Skip to content

Commit

Permalink
Enable new cops and autocorrect offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
philippthun committed Jan 7, 2025
1 parent af6896b commit 05711a2
Show file tree
Hide file tree
Showing 50 changed files with 546 additions and 537 deletions.
28 changes: 28 additions & 0 deletions .rubocop_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,34 @@ Style/RedundantInterpolationUnfreeze:
Enabled: true
Rails/EnumSyntax:
Enabled: true
Lint/DuplicateSetElement:
Enabled: true
Lint/HashNewWithKeywordArgumentsAsDefault:
Enabled: true
Lint/NumericOperationWithConstantResult:
Enabled: true
Lint/UnescapedBracketInRegexp:
Enabled: true
Lint/UselessDefined:
Enabled: true
Style/AmbiguousEndlessMethodDefinition:
Enabled: true
Style/BitwisePredicate:
Enabled: true
Style/CombinableDefined:
Enabled: true
Style/DigChain:
Enabled: true
Style/FileNull:
Enabled: true
Style/FileTouch:
Enabled: true
Style/KeywordArgumentsMerging:
Enabled: true
Style/SafeNavigationChainLength:
Enabled: true
RSpec/StringAsInstanceDoubleConstant:
Enabled: true

### Broken Cops that break code
Lint/ShadowedException: # Breaks "bundle exec rake rubocop" if enabled
Expand Down
93 changes: 37 additions & 56 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-09-30 07:29:13 UTC using RuboCop version 1.66.1.
# on 2025-01-07 13:55:32 UTC using RuboCop version 1.69.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -14,7 +14,7 @@ Lint/AmbiguousRange:
- 'lib/cloud_controller/resource_match.rb'
- 'spec/unit/messages/validators/metadata_validator_spec.rb'

# Offense count: 77
# Offense count: 78
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Expand All @@ -33,7 +33,7 @@ Lint/EmptyConditionalBody:
- 'lib/cloud_controller/diego/failure_reason_sanitizer.rb'
- 'spec/support/shared_examples/jobs/delayed_job.rb'

# Offense count: 57
# Offense count: 56
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Enabled: false
Expand Down Expand Up @@ -68,7 +68,8 @@ Lint/SuppressedException:

# Offense count: 28
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
# NotImplementedExceptions: NotImplementedError
Lint/UnusedMethodArgument:
Exclude:
- 'app/fetchers/feature_flag_list_fetcher.rb'
Expand All @@ -89,22 +90,22 @@ Lint/UselessMethodDefinition:
- 'app/presenters/v3/process_presenter.rb'
- 'spec/support/fake_front_controller.rb'

# Offense count: 791
# Offense count: 799
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 99

# Offense count: 114
# Offense count: 112
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 446
Max: 440

# Offense count: 62
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 9

# Offense count: 162
# Offense count: 164
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 30
Expand All @@ -123,7 +124,7 @@ Naming/HeredocDelimiterNaming:
- 'spec/unit/jobs/deserialization_spec.rb'
- 'spec/unit/lib/app_packager_spec.rb'

# Offense count: 84
# Offense count: 85
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
Expand All @@ -132,14 +133,14 @@ Naming/HeredocDelimiterNaming:
Naming/PredicateName:
Enabled: false

# Offense count: 862
# Offense count: 865
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
# SupportedStyles: snake_case, normalcase, non_integer
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
Naming/VariableNumber:
Enabled: false

# Offense count: 409
# Offense count: 412
RSpec/AnyInstance:
Enabled: false

Expand All @@ -162,18 +163,18 @@ RSpec/ChangeByZero:
Exclude:
- 'spec/unit/actions/update_route_destinations_spec.rb'

# Offense count: 3478
# Offense count: 3498
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false

# Offense count: 99
# Offense count: 102
# Configuration parameters: IgnoredMetadata.
RSpec/DescribeClass:
Enabled: false

# Offense count: 4434
# Offense count: 4462
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
# SupportedStyles: described_class, explicit
Expand All @@ -186,7 +187,7 @@ RSpec/DescribedClass:
RSpec/EmptyExampleGroup:
Enabled: false

# Offense count: 4303
# Offense count: 4326
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 158
Expand All @@ -198,20 +199,20 @@ RSpec/ExpectActual:
- 'spec/unit/support/matchers/be_a_response_like_spec.rb'
- 'spec/unit/support/matchers/match_json_response_spec.rb'

# Offense count: 120
# Offense count: 123
RSpec/ExpectInHook:
Enabled: false

# Offense count: 79
RSpec/ExpectInLet:
Enabled: false

# Offense count: 1501
# Offense count: 1492
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
RSpec/IndexedLet:
Enabled: false

# Offense count: 718
# Offense count: 703
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Enabled: false
Expand All @@ -222,11 +223,11 @@ RSpec/IteratedExpectation:
- 'spec/unit/lib/cloud_controller/diego/main_lrp_action_builder_spec.rb'
- 'spec/unit/lib/services/service_brokers/service_broker_remover_spec.rb'

# Offense count: 71
# Offense count: 72
RSpec/LeakyConstantDeclaration:
Enabled: false

# Offense count: 943
# Offense count: 956
RSpec/LetSetup:
Enabled: false

Expand All @@ -238,7 +239,7 @@ RSpec/MessageChain:
- 'spec/unit/messages/space_quota_update_message_spec.rb'
- 'spec/unit/messages/space_quotas_create_message_spec.rb'

# Offense count: 798
# Offense count: 813
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Expand All @@ -250,22 +251,22 @@ RSpec/MultipleDescribes:
- 'spec/request/knowledge_bombs/verify_old_lrps_can_download_assets_spec.rb'
- 'spec/unit/lib/vcap/json_message_spec.rb'

# Offense count: 8101
# Offense count: 8156
RSpec/MultipleExpectations:
Max: 48

# Offense count: 8945
# Offense count: 8967
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 36

# Offense count: 2557
# Offense count: 2584
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Enabled: false

# Offense count: 1602
# Offense count: 1611
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 8
Expand Down Expand Up @@ -333,11 +334,10 @@ RSpec/RepeatedExampleGroupBody:
- 'spec/unit/lib/rest_controller/paginated_collection_renderer_spec.rb'
- 'spec/unit/messages/process_update_message_spec.rb'

# Offense count: 28
# Offense count: 26
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/unit/actions/app_apply_manifest_spec.rb'
- 'spec/unit/actions/app_assign_droplet_spec.rb'
- 'spec/unit/controllers/runtime/organizations_controller_spec.rb'
- 'spec/unit/controllers/v3/resource_matches_controller_spec.rb'
- 'spec/unit/jobs/services/service_binding_state_fetch_spec.rb'
Expand All @@ -359,7 +359,7 @@ RSpec/ReturnFromStub:
Exclude:
- 'spec/unit/lib/cloud_controller/errands/rotate_database_key_spec.rb'

# Offense count: 206
# Offense count: 207
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect.
RSpec/ScatteredLet:
Expand All @@ -371,7 +371,7 @@ RSpec/ScatteredLet:
RSpec/SpecFilePathFormat:
Enabled: false

# Offense count: 203
# Offense count: 200
RSpec/StubbedMock:
Enabled: false

Expand Down Expand Up @@ -409,7 +409,7 @@ RSpec/VariableName:
- 'spec/request/revisions_spec.rb'
- 'spec/request/spaces_spec.rb'

# Offense count: 536
# Offense count: 540
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Enabled: false
Expand All @@ -422,7 +422,7 @@ RSpec/VoidExpect:
- 'spec/unit/jobs/runtime/prune_excess_app_revisions_spec.rb'
- 'spec/unit/lib/cloud_controller/integer_array_serializer_spec.rb'

# Offense count: 1591
# Offense count: 1598
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ResponseMethods.
# ResponseMethods: response, last_response
Expand All @@ -448,22 +448,13 @@ Rails/ThreeStateBooleanColumn:
- 'db/migrations/20141022211551_add_updateable_column_to_services.rb'
- 'db/migrations/20151217235335_remove_unused_package_cols.rb'

# Offense count: 260
# Offense count: 268
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, flexible
Rails/TimeZone:
Enabled: false

# Offense count: 8
# Configuration parameters: TransactionMethods.
Rails/TransactionExitStatement:
Exclude:
- 'app/actions/deployment_create.rb'
- 'app/jobs/v2/services/service_binding_state_fetch.rb'
- 'app/jobs/v2/services/service_instance_state_fetch.rb'
- 'lib/cloud_controller/deployment_updater/updater.rb'

# Offense count: 2
# Configuration parameters: Severity.
Rails/UnusedRenderContent:
Expand Down Expand Up @@ -494,23 +485,13 @@ Style/CaseLikeIf:
- 'lib/vcap/host_system.rb'
- 'spec/support/shared_examples/jobs/delayed_job.rb'

# Offense count: 2014
# Offense count: 2021
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Enabled: false

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
# AllowedReceivers: params
Style/CollectionCompact:
Exclude:
- 'app/presenters/v3/app_presenter.rb'
- 'app/presenters/v3/package_presenter.rb'
- 'lib/vcap/json_message.rb'

# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CombinableLoops:
Expand All @@ -521,7 +502,7 @@ Style/CombinableLoops:
- 'spec/linters/migration/add_constraint_name.rb'
- 'spec/unit/models/runtime/organization_spec.rb'

# Offense count: 1488
# Offense count: 1462
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false
Expand All @@ -538,7 +519,7 @@ Style/DoubleNegation:
- 'spec/support/matchers/have_attributes.rb'
- 'spec/unit/lib/services/service_brokers/v2/response_parser_spec.rb'

# Offense count: 3279
# Offense count: 3287
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Expand Down Expand Up @@ -571,11 +552,11 @@ Style/MapToHash:
- 'app/models/runtime/app_model.rb'
- 'lib/cloud_controller/diego/reporters/instances_stats_reporter.rb'

# Offense count: 76
# Offense count: 75
Style/MultilineBlockChain:
Enabled: false

# Offense count: 53
# Offense count: 57
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
# SupportedStyles: predicate, comparison
Expand Down
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path('application', __dir__)

Rails.logger = Logger.new('/dev/null')
Rails.logger = Logger.new(File::NULL)
Rails.application.initialize!
2 changes: 1 addition & 1 deletion lib/cloud_controller/blobstore/fingerprints_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def each(&block)

def parse_mode(raw_mode, filename)
mode = raw_mode ? raw_mode.to_i(8) : DEFAULT_FILE_MODE
unless (mode & 0o600) == 0o600
unless mode.allbits?(0o600)
raise CloudController::Errors::ApiError.new_from_details('AppResourcesFileModeInvalid',
"File mode '#{raw_mode}' with path '#{filename}' is invalid. Minimum file mode is '0600'")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/request/admin_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

let(:expected_codes_and_responses) do
h = Hash.new(
code: 403
{ code: 403 }
)
h['admin'] = {
code: 202
Expand Down
Loading

0 comments on commit 05711a2

Please sign in to comment.