Skip to content

Commit

Permalink
Merge pull request cloudfoundry#650 from Justin-W/issue-648
Browse files Browse the repository at this point in the history
Fix Rubocop dependencies and config
  • Loading branch information
rkoster authored Dec 7, 2021
2 parents 9754cf8 + 7203bbe commit 9f17475
Show file tree
Hide file tree
Showing 22 changed files with 1,169 additions and 105 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ config/private.yml
dev_releases
releases/*.tgz
releases/**/*.tgz
rubocop_cache/
#src/bosh_azure_cpi/501/rubocop_cache/
src/bosh_azure_cpi/vendor/cache
src/bosh_azure_cpi/coverage
src/bosh_azure_cpi/spec/manual_tests/performance/stemcell_to_test.tgz
Expand Down
54 changes: 52 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,62 @@ Your development environment is prepared successfully.
### Unit tests
The [unit tests](https://github.com/cloudfoundry/bosh-azure-cpi-release/tree/master/src/bosh_azure_cpi/spec/unit) are **REQUIRED** before you submit a PR. When submitting a PR, you need to provide the test coverage and make sure that the coverage doesn't decrease.
The [unit tests](https://github.com/cloudfoundry/bosh-azure-cpi-release/tree/master/src/bosh_azure_cpi/spec/unit)
are **REQUIRED** before you submit a PR.
When submitting a PR, you need to provide the test coverage and make sure that the coverage doesn't decrease.

```bash
cd ~/workspace/bosh-azure-cpi-release/src/bosh_azure_cpi
./bin/test-unit
```

or:

```bash
cd ~/workspace/bosh-azure-cpi-release
pushd src/bosh_azure_cpi
./bin/test-unit
popd
```

or:

```bash
cd ~/workspace/bosh-azure-cpi-release
pushd 'src/bosh_azure_cpi' ; ./bin/test-unit ; popd
```

If unit tests are passed, you can create a dev release and deploy it for tests.

### Rubocop

The [rubocop_check](https://github.com/cloudfoundry/bosh-azure-cpi-release/tree/master/src/bosh_azure_cpi/bin/rubocop_check)
script checks for rubocop offenses.

```bash
cd ~/workspace/bosh-azure-cpi-release/src/bosh_azure_cpi
bundle install --with=test
./bin/rubocop_check
```

#### Rubocop autofix

The [rubocop_autofix](https://github.com/cloudfoundry/bosh-azure-cpi-release/tree/master/src/bosh_azure_cpi/bin/rubocop_autofix)
script auto-corrects any rubocop offenses which can be auto-corrected.

**_WARNING_:** Running this script **_COULD_** introduce bugs into the code.
Auto-correct code changes made by rubocop **_ARE NOT_** guaranteed to be functionally equivalent to the original code.
You should _carefully_ review all auto-corrected code changes made by rubocop before merging them.

However, with the above warning clearly in mind, this script may be useful in certain situations,
even if only as a way to better understand the 'problem' for rubocop offenses with ambiguous output.

```bash
cd ~/workspace/bosh-azure-cpi-release/src/bosh_azure_cpi
bundle install --with=test
./bin/rubocop_autofix
```

#### Running ERB job templates unit tests

The ERB templates rendered by the jobs of this Bosh Release have specific unit
Expand All @@ -147,7 +194,10 @@ required, you can run them separately though, with this command:

### CI Pipeline

You can setup a [CI pipeline](../ci/) to run the [integration tests](https://github.com/cloudfoundry/bosh-azure-cpi-release/tree/master/src/bosh_azure_cpi/spec/integration) and [BATs](https://github.com/cloudfoundry/bosh-acceptance-tests/tree/gocli-bats). It's optional for submitting a PR and required for publishing a new CPI release.
You can setup a [CI pipeline](../ci/) to run the
[integration tests](https://github.com/cloudfoundry/bosh-azure-cpi-release/tree/master/src/bosh_azure_cpi/spec/integration)
and [BATs](https://github.com/cloudfoundry/bosh-acceptance-tests/tree/gocli-bats).
It's optional for submitting a PR and required for publishing a new CPI release.
### Test CPI methods
Expand Down
157 changes: 157 additions & 0 deletions src/bosh_azure_cpi/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,161 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-rake
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.7.3

Gemspec/DateAssignment: # new in 1.10
Enabled: true

Gemspec/RequireMFA: # new in 1.23
Enabled: true

Layout/LineEndStringConcatenationIndentation: # new in 1.18
Enabled: true

Layout/SpaceBeforeBrackets: # new in 1.7
Enabled: true

Lint/AmbiguousAssignment: # new in 1.7
Enabled: true

Lint/AmbiguousOperatorPrecedence: # new in 1.21
Enabled: true

Lint/AmbiguousRange: # new in 1.19
Enabled: true

Lint/DeprecatedConstants: # new in 1.8
Enabled: true

Lint/DuplicateBranch: # new in 1.3
Enabled: true

Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
Enabled: true

Lint/EmptyBlock: # new in 1.1
Enabled: true

Lint/EmptyClass: # new in 1.3
Enabled: true

Lint/EmptyInPattern: # new in 1.16
Enabled: true

Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
Enabled: true

Lint/LambdaWithoutLiteralBlock: # new in 1.8
Enabled: true

Lint/NoReturnInBeginEndBlocks: # new in 1.2
Enabled: true

Lint/NumberedParameterAssignment: # new in 1.9
Enabled: true

Lint/OrAssignmentToConstant: # new in 1.9
Enabled: true

Lint/RedundantDirGlobSort: # new in 1.8
Enabled: true

Lint/RequireRelativeSelfPath: # new in 1.22
Enabled: true

Lint/SymbolConversion: # new in 1.9
Enabled: true

Lint/ToEnumArguments: # new in 1.1
Enabled: true

Lint/TripleQuotes: # new in 1.9
Enabled: true

Lint/UnexpectedBlockArity: # new in 1.5
Enabled: true

Lint/UnmodifiedReduceAccumulator: # new in 1.1
Enabled: true

Lint/UselessRuby2Keywords: # new in 1.23
Enabled: true

RSpec/ExcessiveDocstringSpacing: # new in 2.5
Enabled: true

RSpec/IdenticalEqualityAssertion: # new in 2.4
Enabled: true

RSpec/SubjectDeclaration: # new in 2.5
Enabled: true

RSpec/Rails/AvoidSetupHook: # new in 2.4
Enabled: true

Security/IoMethods: # new in 1.22
Enabled: true

Style/ArgumentsForwarding: # new in 1.1
Enabled: true

Style/CollectionCompact: # new in 1.2
Enabled: true

Style/DocumentDynamicEvalDefinition: # new in 1.1
Enabled: true

Style/EndlessMethod: # new in 1.8
Enabled: true

Style/HashConversion: # new in 1.10
Enabled: true

Style/HashExcept: # new in 1.7
Enabled: true

Style/IfWithBooleanLiteralBranches: # new in 1.9
Enabled: true

Style/InPatternThen: # new in 1.16
Enabled: true

Style/MultilineInPatternThen: # new in 1.16
Enabled: true

Style/NegatedIfElseCondition: # new in 1.2
Enabled: true

Style/NilLambda: # new in 1.3
Enabled: true

Style/NumberedParameters: # new in 1.22
Enabled: true

Style/NumberedParametersLimit: # new in 1.22
Enabled: true

Style/OpenStructUse: # new in 1.23
Enabled: true

Style/QuotedSymbols: # new in 1.16
Enabled: true

Style/RedundantArgument: # new in 1.4
Enabled: true

Style/RedundantSelfAssignmentBranch: # new in 1.19
Enabled: true

Style/SelectByRegexp: # new in 1.22
Enabled: true

Style/StringChars: # new in 1.12
Enabled: true

Style/SwapValues: # new in 1.1
Enabled: true
Loading

0 comments on commit 9f17475

Please sign in to comment.