From 8c134301428eb15d63da084fb5bc8d32b81d3cae Mon Sep 17 00:00:00 2001 From: Philipp Thun Date: Wed, 4 Feb 2026 11:00:02 +0100 Subject: [PATCH] Enable new cops, fix offenses, update todos And also remove unneeded configuration, order cops and cleanup stuff. --- .rubocop_cc.yml | 695 +++++++++++------- .rubocop_todo.yml | 206 +++--- app/actions/app_update.rb | 2 +- app/actions/build_create.rb | 2 +- app/actions/v2/app_update.rb | 2 +- app/jobs/runtime/failed_jobs_cleanup.rb | 2 +- ...grow_service_instances_syslog_drain_url.rb | 2 - ..._grow_service_bindings_syslog_drain_url.rb | 2 - ...roker_catalog_descriptions_to_type_text.rb | 4 - ...er_name_and_guid_to_service_usage_event.rb | 2 - ...2003850_add_revision_description_column.rb | 2 - ...20190930225152_add_sidecars_to_droplets.rb | 2 - lib/cloud_controller/seeds.rb | 2 +- lib/locket/lock_runner.rb | 18 +- lib/sequel_plugins/vcap_relations.rb | 2 +- 15 files changed, 545 insertions(+), 400 deletions(-) diff --git a/.rubocop_cc.yml b/.rubocop_cc.yml index 247abab2a57..9f6497665e4 100644 --- a/.rubocop_cc.yml +++ b/.rubocop_cc.yml @@ -15,33 +15,33 @@ require: - ./spec/linters/match_requires_with_includes.rb - ./spec/linters/prefer_oj_over_other_json_libraries.rb + +#### BASE SECTION AllCops: TargetRubyVersion: 3.2 Exclude: - - errors/**/* - - lib/diego/bbs/models/**/* - - lib/locket/**/* - - lib/loggregator-api/**/* - - lib/logcache/*_pb.rb + - lib/diego/bbs/models/**/*_pb.rb + - lib/locket/**/*_pb.rb + - lib/logcache/**/*_pb.rb + - lib/loggregator-api/**/*_pb.rb - vendor/bundle/**/* + + +#### CUSTOMIZED SECTION Layout/DotPosition: EnforcedStyle: trailing -Layout/FirstArrayElementIndentation: - EnforcedStyle: consistent -Layout/SpaceAroundEqualsInParameterDefault: - EnforcedStyle: no_space Layout/EmptyLineBetweenDefs: EmptyLineBetweenClassDefs: false +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent Layout/LineLength: Max: 180 -Lint/UnifiedInteger: - Exclude: - - db/migrations/**/* +Layout/SpaceAroundEqualsInParameterDefault: + EnforcedStyle: no_space Metrics/BlockLength: Exclude: - - db/migrations/**/* - - spec/**/* - - lib/cloud_controller/config.rb + - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ + - !ruby/regexp /db/migrations/202([0-5]).+\.rb$/ - config/routes.rb - lib/tasks/db.rake - lib/tasks/jobs.rake @@ -51,98 +51,112 @@ Metrics/CyclomaticComplexity: Metrics/MethodLength: Max: 60 Metrics/ModuleLength: - Max: 200 Exclude: - spec/**/* + Max: 200 Migration/AddConstraintName: # Exclude for old Migrations Include: - - 'db/migrations/**/*' + - db/migrations/**/* Exclude: - - !ruby/regexp /db/migrations/201([0-6]|70[1-6]).+\.rb$/ - - db/migrations/20221125134500_add_request_count_table.rb - + - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ + - !ruby/regexp /db/migrations/202([0-2]).+\.rb$/ Migration/IncludeStringSize: # Exclude for old Migrations Include: - - 'db/migrations/**/*' + - db/migrations/**/* Exclude: - - !ruby/regexp /db/migrations/201([0-6]|70[1-6]|707[01]).+\.rb$/ - - db/migrations/20221125134500_add_request_count_table.rb - + - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ + - !ruby/regexp /db/migrations/202([0-2]).+\.rb$/ Migration/RequirePrimaryKey: # Exclude for old Migrations Include: - - 'db/migrations/**/*' - Exclude: - - !ruby/regexp /db/migrations/201([0-7]|80[1-3]).+\.rb$/ - -Sequel/ConcurrentIndex: # Exclude for old Migrations - Exclude: - - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ - - !ruby/regexp /db/migrations/202([0-2]|30[0-7]).+\.rb$/ - - spec/**/* - -Sequel/IrreversibleMigration: # Exclude for old Migrations + - db/migrations/**/* Exclude: - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ - - !ruby/regexp /db/migrations/202([0-3]).+\.rb$/ - - spec/**/* - -Rails/HttpPositionalArguments: # Breaks Code for specs as it`s not rails used there it`s a test framework(racktest) - Exclude: - - spec/**/* - -Rails/Blank: # Alters logic if NilOrEmpty is true - NilOrEmpty: false - -Rails/Present: # Alters logic if NotNilAndNotEmpty is true - NotNilAndNotEmpty: false - -Rails/Output: # Exclude for blobstore benchmark - Exclude: - - lib/cloud_controller/benchmark/blobstore.rb - -Naming/FileName: - Exclude: - - Guardfile Naming/MethodParameterName: - MinNameLength: 3 - AllowNamesEndingInNumbers: true AllowedNames: - - '_' - e - - io - id - - to - by - 'on' - - in - at - - ip - db - ForbiddenNames: [] + AllowNamesEndingInNumbers: true + MinNameLength: 3 +Rails/Blank: # Alters logic if NilOrEmpty is true + NilOrEmpty: false +Rails/HttpPositionalArguments: # Breaks Code for specs as it's not rails used there it's a test framework (racktest) + Exclude: + - spec/**/* +Rails/Output: # Exclude for blobstore benchmark + Exclude: + - lib/cloud_controller/benchmark/blobstore.rb +Rails/Present: # Alters logic if NotNilAndNotEmpty is true + NotNilAndNotEmpty: false +Rails/SkipsModelValidations: # We don't want any model at all in migrations and migration specs + Exclude: + - db/migrations/**/* + - spec/migrations/**/* +Sequel/ConcurrentIndex: + Exclude: + - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ + - !ruby/regexp /db/migrations/202([0-3]).+\.rb$/ +Sequel/IrreversibleMigration: + Exclude: + - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ + - !ruby/regexp /db/migrations/202([0-3]).+\.rb$/ Style/Alias: EnforcedStyle: prefer_alias_method -Style/Encoding: +Style/ExpandPathArguments: Exclude: - - "**/*.pb.rb" + - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/ Style/FormatString: EnforcedStyle: sprintf -Style/RaiseArgs: - EnforcedStyle: compact Style/HashSyntax: EnforcedShorthandSyntax: consistent -Style/ExpandPathArguments: - Exclude: - - 'db/migrations/20130911111938_encrypt_app_env_json.rb' - - 'db/migrations/201805*' -Rails/DangerousColumnNames: # Disabled, in comparison to active_record we need to add the id column manually in sequel - Enabled: false -Rails/SkipsModelValidations: # We don`t want any model at all in migrations and migration specs - Enabled: true - Exclude: - - db/migrations/**/* - - spec/migrations/**/* +Style/RaiseArgs: + EnforcedStyle: compact + #### ENABLED SECTION +Capybara/ClickLinkOrButtonStyle: + Enabled: true +Capybara/FindAllFirst: + Enabled: true +Capybara/MatchStyle: + Enabled: true +Capybara/NegationMatcher: + Enabled: true +Capybara/NegationMatcherAfterVisit: + Enabled: true +Capybara/RedundantWithinFind: + Enabled: true +Capybara/RSpec/HaveSelector: + Enabled: true +Capybara/RSpec/PredicateMatcher: + Enabled: true +Capybara/SpecificActions: + Enabled: true +Capybara/SpecificFinders: + Enabled: true +Capybara/SpecificMatcher: + Enabled: true +FactoryBot/AssociationStyle: + Enabled: true +FactoryBot/ConsistentParenthesesStyle: + Enabled: true +FactoryBot/ExcessiveCreateList: + Enabled: true +FactoryBot/FactoryAssociationWithStrategy: + Enabled: true +FactoryBot/FactoryNameStyle: + Enabled: true +FactoryBot/IdSequence: + Enabled: true +FactoryBot/RedundantFactoryOption: + Enabled: true +FactoryBot/SyntaxMethods: + Enabled: true +Gemspec/AddRuntimeDependency: + Enabled: true Gemspec/AttributeAssignment: Enabled: true Gemspec/DeprecatedAttributeAssignment: @@ -169,6 +183,8 @@ Lint/AmbiguousRange: Enabled: true Lint/ArrayLiteralInRegexp: Enabled: true +Lint/ConstantDefinitionInBlock: + Enabled: true Lint/ConstantOverwrittenInRescue: Enabled: true Lint/ConstantReassignment: @@ -191,6 +207,8 @@ Lint/EmptyBlock: Enabled: true Lint/EmptyClass: Enabled: true +Lint/EmptyConditionalBody: + Enabled: true Lint/EmptyInPattern: Enabled: true Lint/HashNewWithKeywordArgumentsAsDefault: @@ -203,6 +221,8 @@ Lint/LambdaWithoutLiteralBlock: Enabled: true Lint/LiteralAssignmentInCondition: Enabled: true +Lint/MissingSuper: + Enabled: true Lint/MixedCaseRange: Enabled: true Lint/NoReturnInBeginEndBlocks: @@ -229,6 +249,8 @@ Lint/RequireRelativeSelfPath: Enabled: true Lint/SharedMutableDefault: Enabled: true +Lint/SuppressedException: + Enabled: true Lint/SuppressedExceptionInNumberConversion: Enabled: true Lint/SymbolConversion: @@ -241,415 +263,524 @@ Lint/UnescapedBracketInRegexp: Enabled: true Lint/UnexpectedBlockArity: Enabled: true +Lint/UnifiedInteger: + Enabled: true Lint/UnmodifiedReduceAccumulator: Enabled: true +Lint/UnusedMethodArgument: + Enabled: true +Lint/UselessConstantScoping: + Enabled: true Lint/UselessDefaultValueArgument: Enabled: true Lint/UselessDefined: Enabled: true +Lint/UselessMethodDefinition: + Enabled: true +Lint/UselessNumericOperation: + Enabled: true Lint/UselessOr: Enabled: true Lint/UselessRescue: Enabled: true Lint/UselessRuby2Keywords: Enabled: true -Metrics/CollectionLiteralLength: +Metrics/AbcSize: Enabled: true -Naming/BlockForwarding: +Metrics/ClassLength: Enabled: true -Security/CompoundHash: +Metrics/CollectionLiteralLength: Enabled: true -Security/IoMethods: +Metrics/ParameterLists: Enabled: true -Style/AmbiguousEndlessMethodDefinition: +Metrics/PerceivedComplexity: Enabled: true -Style/ArgumentsForwarding: +Naming/BlockForwarding: Enabled: true -Style/ArrayIntersect: +Naming/FileName: Enabled: true -Style/ArrayIntersectWithSingleElement: +Naming/HeredocDelimiterNaming: Enabled: true -Style/BitwisePredicate: +Naming/PredicateMethod: Enabled: true -Style/CollectionCompact: +Naming/PredicatePrefix: Enabled: true -Style/CombinableDefined: +Naming/VariableNumber: Enabled: true -Style/ComparableBetween: +Rails/ActionControllerFlashBeforeRender: Enabled: true -Style/ComparableClamp: +Rails/ActionControllerTestCase: Enabled: true -Style/ConcatArrayLiterals: +Rails/ActionOrder: Enabled: true -Style/DataInheritance: +Rails/ActiveRecordAliases: Enabled: true -Style/DigChain: +Rails/ActiveRecordCallbacksOrder: Enabled: true -Style/DirEmpty: +Rails/ActiveSupportOnLoad: Enabled: true -Style/DocumentDynamicEvalDefinition: +Rails/AddColumnIndex: Enabled: true -Style/EmptyHeredoc: +Rails/AfterCommitOverride: Enabled: true -Style/EmptyStringInsideInterpolation: +Rails/AttributeDefaultBlockValue: Enabled: true -Style/EndlessMethod: +Rails/CompactBlank: Enabled: true -Style/EnvHome: +Rails/DeprecatedActiveModelErrorsMethods: Enabled: true -Style/ExactRegexpMatch: +Rails/DotSeparatedKeys: Enabled: true -Style/FetchEnvVar: +Rails/DuplicateAssociation: Enabled: true -Style/FileEmpty: +Rails/DuplicateScope: Enabled: true -Style/FileNull: +Rails/DurationArithmetic: Enabled: true -Style/FileRead: +Rails/EagerEvaluationLogMessage: Enabled: true -Style/FileTouch: +Rails/EnumSyntax: Enabled: true -Style/FileWrite: +Rails/EnvLocal: Enabled: true -Style/HashConversion: +Rails/ExpandedDateRange: Enabled: true -Style/HashExcept: +Rails/FindById: Enabled: true -Style/HashFetchChain: +Rails/FindByOrAssignmentMemoization: Enabled: true -Style/IfWithBooleanLiteralBranches: +Rails/FreezeTime: Enabled: true -Style/InPatternThen: +Rails/HttpStatusNameConsistency: Enabled: true -Style/ItAssignment: +Rails/I18nLazyLookup: Enabled: true -Style/ItBlockParameter: +Rails/I18nLocaleAssignment: Enabled: true -Style/KeywordArgumentsMerging: +Rails/IgnoredColumnsAssignment: Enabled: true -Style/MagicCommentFormat: +Rails/Inquiry: Enabled: true -Style/MapCompactWithConditionalBlock: +Rails/MailerName: Enabled: true -Style/MapToHash: +Rails/MatchRoute: Enabled: true -Style/MapToSet: +Rails/MigrationClassName: Enabled: true -Style/MinMaxComparison: +Rails/MultipleRoutePaths: Enabled: true -Style/MultilineInPatternThen: +Rails/NegateInclude: Enabled: true -Style/NegatedIfElseCondition: +Rails/OrderArguments: Enabled: true -Style/NestedFileDirname: +Rails/Pluck: Enabled: true -Style/NilLambda: +Rails/PluckInWhere: Enabled: true -Style/NumberedParameters: +Rails/RedirectBackOrTo: Enabled: true -Style/NumberedParametersLimit: +Rails/RedundantPresenceValidationOnBelongsTo: Enabled: true -Style/ObjectThen: +Rails/RedundantTravelBack: Enabled: true -Style/OpenStructUse: +Rails/RenderInline: Enabled: true -Style/OperatorMethodCall: +Rails/RenderPlainText: Enabled: true -Style/QuotedSymbols: +Rails/ResponseParsedBody: Enabled: true -Style/RedundantArgument: +Rails/RootJoinChain: Enabled: true -Style/RedundantArrayConstructor: +Rails/RootPathnameMethods: Enabled: true -Style/RedundantArrayFlatten: +Rails/RootPublicPath: Enabled: true -Style/RedundantConstantBase: +Rails/SelectMap: Enabled: true -Style/RedundantCurrentDirectoryInPath: +Rails/ShortI18n: Enabled: true -Style/RedundantDoubleSplatHashBraces: +Rails/SquishedSQLHeredocs: Enabled: true -Style/RedundantEach: +Rails/StripHeredoc: Enabled: true -Style/RedundantFilterChain: +Rails/StrongParametersExpect: Enabled: true -Style/RedundantFormat: +Rails/ThreeStateBooleanColumn: Enabled: true -Style/RedundantHeredocDelimiterQuotes: +Rails/TimeZone: Enabled: true -Style/RedundantInitialize: +Rails/TimeZoneAssignment: Enabled: true -Style/RedundantLineContinuation: +Rails/ToFormattedS: Enabled: true -Style/RedundantRegexpArgument: +Rails/ToSWithArgument: Enabled: true -Style/RedundantRegexpConstructor: +Rails/TopLevelHashWithIndifferentAccess: Enabled: true -Style/RedundantSelfAssignmentBranch: +Rails/TransactionExitStatement: Enabled: true -Style/RedundantStringEscape: +Rails/UnusedIgnoredColumns: Enabled: true -Style/ReturnNilInPredicateMethodDefinition: +Rails/UnusedRenderContent: Enabled: true -Style/SafeNavigationChainLength: +Rails/WhereEquals: Enabled: true -Style/SelectByRegexp: +Rails/WhereExists: Enabled: true -Style/StringChars: +Rails/WhereMissing: Enabled: true -Style/SuperWithArgsParentheses: +Rails/WhereNot: Enabled: true -Style/SwapValues: +Rails/WhereNotWithMultipleConditions: Enabled: true -Style/YAMLFileRead: +Rails/WhereRange: Enabled: true -Rails/ActionControllerFlashBeforeRender: +RSpec/AnyInstance: Enabled: true -Rails/ActionControllerTestCase: +RSpec/Be: Enabled: true -Rails/ActionOrder: +RSpec/BeEmpty: Enabled: true -Rails/ActiveRecordCallbacksOrder: +RSpec/BeEq: Enabled: true -Rails/ActiveSupportOnLoad: +RSpec/BeforeAfterAll: Enabled: true -Rails/AddColumnIndex: +RSpec/BeNil: Enabled: true -Rails/AfterCommitOverride: +RSpec/ChangeByZero: Enabled: true -Rails/AttributeDefaultBlockValue: +RSpec/ContainExactly: Enabled: true -Rails/CompactBlank: +RSpec/ContextWording: Enabled: true -Rails/DeprecatedActiveModelErrorsMethods: +RSpec/DescribeClass: Enabled: true -Rails/DotSeparatedKeys: +RSpec/DescribedClass: Enabled: true -Rails/DuplicateAssociation: +RSpec/DuplicatedMetadata: Enabled: true -Rails/DuplicateScope: +RSpec/EmptyExampleGroup: Enabled: true -Rails/DurationArithmetic: +RSpec/EmptyMetadata: Enabled: true -Rails/EagerEvaluationLogMessage: +RSpec/Eq: Enabled: true -Rails/EnvLocal: +RSpec/ExampleLength: Enabled: true -Rails/ExpandedDateRange: +RSpec/ExcessiveDocstringSpacing: Enabled: true -Rails/FindById: +RSpec/ExpectActual: Enabled: true -Rails/FindByOrAssignmentMemoization: +RSpec/ExpectInHook: Enabled: true -Rails/FreezeTime: +RSpec/ExpectInLet: Enabled: true -Rails/I18nLazyLookup: - Enabled: false -Rails/I18nLocaleAssignment: - Enabled: false -Rails/I18nLocaleTexts: - Enabled: false -Rails/IgnoredColumnsAssignment: +RSpec/IdenticalEqualityAssertion: Enabled: true -Rails/Inquiry: +RSpec/IncludeExamples: Enabled: true -Rails/MailerName: +RSpec/IndexedLet: Enabled: true -Rails/MatchRoute: +RSpec/InstanceVariable: Enabled: true -Rails/MigrationClassName: +RSpec/IteratedExpectation: Enabled: true -Rails/MultipleRoutePaths: +RSpec/LeakyConstantDeclaration: Enabled: true -Rails/NegateInclude: +RSpec/LeakyLocalVariable: Enabled: true -Rails/OrderArguments: +RSpec/LetSetup: Enabled: true -Rails/Pluck: +RSpec/MatchArray: Enabled: true -Rails/PluckInWhere: +RSpec/MessageChain: Enabled: true -Rails/RedundantPresenceValidationOnBelongsTo: +RSpec/MessageSpies: Enabled: true -Rails/RedundantTravelBack: +RSpec/MetadataStyle: Enabled: true -Rails/RenderInline: +RSpec/MultipleDescribes: Enabled: true -Rails/RenderPlainText: +RSpec/MultipleExpectations: Enabled: true -Rails/ResponseParsedBody: +RSpec/MultipleMemoizedHelpers: Enabled: true -Rails/RootJoinChain: +RSpec/NamedSubject: Enabled: true -Rails/RootPathnameMethods: +RSpec/NestedGroups: Enabled: true -Rails/RootPublicPath: +RSpec/NoExpectationExample: Enabled: true -Rails/SelectMap: +RSpec/OverwritingSetup: Enabled: true -Rails/ShortI18n: +RSpec/PendingWithoutReason: Enabled: true -Rails/SquishedSQLHeredocs: +RSpec/ReceiveMessages: Enabled: true -Rails/StripHeredoc: +RSpec/RedundantAround: Enabled: true -Rails/StrongParametersExpect: +RSpec/RedundantPredicateMatcher: Enabled: true -Rails/ThreeStateBooleanColumn: +RSpec/RemoveConst: Enabled: true -Rails/TimeZoneAssignment: +RSpec/RepeatedDescription: Enabled: true -Rails/ToFormattedS: +RSpec/RepeatedExample: Enabled: true -Rails/ToSWithArgument: +RSpec/RepeatedExampleGroupBody: Enabled: true -Rails/TopLevelHashWithIndifferentAccess: +RSpec/RepeatedExampleGroupDescription: Enabled: true -Rails/TransactionExitStatement: +RSpec/ReturnFromStub: Enabled: true -Rails/UnusedIgnoredColumns: +RSpec/ScatteredLet: Enabled: true -Rails/UnusedRenderContent: +RSpec/SkipBlockInsideExample: Enabled: true -Rails/WhereEquals: +RSpec/SortMetadata: Enabled: true -Rails/WhereExists: +RSpec/SpecFilePathFormat: Enabled: true -Rails/WhereMissing: +RSpec/SpecFilePathSuffix: Enabled: true -Rails/WhereNot: +RSpec/StubbedMock: Enabled: true -Rails/WhereNotWithMultipleConditions: +RSpec/SubjectDeclaration: Enabled: true -Capybara/ClickLinkOrButtonStyle: - Enabled: false -Capybara/FindAllFirst: +RSpec/SubjectStub: Enabled: true -Capybara/MatchStyle: - Enabled: false -Capybara/NegationMatcher: - Enabled: false -Capybara/NegationMatcherAfterVisit: +RSpec/VariableName: Enabled: true -Capybara/RedundantWithinFind: +RSpec/VerifiedDoubleReference: Enabled: true -Capybara/SpecificActions: - Enabled: false -Capybara/SpecificFinders: - Enabled: false -Capybara/SpecificMatcher: - Enabled: false -Capybara/RSpec/HaveSelector: - Enabled: false -Capybara/RSpec/PredicateMatcher: - Enabled: false -FactoryBot/AssociationStyle: +RSpec/VerifiedDoubles: Enabled: true -FactoryBot/ConsistentParenthesesStyle: +RSpec/VoidExpect: Enabled: true -FactoryBot/ExcessiveCreateList: +RSpecRails/AvoidSetupHook: Enabled: true -FactoryBot/FactoryAssociationWithStrategy: +RSpecRails/HaveHttpStatus: Enabled: true -FactoryBot/FactoryNameStyle: +RSpecRails/InferredSpecType: Enabled: true -FactoryBot/IdSequence: +RSpecRails/MinitestAssertions: Enabled: true -FactoryBot/RedundantFactoryOption: +RSpecRails/NegationBeValid: Enabled: true -FactoryBot/SyntaxMethods: +RSpecRails/TravelAround: Enabled: true -RSpec/BeEmpty: +Security/CompoundHash: Enabled: true -RSpec/BeEq: +Security/IoMethods: Enabled: true -RSpec/BeNil: +Style/AmbiguousEndlessMethodDefinition: Enabled: true -RSpec/ChangeByZero: +Style/ArgumentsForwarding: Enabled: true -RSpec/ContainExactly: +Style/ArrayIntersect: Enabled: true -RSpec/DuplicatedMetadata: +Style/ArrayIntersectWithSingleElement: Enabled: true -RSpec/EmptyMetadata: +Style/BitwisePredicate: Enabled: true -RSpec/Eq: +Style/CaseLikeIf: Enabled: true -RSpec/ExcessiveDocstringSpacing: +Style/ClassAndModuleChildren: Enabled: true -RSpec/IdenticalEqualityAssertion: +Style/CollectionCompact: Enabled: true -RSpec/IndexedLet: +Style/CollectionQuerying: Enabled: true -RSpec/MatchArray: +Style/CombinableDefined: Enabled: true -RSpec/MetadataStyle: +Style/CombinableLoops: Enabled: true -RSpec/NoExpectationExample: +Style/ComparableBetween: Enabled: true -RSpec/PendingWithoutReason: +Style/ComparableClamp: Enabled: true -RSpec/ReceiveMessages: +Style/ConcatArrayLiterals: Enabled: true -RSpec/RedundantAround: +Style/DataInheritance: Enabled: true -RSpec/RedundantPredicateMatcher: +Style/DigChain: Enabled: true -RSpec/RemoveConst: +Style/DirEmpty: Enabled: true -RSpec/SkipBlockInsideExample: +Style/Documentation: Enabled: true -RSpec/SortMetadata: +Style/DocumentDynamicEvalDefinition: Enabled: true -RSpec/SpecFilePathFormat: +Style/DoubleNegation: Enabled: true -RSpec/SpecFilePathSuffix: +Style/EmptyClassDefinition: Enabled: true -RSpec/SubjectDeclaration: +Style/EmptyHeredoc: Enabled: true -RSpec/VerifiedDoubleReference: +Style/EmptyStringInsideInterpolation: Enabled: true -RSpecRails/AvoidSetupHook: +Style/Encoding: Enabled: true -RSpecRails/HaveHttpStatus: +Style/EndlessMethod: Enabled: true -RSpecRails/InferredSpecType: +Style/EnvHome: Enabled: true -RSpecRails/MinitestAssertions: +Style/ExactRegexpMatch: Enabled: true -RSpecRails/NegationBeValid: +Style/FetchEnvVar: Enabled: true -RSpecRails/TravelAround: +Style/FileEmpty: Enabled: true -Style/SingleLineDoEndBlock: +Style/FileNull: Enabled: true -Gemspec/AddRuntimeDependency: +Style/FileRead: + Enabled: true +Style/FileTouch: + Enabled: true +Style/FileWrite: + Enabled: true +Style/FrozenStringLiteralComment: + Enabled: true +Style/HashConversion: + Enabled: true +Style/HashExcept: + Enabled: true +Style/HashFetchChain: + Enabled: true +Style/HashSlice: + Enabled: true +Style/IfWithBooleanLiteralBranches: + Enabled: true +Style/InPatternThen: + Enabled: true +Style/ItAssignment: + Enabled: true +Style/ItBlockParameter: + Enabled: true +Style/KeywordArgumentsMerging: + Enabled: true +Style/MagicCommentFormat: + Enabled: true +Style/MapCompactWithConditionalBlock: Enabled: true Style/MapIntoArray: Enabled: true +Style/MapToHash: + Enabled: true +Style/MapToSet: + Enabled: true +Style/MinMaxComparison: + Enabled: true +Style/ModuleMemberExistenceCheck: + Enabled: true +Style/MultilineBlockChain: + Enabled: true +Style/MultilineInPatternThen: + Enabled: true +Style/NegatedIfElseCondition: + Enabled: true +Style/NegativeArrayIndex: + Enabled: true +Style/NestedFileDirname: + Enabled: true +Style/NilLambda: + Enabled: true +Style/NumberedParameters: + Enabled: true +Style/NumberedParametersLimit: + Enabled: true +Style/NumericPredicate: + Enabled: true +Style/ObjectThen: + Enabled: true +Style/OpenStructUse: + Enabled: true +Style/OperatorMethodCall: + Enabled: true +Style/OptionalBooleanParameter: + Enabled: true +Style/QuotedSymbols: + Enabled: true +Style/RedundantArgument: + Enabled: true +Style/RedundantArrayConstructor: + Enabled: true +Style/RedundantArrayFlatten: + Enabled: true +Style/RedundantConstantBase: + Enabled: true +Style/RedundantCurrentDirectoryInPath: + Enabled: true +Style/RedundantDoubleSplatHashBraces: + Enabled: true +Style/RedundantEach: + Enabled: true +Style/RedundantFilterChain: + Enabled: true +Style/RedundantFormat: + Enabled: true +Style/RedundantHeredocDelimiterQuotes: + Enabled: true +Style/RedundantInitialize: + Enabled: true +Style/RedundantInterpolationUnfreeze: + Enabled: true +Style/RedundantLineContinuation: + Enabled: true +Style/RedundantRegexpArgument: + Enabled: true +Style/RedundantRegexpConstructor: + Enabled: true +Style/RedundantSelfAssignmentBranch: + Enabled: true +Style/RedundantStringEscape: + Enabled: true +Style/ReturnNilInPredicateMethodDefinition: + Enabled: true +Style/ReverseFind: + Enabled: true +Style/SafeNavigation: + Enabled: true +Style/SafeNavigationChainLength: + Enabled: true +Style/SelectByRegexp: + Enabled: true Style/SendWithLiteralMethodName: Enabled: true +Style/SingleLineDoEndBlock: + Enabled: true +Style/StringChars: + Enabled: true +Style/StringConcatenation: + Enabled: true +Style/StructInheritance: + Enabled: true Style/SuperArguments: Enabled: true -Rails/WhereRange: +Style/SuperWithArgsParentheses: Enabled: true -Lint/UselessNumericOperation: +Style/SwapValues: Enabled: true -Style/RedundantInterpolationUnfreeze: +Style/TernaryParentheses: Enabled: true -Rails/EnumSyntax: +Style/YAMLFileRead: Enabled: true -### Broken Cops that break code + +#### DISABLED SECTION Lint/ShadowedException: # Breaks "bundle exec rake rubocop" if enabled Enabled: false -Sequel/SaveChanges: # Breaks Code +Rails/CreateTableWithTimestamps: # Only works with ActiveRecord but we're using Sequel + Enabled: false +Rails/DangerousColumnNames: # Disabled, in comparison to active_record we need to add the id column manually in sequel Enabled: false Rails/DynamicFindBy: # Breaks Code Enabled: false Rails/FindEach: # Breaks Code Enabled: false +Rails/I18nLocaleTexts: # We don't use locale texts + Enabled: false Rails/RedundantActiveRecordAllMethod: # As we use Sequel this breaks code as it matches Sequel functions Enabled: false -Rails/CreateTableWithTimestamps: # Only works with ActiveRecord but we're using Sequel +Sequel/SaveChanges: # Breaks Code Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d8b4ab7a415..76df5ebfdb2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 2026-02-04 13:48:02 UTC using RuboCop version 1.84.1. # 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 @@ -14,26 +14,26 @@ Lint/AmbiguousRange: - 'lib/cloud_controller/resource_match.rb' - 'spec/unit/messages/validators/metadata_validator_spec.rb' -# Offense count: 77 +# Offense count: 84 # Configuration parameters: AllowedMethods. # AllowedMethods: enums Lint/ConstantDefinitionInBlock: Enabled: false -# Offense count: 83 +# Offense count: 85 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: Enabled: false # Offense count: 5 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect, AllowComments. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowComments. Lint/EmptyConditionalBody: Exclude: - 'lib/cloud_controller/diego/failure_reason_sanitizer.rb' - 'spec/support/shared_examples/jobs/delayed_job.rb' -# Offense count: 57 +# Offense count: 58 # Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Enabled: false @@ -66,22 +66,37 @@ Lint/SuppressedException: - 'spec/unit/lib/services/service_brokers/service_broker_registration_spec.rb' - 'spec/unit/models/services/service_broker_spec.rb' -# Offense count: 28 +# Offense count: 27 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. +# NotImplementedExceptions: NotImplementedError Lint/UnusedMethodArgument: Exclude: - 'app/fetchers/feature_flag_list_fetcher.rb' - 'app/presenters/v3/app_manifest_presenters/route_properties_presenter.rb' - - 'lib/cloud_controller/blobstore/client_provider.rb' - 'lib/services/service_brokers/null_client.rb' - 'lib/services/service_brokers/user_provided/client.rb' - 'lib/services/service_brokers/v2/response_parser.rb' - 'spec/support/fakes/fake_service_broker_v2_client.rb' +# Offense count: 15 +Lint/UselessConstantScoping: + Exclude: + - 'app/controllers/runtime/stagings_controller.rb' + - 'app/controllers/v3/service_credential_bindings_controller.rb' + - 'app/controllers/v3/service_instances_controller.rb' + - 'app/controllers/v3/service_route_bindings_controller.rb' + - 'app/mappers/order_by_mapper.rb' + - 'app/messages/resource_match_create_message.rb' + - 'app/messages/route_update_destinations_message.rb' + - 'app/models/runtime/role.rb' + - 'lib/cloud_controller/db_connection/options_factory.rb' + - 'lib/cloud_controller/db_migrator.rb' + - 'lib/cloud_controller/deployment_updater/updater.rb' + - 'lib/cloud_controller/security/security_context_configurer.rb' + # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. Lint/UselessMethodDefinition: Exclude: - 'app/messages/route_destination_update_message.rb' @@ -89,22 +104,22 @@ Lint/UselessMethodDefinition: - 'app/presenters/v3/process_presenter.rb' - 'spec/support/fake_front_controller.rb' -# Offense count: 791 +# Offense count: 834 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 99 -# Offense count: 114 +# Offense count: 122 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 446 + Max: 406 -# Offense count: 62 +# Offense count: 65 # Configuration parameters: CountKeywordArgs, MaxOptionalParameters. Metrics/ParameterLists: Max: 9 -# Offense count: 162 +# Offense count: 182 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 30 @@ -123,38 +138,45 @@ Naming/HeredocDelimiterNaming: - 'spec/unit/jobs/deserialization_spec.rb' - 'spec/unit/lib/app_packager_spec.rb' -# Offense count: 84 -# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. -# NamePrefix: is_, has_, have_ -# ForbiddenPrefixes: is_, has_, have_ +# Offense count: 69 +# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates. +# AllowedMethods: call +# WaywardPredicates: infinite?, nonzero? +Naming/PredicateMethod: + Enabled: false + +# Offense count: 90 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs. +# NamePrefix: is_, has_, have_, does_ +# ForbiddenPrefixes: is_, has_, have_, does_ # AllowedMethods: is_a? # MethodDefinitionMacros: define_method, define_singleton_method Naming/PredicatePrefix: Enabled: false -# Offense count: 862 +# Offense count: 894 # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer -# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 +# AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 Naming/VariableNumber: Enabled: false -# Offense count: 409 +# Offense count: 447 RSpec/AnyInstance: Enabled: false -# Offense count: 164 +# Offense count: 181 RSpec/Be: Enabled: false -# Offense count: 6 +# Offense count: 8 RSpec/BeforeAfterAll: Exclude: - 'spec/integration/app_log_emitter_spec.rb' - 'spec/integration/cors_spec.rb' + - 'spec/isolated_specs/inline_runner_spec.rb' - 'spec/unit/lib/vcap/rest_api/event_query_spec.rb' - 'spec/unit/lib/vcap/rest_api/query_spec.rb' - - 'spec/isolated_specs/inline_runner_spec.rb' # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). @@ -163,31 +185,30 @@ RSpec/ChangeByZero: Exclude: - 'spec/unit/actions/update_route_destinations_spec.rb' -# Offense count: 3478 +# Offense count: 3651 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Enabled: false -# Offense count: 99 +# Offense count: 132 # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: Enabled: false -# Offense count: 4434 +# Offense count: 4850 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Enabled: false -# Offense count: 49 +# Offense count: 48 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. RSpec/EmptyExampleGroup: Enabled: false -# Offense count: 4303 +# Offense count: 4493 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 158 @@ -199,7 +220,7 @@ 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: 126 RSpec/ExpectInHook: Enabled: false @@ -207,27 +228,37 @@ RSpec/ExpectInHook: RSpec/ExpectInLet: Enabled: false -# Offense count: 1501 +# Offense count: 207 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/IncludeExamples: + Enabled: false + +# Offense count: 1508 # Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. RSpec/IndexedLet: Enabled: false -# Offense count: 718 +# Offense count: 723 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Enabled: false # Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). RSpec/IteratedExpectation: Exclude: - '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: 74 RSpec/LeakyConstantDeclaration: Enabled: false -# Offense count: 943 +# Offense count: 74 +RSpec/LeakyLocalVariable: + Enabled: false + +# Offense count: 926 RSpec/LetSetup: Enabled: false @@ -239,7 +270,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: 812 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -251,27 +282,27 @@ 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: 8616 RSpec/MultipleExpectations: Max: 48 -# Offense count: 8945 +# Offense count: 9453 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: Max: 36 -# Offense count: 2557 +# Offense count: 2727 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: Enabled: false -# Offense count: 1602 +# Offense count: 1738 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 8 -# Offense count: 89 +# Offense count: 93 # Configuration parameters: AllowedPatterns. # AllowedPatterns: ^expect_, ^assert_ RSpec/NoExpectationExample: @@ -334,11 +365,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' @@ -360,19 +390,18 @@ RSpec/ReturnFromStub: Exclude: - 'spec/unit/lib/cloud_controller/errands/rotate_database_key_spec.rb' -# Offense count: 206 +# Offense count: 235 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect. RSpec/ScatteredLet: Enabled: false -# Offense count: 35 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. -# Include: **/*_spec.rb +# Offense count: 38 +# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector. +# SupportedInflectors: default, active_support RSpec/SpecFilePathFormat: Enabled: false -# Offense count: 203 +# Offense count: 206 RSpec/StubbedMock: Enabled: false @@ -410,20 +439,19 @@ RSpec/VariableName: - 'spec/request/revisions_spec.rb' - 'spec/request/spaces_spec.rb' -# Offense count: 536 +# Offense count: 492 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Enabled: false -# Offense count: 7 +# Offense count: 4 RSpec/VoidExpect: Exclude: - 'spec/unit/controllers/runtime/organizations_controller_spec.rb' - 'spec/unit/controllers/runtime/spaces_controller_spec.rb' - '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: 1641 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ResponseMethods. # ResponseMethods: response, last_response @@ -442,31 +470,19 @@ Rails/ActiveRecordAliases: - 'spec/unit/models/services/service_instance_operation_spec.rb' # Offense count: 2 -# Configuration parameters: Include. -# Include: db/**/*.rb Rails/ThreeStateBooleanColumn: Exclude: - 'db/migrations/20141022211551_add_updateable_column_to_services.rb' - 'db/migrations/20151217235335_remove_unused_package_cols.rb' -# Offense count: 260 +# Offense count: 285 # 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: Exclude: - 'app/controllers/v3/security_groups_controller.rb' @@ -495,22 +511,27 @@ Style/CaseLikeIf: - 'lib/vcap/host_system.rb' - 'spec/support/shared_examples/jobs/delayed_job.rb' -# Offense count: 2014 +# Offense count: 2006 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. +# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules. # SupportedStyles: nested, compact +# SupportedStylesForClasses: ~, nested, compact +# SupportedStylesForModules: ~, nested, compact Style/ClassAndModuleChildren: Enabled: false -# Offense count: 3 +# Offense count: 12 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedReceivers. -# AllowedReceivers: params -Style/CollectionCompact: +Style/CollectionQuerying: Exclude: - - 'app/presenters/v3/app_presenter.rb' - - 'app/presenters/v3/package_presenter.rb' - - 'lib/vcap/json_message.rb' + - 'app/access/organization_access.rb' + - 'db/migrations/20161005205815_fix_droplets_process_types_json.rb' + - 'db/migrations/20231205143526_remove_deployments_with_degenerate.rb' + - 'lib/cloud_controller/diego/docker/staging_action_builder.rb' + - 'lib/cloud_controller/errands/rotate_database_key.rb' + - 'spec/support/background_job_helpers.rb' + - 'spec/unit/controllers/runtime/app_summaries_controller_spec.rb' + - 'spec/unit/repositories/app_usage_event_repository_spec.rb' # Offense count: 6 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -522,7 +543,7 @@ Style/CombinableLoops: - 'spec/linters/migration/add_constraint_name.rb' - 'spec/unit/models/runtime/organization_spec.rb' -# Offense count: 1488 +# Offense count: 1487 # Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false @@ -539,7 +560,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: 3395 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -554,12 +575,24 @@ Style/HashConversion: - 'lib/cloud_controller/controller_factory.rb' - 'spec/support/matchers/sequel_validations.rb' -# Offense count: 5 +# Offense count: 8 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/HashSlice: + Exclude: + - 'app/controllers/services/service_instances_controller.rb' + - 'app/controllers/services/service_plans_controller.rb' + - 'app/presenters/system_environment/service_binding_presenter.rb' + - 'lib/cloud_controller/blobstore/fog/fog_blob.rb' + - 'lib/cloud_controller/blobstore/storage_cli/storage_cli_blob.rb' + - 'lib/cloud_controller/blobstore/webdav/dav_blob.rb' + - 'lib/cloud_controller/telemetry_logger.rb' + - 'spec/unit/lib/cloud_controller/errands/rotate_database_key_spec.rb' + +# Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). Style/MapIntoArray: Exclude: - 'app/actions/space_delete.rb' - - 'lib/cloud_controller/install_buildpacks.rb' - 'spec/unit/controllers/v3/isolation_segments_controller_spec.rb' - 'spec/unit/presenters/v3/relationship_presenter_spec.rb' - 'spec/unit/presenters/v3/to_many_relationship_presenter_spec.rb' @@ -572,23 +605,22 @@ Style/MapToHash: - 'app/models/runtime/app_model.rb' - 'lib/cloud_controller/diego/reporters/instances_stats_reporter.rb' -# Offense count: 76 +# Offense count: 82 Style/MultilineBlockChain: Enabled: false -# Offense count: 53 +# Offense count: 63 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: Enabled: false -# Offense count: 7 +# Offense count: 6 Style/OpenStructUse: Exclude: - 'app/jobs/v2/services/delete_orphaned_binding.rb' - 'app/messages/package_create_message.rb' - - 'spec/unit/lib/cloud_controller/runners/thin_runner_spec.rb' - 'spec/unit/lib/cloud_controller/seeds_spec.rb' # Offense count: 14 @@ -611,7 +643,7 @@ Style/OptionalBooleanParameter: # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect, AllowComments. +# Configuration parameters: AllowComments. Style/RedundantInitialize: Exclude: - 'app/messages/route_destination_update_message.rb' @@ -629,7 +661,7 @@ Style/ReturnNilInPredicateMethodDefinition: - 'app/messages/space_delete_unmapped_routes_message.rb' - 'spec/support/legacy_api_dsl.rb' -# Offense count: 114 +# Offense count: 117 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! @@ -652,7 +684,7 @@ Style/SendWithLiteralMethodName: - 'app/jobs/runtime/orphaned_blobs_cleanup.rb' - 'app/jobs/v3/buildpack_cache_delete.rb' -# Offense count: 91 +# Offense count: 94 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: diff --git a/app/actions/app_update.rb b/app/actions/app_update.rb index a5ac3ead884..1b6a1d9a9b0 100644 --- a/app/actions/app_update.rb +++ b/app/actions/app_update.rb @@ -95,7 +95,7 @@ def validate_stack_state(app, message, lifecycle) stack = Stack.find(name: message.buildpack_data.stack) return [] unless stack - if app.builds_dataset.count.zero? + if app.builds_dataset.empty? StackStateValidator.validate_for_new_app!(stack) else StackStateValidator.validate_for_restaging!(stack) diff --git a/app/actions/build_create.rb b/app/actions/build_create.rb index b2765cc18b3..32b0014d084 100644 --- a/app/actions/build_create.rb +++ b/app/actions/build_create.rb @@ -202,7 +202,7 @@ def validate_stack_state!(lifecycle, app) end def first_build_for_app?(app) - app.builds_dataset.count.zero? + app.builds_dataset.empty? end end end diff --git a/app/actions/v2/app_update.rb b/app/actions/v2/app_update.rb index bbfa7972cc2..853be26cfc3 100644 --- a/app/actions/v2/app_update.rb +++ b/app/actions/v2/app_update.rb @@ -193,7 +193,7 @@ def validate_stack_state(app, request_attrs) stack = Stack.find(guid: request_attrs['stack_guid']) return unless stack - stack_warnings = if app.builds_dataset.count.zero? + stack_warnings = if app.builds_dataset.empty? StackStateValidator.validate_for_new_app!(stack) else StackStateValidator.validate_for_restaging!(stack) diff --git a/app/jobs/runtime/failed_jobs_cleanup.rb b/app/jobs/runtime/failed_jobs_cleanup.rb index 6812677c83c..bb5b1e44868 100644 --- a/app/jobs/runtime/failed_jobs_cleanup.rb +++ b/app/jobs/runtime/failed_jobs_cleanup.rb @@ -26,7 +26,7 @@ def perform orphaned_delayed_jobs = Delayed::Job. where(Sequel.lit("run_at < CURRENT_TIMESTAMP - INTERVAL '?' DAY", force_delete_after)) - unless orphaned_delayed_jobs.count.zero? + unless orphaned_delayed_jobs.empty? logger.info("Deleting #{orphaned_delayed_jobs.count} orphaned Delayed Jobs older than #{force_delete_after} days") orphaned_delayed_jobs.delete diff --git a/db/migrations/20170724170303_grow_service_instances_syslog_drain_url.rb b/db/migrations/20170724170303_grow_service_instances_syslog_drain_url.rb index 2a34642495d..d3c22af05a9 100644 --- a/db/migrations/20170724170303_grow_service_instances_syslog_drain_url.rb +++ b/db/migrations/20170724170303_grow_service_instances_syslog_drain_url.rb @@ -1,9 +1,7 @@ Sequel.migration do up do alter_table :service_instances do - # rubocop:disable Migration/IncludeStringSize set_column_type :syslog_drain_url, String, text: true - # rubocop:enable Migration/IncludeStringSize end end end diff --git a/db/migrations/20170724173748_grow_service_bindings_syslog_drain_url.rb b/db/migrations/20170724173748_grow_service_bindings_syslog_drain_url.rb index e7ada860307..606c09608f0 100644 --- a/db/migrations/20170724173748_grow_service_bindings_syslog_drain_url.rb +++ b/db/migrations/20170724173748_grow_service_bindings_syslog_drain_url.rb @@ -1,9 +1,7 @@ Sequel.migration do up do alter_table :service_bindings do - # rubocop:disable Migration/IncludeStringSize set_column_type :syslog_drain_url, String, text: true - # rubocop:enable Migration/IncludeStringSize end end end diff --git a/db/migrations/20180710115626_change_broker_catalog_descriptions_to_type_text.rb b/db/migrations/20180710115626_change_broker_catalog_descriptions_to_type_text.rb index ac46e4b1871..d34a5d9fe6d 100644 --- a/db/migrations/20180710115626_change_broker_catalog_descriptions_to_type_text.rb +++ b/db/migrations/20180710115626_change_broker_catalog_descriptions_to_type_text.rb @@ -6,15 +6,11 @@ # older brokers that may have long descriptions. Here we are disabling # rubocop from checking the string size. alter_table :services do - # rubocop:disable Migration/IncludeStringSize set_column_type :description, String, text: true - # rubocop:enable Migration/IncludeStringSize end alter_table :service_plans do - # rubocop:disable Migration/IncludeStringSize set_column_type :description, String, text: true - # rubocop:enable Migration/IncludeStringSize end end end diff --git a/db/migrations/20180927105539_add_broker_name_and_guid_to_service_usage_event.rb b/db/migrations/20180927105539_add_broker_name_and_guid_to_service_usage_event.rb index 93f23372af3..3d08d605a64 100644 --- a/db/migrations/20180927105539_add_broker_name_and_guid_to_service_usage_event.rb +++ b/db/migrations/20180927105539_add_broker_name_and_guid_to_service_usage_event.rb @@ -5,9 +5,7 @@ # field type here. # For the guid we have control, so we explicitly set a limit. - # rubocop:disable Migration/IncludeStringSize add_column :service_usage_events, :service_broker_name, String, null: true - # rubocop:enable Migration/IncludeStringSize add_column :service_usage_events, :service_broker_guid, String, null: true, size: 255 end end diff --git a/db/migrations/20190302003850_add_revision_description_column.rb b/db/migrations/20190302003850_add_revision_description_column.rb index 3917c2b30bc..d3229b3a476 100644 --- a/db/migrations/20190302003850_add_revision_description_column.rb +++ b/db/migrations/20190302003850_add_revision_description_column.rb @@ -1,9 +1,7 @@ Sequel.migration do change do alter_table(:revisions) do - # rubocop:disable Migration/IncludeStringSize add_column :description, String, text: true, default: 'N/A', null: false - # rubocop:enable Migration/IncludeStringSize end end end diff --git a/db/migrations/20190930225152_add_sidecars_to_droplets.rb b/db/migrations/20190930225152_add_sidecars_to_droplets.rb index 536036f1d33..1823231fdf1 100644 --- a/db/migrations/20190930225152_add_sidecars_to_droplets.rb +++ b/db/migrations/20190930225152_add_sidecars_to_droplets.rb @@ -1,9 +1,7 @@ Sequel.migration do change do alter_table :droplets do - # rubocop:disable Migration/IncludeStringSize add_column :sidecars, String, text: true, default: nil - # rubocop:enable Migration/IncludeStringSize end end end diff --git a/lib/cloud_controller/seeds.rb b/lib/cloud_controller/seeds.rb index 9b6b3b3f0d3..eb063baba80 100644 --- a/lib/cloud_controller/seeds.rb +++ b/lib/cloud_controller/seeds.rb @@ -124,7 +124,7 @@ def find_routing_guid(domain) end def create_seed_security_groups(config) - return unless config.get(:security_group_definitions) && SecurityGroup.count == 0 + return unless config.get(:security_group_definitions) && SecurityGroup.empty? config.get(:security_group_definitions).each do |security_group| seed_security_group = security_group.dup diff --git a/lib/locket/lock_runner.rb b/lib/locket/lock_runner.rb index 769598415f0..4f2fc4aebe4 100644 --- a/lib/locket/lock_runner.rb +++ b/lib/locket/lock_runner.rb @@ -7,9 +7,9 @@ class Error < StandardError end def initialize(key:, owner:, host:, port:, client_ca_path:, client_cert_path:, client_key_path:) - client_ca = File.open(client_ca_path).read - client_key = File.open(client_key_path).read - client_cert = File.open(client_cert_path).read + client_ca = File.read(client_ca_path) + client_key = File.read(client_key_path) + client_cert = File.read(client_cert_path) @service = Models::Locket::Stub.new( "#{host}:#{port}", @@ -29,15 +29,11 @@ def start loop do begin service.lock(build_lock_request) - if !@lock_acquired then - logger.info("Acquired lock '#{key}' for owner '#{owner}'") - end + logger.info("Acquired lock '#{key}' for owner '#{owner}'") unless @lock_acquired @lock_acquired = true failed = false rescue GRPC::BadStatus => e - if !failed then - logger.info("Failed to acquire lock '#{key}' for owner '#{owner}': #{e.message}") - end + logger.info("Failed to acquire lock '#{key}' for owner '#{owner}': #{e.message}") unless failed failed = true @lock_acquired = false end @@ -65,9 +61,9 @@ def build_lock_request resource: { key: key, owner: owner, - type_code: Models::TypeCode::LOCK, + type_code: Models::TypeCode::LOCK }, - ttl_in_seconds: 15, + ttl_in_seconds: 15 } ) end diff --git a/lib/sequel_plugins/vcap_relations.rb b/lib/sequel_plugins/vcap_relations.rb index 2bf04bf4543..8a88acef4a2 100644 --- a/lib/sequel_plugins/vcap_relations.rb +++ b/lib/sequel_plugins/vcap_relations.rb @@ -6,7 +6,7 @@ def self.apply(model) module InstanceMethods def has_one_to_many?(association) - association_type(association) == :one_to_many && send(association).count > 0 + association_type(association) == :one_to_many && send(association).any? end def has_one_to_one?(association)