Improve rubocop setup for vendored gems
The following discussions from !124875 (merged) should be addressed:
-
@splattael started a discussion: Suggestion Should disable this
👮 rule ingems/config/rubocop.yml
for all gems? It's only useful for a handful of SaaS related feature specs. -
@splattael started a discussion: Observation (non-blocking) Just noting that this enables all cops even if they don't make sense in context of a gem. So, we need to disable them one by one if undesired/unfixable offenses come up.
Suggestion (non-blocking) Skipping this line would let us remove a bunch of disables below but would require to backport some cops to
gitlab-styles
. See gitlab-org/ruby/gems/gitlab-styles#43 -
@splattael started a discussion: Suggestion (non-blocking) Should we disable this cop similar to https://gitlab.com/gitlab-org/gitlab/-/blob/50e84d0f3d6c3db2a6b85ef5a9902d881295e235/.rubocop.yml#L493-496.
Ideally, one would fix this cop after all
😅 -
@splattael started a discussion: "grace period" is supposed to be used in TODOs only.
Suggestion (non-blocking) Perhaps we could create
.rubocop_todo.yml
instead?🤔 BTW, regenerating TODOs behaves weirdly if
--config .rubocop.yml
is passed because it warns about enabling new cops by default on the second run🤷 Click to expand
$ be rubocop --config .rubocop.yml --regenerate-todo --exclude-limit 10000 Phase 1 of 2: run Layout/LineLength cop Inspecting 12 files ............ 12 files inspected, no offenses detected Created .rubocop_todo.yml. Phase 2 of 2: run all cops Inspecting 12 files ...C.....C.. 12 files inspected, 2 offenses detected, 1 offense autocorrectable The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file. Please also note that you can opt-in to new cops by default by adding this to your config: AllCops: NewCops: enable Gemspec/DeprecatedAttributeAssignment: # new in 1.30 Enabled: true Gemspec/RequireMFA: # new in 1.23 Enabled: true Lint/DuplicateMatchPattern: # new in 1.50 Enabled: true Lint/UselessRescue: # new in 1.43 Enabled: true Metrics/CollectionLiteralLength: # new in 1.47 Enabled: true Naming/BlockForwarding: # new in 1.24 Enabled: true Style/ArgumentsForwarding: # new in 1.1 Enabled: true Style/ArrayIntersect: # new in 1.40 Enabled: true Style/CollectionCompact: # new in 1.2 Enabled: true Style/ComparableClamp: # new in 1.44 Enabled: true Style/ConcatArrayLiterals: # new in 1.41 Enabled: true Style/DataInheritance: # new in 1.49 Enabled: true Style/DirEmpty: # new in 1.48 Enabled: true Style/DocumentDynamicEvalDefinition: # new in 1.1 Enabled: true Style/EmptyHeredoc: # new in 1.32 Enabled: true Style/EndlessMethod: # new in 1.8 Enabled: true Style/EnvHome: # new in 1.29 Enabled: true Style/FetchEnvVar: # new in 1.28 Enabled: true Style/FileEmpty: # new in 1.48 Enabled: true Style/FileRead: # new in 1.24 Enabled: true Style/FileWrite: # new in 1.24 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/MagicCommentFormat: # new in 1.35 Enabled: true Style/MapCompactWithConditionalBlock: # new in 1.30 Enabled: true Style/MapToHash: # new in 1.24 Enabled: true Style/MapToSet: # new in 1.42 Enabled: true Style/MinMaxComparison: # new in 1.42 Enabled: true Style/MultilineInPatternThen: # new in 1.16 Enabled: true Style/NegatedIfElseCondition: # new in 1.2 Enabled: true Style/NestedFileDirname: # new in 1.26 Enabled: true Style/NilLambda: # new in 1.3 Enabled: true Style/ObjectThen: # new in 1.28 Enabled: true Style/OperatorMethodCall: # new in 1.37 Enabled: true Style/QuotedSymbols: # new in 1.16 Enabled: true Style/RedundantArgument: # new in 1.4 Enabled: true Style/RedundantConstantBase: # new in 1.40 Enabled: true Style/RedundantDoubleSplatHashBraces: # new in 1.41 Enabled: true Style/RedundantEach: # new in 1.38 Enabled: true Style/RedundantHeredocDelimiterQuotes: # new in 1.45 Enabled: true Style/RedundantInitialize: # new in 1.27 Enabled: true Style/RedundantLineContinuation: # new in 1.49 Enabled: true Style/RedundantSelfAssignmentBranch: # new in 1.19 Enabled: true Style/RedundantStringEscape: # new in 1.37 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 Capybara/MatchStyle: # new in 2.17 Enabled: true Capybara/NegationMatcher: # new in 2.14 Enabled: true Capybara/SpecificActions: # new in 2.14 Enabled: true Capybara/SpecificMatcher: # new in 2.12 Enabled: true FactoryBot/AssociationStyle: # new in 2.23 Enabled: true FactoryBot/ConsistentParenthesesStyle: # new in 2.14 Enabled: true FactoryBot/FactoryAssociationWithStrategy: # new in 2.23 Enabled: true FactoryBot/FactoryNameStyle: # new in 2.16 Enabled: true FactoryBot/RedundantFactoryOption: # new in 2.23 Enabled: true FactoryBot/SyntaxMethods: # new in 2.7 Enabled: true RSpec/BeEmpty: # new in 2.20 Enabled: true RSpec/BeEq: # new in 2.9.0 Enabled: true RSpec/BeNil: # new in 2.9.0 Enabled: true RSpec/ChangeByZero: # new in 2.11 Enabled: true RSpec/ContainExactly: # new in 2.19 Enabled: true RSpec/DuplicatedMetadata: # new in 2.16 Enabled: true RSpec/ExcessiveDocstringSpacing: # new in 2.5 Enabled: true RSpec/IdenticalEqualityAssertion: # new in 2.4 Enabled: true RSpec/IndexedLet: # new in 2.20 Enabled: true RSpec/MatchArray: # new in 2.19 Enabled: true RSpec/NoExpectationExample: # new in 2.13 Enabled: true RSpec/PendingWithoutReason: # new in 2.16 Enabled: true RSpec/RedundantAround: # new in 2.19 Enabled: true RSpec/SkipBlockInsideExample: # new in 2.19 Enabled: true RSpec/SortMetadata: # new in 2.14 Enabled: true RSpec/SubjectDeclaration: # new in 2.5 Enabled: true RSpec/VerifiedDoubleReference: # new in 2.10.0 Enabled: true RSpec/Rails/AvoidSetupHook: # new in 2.4 Enabled: true RSpec/Rails/HaveHttpStatus: # new in 2.12 Enabled: true RSpec/Rails/InferredSpecType: # new in 2.14 Enabled: true RSpec/Rails/MinitestAssertions: # new in 2.17 Enabled: true RSpec/Rails/TravelAround: # new in 2.19 Enabled: true Rails/ActionControllerFlashBeforeRender: # new in 2.16 Enabled: true Rails/ActionControllerTestCase: # new in 2.14 Enabled: true Rails/ActionOrder: # new in 2.17 Enabled: true Rails/ActiveSupportOnLoad: # new in 2.16 Enabled: true Rails/AddColumnIndex: # new in 2.11 Enabled: true Rails/CompactBlank: # new in 2.13 Enabled: true Rails/DeprecatedActiveModelErrorsMethods: # new in 2.14 Enabled: true Rails/DotSeparatedKeys: # new in 2.15 Enabled: true Rails/DuplicateAssociation: # new in 2.14 Enabled: true Rails/DuplicateScope: # new in 2.14 Enabled: true Rails/DurationArithmetic: # new in 2.13 Enabled: true Rails/EagerEvaluationLogMessage: # new in 2.11 Enabled: true Rails/ExpandedDateRange: # new in 2.11 Enabled: true Rails/FreezeTime: # new in 2.16 Enabled: true Rails/I18nLazyLookup: # new in 2.14 Enabled: true Rails/I18nLocaleAssignment: # new in 2.11 Enabled: true Rails/I18nLocaleTexts: # new in 2.14 Enabled: true Rails/IgnoredColumnsAssignment: # new in 2.17 Enabled: true Rails/MigrationClassName: # new in 2.14 Enabled: true Rails/RedundantPresenceValidationOnBelongsTo: # new in 2.13 Enabled: true Rails/RedundantTravelBack: # new in 2.12 Enabled: true Rails/ResponseParsedBody: # new in 2.18 Enabled: true Rails/RootJoinChain: # new in 2.13 Enabled: true Rails/RootPathnameMethods: # new in 2.16 Enabled: true Rails/RootPublicPath: # new in 2.15 Enabled: true Rails/StripHeredoc: # new in 2.15 Enabled: true Rails/ThreeStateBooleanColumn: # new in 2.19 Enabled: true Rails/TimeZoneAssignment: # new in 2.10 Enabled: true Rails/ToFormattedS: # new in 2.15 Enabled: true Rails/ToSWithArgument: # new in 2.16 Enabled: true Rails/TopLevelHashWithIndifferentAccess: # new in 2.16 Enabled: true Rails/UnusedIgnoredColumns: # new in 2.11 Enabled: true Rails/WhereMissing: # new in 2.16 Enabled: true Rails/WhereNotWithMultipleConditions: # new in 2.17 Enabled: true For more information: https://docs.rubocop.org/rubocop/versioning.html The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file. Please also note that you can opt-in to new cops by default by adding this to your config: AllCops: NewCops: enable Gemspec/DeprecatedAttributeAssignment: # new in 1.30 Enabled: true Gemspec/RequireMFA: # new in 1.23 Enabled: true Lint/DuplicateMatchPattern: # new in 1.50 Enabled: true Lint/UselessRescue: # new in 1.43 Enabled: true Metrics/CollectionLiteralLength: # new in 1.47 Enabled: true Naming/BlockForwarding: # new in 1.24 Enabled: true Style/ArgumentsForwarding: # new in 1.1 Enabled: true Style/ArrayIntersect: # new in 1.40 Enabled: true Style/CollectionCompact: # new in 1.2 Enabled: true Style/ComparableClamp: # new in 1.44 Enabled: true Style/ConcatArrayLiterals: # new in 1.41 Enabled: true Style/DataInheritance: # new in 1.49 Enabled: true Style/DirEmpty: # new in 1.48 Enabled: true Style/DocumentDynamicEvalDefinition: # new in 1.1 Enabled: true Style/EmptyHeredoc: # new in 1.32 Enabled: true Style/EndlessMethod: # new in 1.8 Enabled: true Style/EnvHome: # new in 1.29 Enabled: true Style/FetchEnvVar: # new in 1.28 Enabled: true Style/FileEmpty: # new in 1.48 Enabled: true Style/FileRead: # new in 1.24 Enabled: true Style/FileWrite: # new in 1.24 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/MagicCommentFormat: # new in 1.35 Enabled: true Style/MapCompactWithConditionalBlock: # new in 1.30 Enabled: true Style/MapToHash: # new in 1.24 Enabled: true Style/MapToSet: # new in 1.42 Enabled: true Style/MinMaxComparison: # new in 1.42 Enabled: true Style/MultilineInPatternThen: # new in 1.16 Enabled: true Style/NegatedIfElseCondition: # new in 1.2 Enabled: true Style/NestedFileDirname: # new in 1.26 Enabled: true Style/NilLambda: # new in 1.3 Enabled: true Style/ObjectThen: # new in 1.28 Enabled: true Style/OperatorMethodCall: # new in 1.37 Enabled: true Style/QuotedSymbols: # new in 1.16 Enabled: true Style/RedundantArgument: # new in 1.4 Enabled: true Style/RedundantConstantBase: # new in 1.40 Enabled: true Style/RedundantDoubleSplatHashBraces: # new in 1.41 Enabled: true Style/RedundantEach: # new in 1.38 Enabled: true Style/RedundantHeredocDelimiterQuotes: # new in 1.45 Enabled: true Style/RedundantInitialize: # new in 1.27 Enabled: true Style/RedundantLineContinuation: # new in 1.49 Enabled: true Style/RedundantSelfAssignmentBranch: # new in 1.19 Enabled: true Style/RedundantStringEscape: # new in 1.37 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 Capybara/MatchStyle: # new in 2.17 Enabled: true Capybara/NegationMatcher: # new in 2.14 Enabled: true Capybara/SpecificActions: # new in 2.14 Enabled: true Capybara/SpecificMatcher: # new in 2.12 Enabled: true FactoryBot/AssociationStyle: # new in 2.23 Enabled: true FactoryBot/ConsistentParenthesesStyle: # new in 2.14 Enabled: true FactoryBot/FactoryAssociationWithStrategy: # new in 2.23 Enabled: true FactoryBot/FactoryNameStyle: # new in 2.16 Enabled: true FactoryBot/RedundantFactoryOption: # new in 2.23 Enabled: true FactoryBot/SyntaxMethods: # new in 2.7 Enabled: true RSpec/BeEmpty: # new in 2.20 Enabled: true RSpec/BeEq: # new in 2.9.0 Enabled: true RSpec/BeNil: # new in 2.9.0 Enabled: true RSpec/ChangeByZero: # new in 2.11 Enabled: true RSpec/ContainExactly: # new in 2.19 Enabled: true RSpec/DuplicatedMetadata: # new in 2.16 Enabled: true RSpec/ExcessiveDocstringSpacing: # new in 2.5 Enabled: true RSpec/IdenticalEqualityAssertion: # new in 2.4 Enabled: true RSpec/IndexedLet: # new in 2.20 Enabled: true RSpec/MatchArray: # new in 2.19 Enabled: true RSpec/NoExpectationExample: # new in 2.13 Enabled: true RSpec/PendingWithoutReason: # new in 2.16 Enabled: true RSpec/RedundantAround: # new in 2.19 Enabled: true RSpec/SkipBlockInsideExample: # new in 2.19 Enabled: true RSpec/SortMetadata: # new in 2.14 Enabled: true RSpec/SubjectDeclaration: # new in 2.5 Enabled: true RSpec/VerifiedDoubleReference: # new in 2.10.0 Enabled: true RSpec/Rails/AvoidSetupHook: # new in 2.4 Enabled: true RSpec/Rails/HaveHttpStatus: # new in 2.12 Enabled: true RSpec/Rails/InferredSpecType: # new in 2.14 Enabled: true RSpec/Rails/MinitestAssertions: # new in 2.17 Enabled: true RSpec/Rails/TravelAround: # new in 2.19 Enabled: true Rails/ActionControllerFlashBeforeRender: # new in 2.16 Enabled: true Rails/ActionControllerTestCase: # new in 2.14 Enabled: true Rails/ActionOrder: # new in 2.17 Enabled: true Rails/ActiveSupportOnLoad: # new in 2.16 Enabled: true Rails/AddColumnIndex: # new in 2.11 Enabled: true Rails/CompactBlank: # new in 2.13 Enabled: true Rails/DeprecatedActiveModelErrorsMethods: # new in 2.14 Enabled: true Rails/DotSeparatedKeys: # new in 2.15 Enabled: true Rails/DuplicateAssociation: # new in 2.14 Enabled: true Rails/DuplicateScope: # new in 2.14 Enabled: true Rails/DurationArithmetic: # new in 2.13 Enabled: true Rails/EagerEvaluationLogMessage: # new in 2.11 Enabled: true Rails/ExpandedDateRange: # new in 2.11 Enabled: true Rails/FreezeTime: # new in 2.16 Enabled: true Rails/I18nLazyLookup: # new in 2.14 Enabled: true Rails/I18nLocaleAssignment: # new in 2.11 Enabled: true Rails/I18nLocaleTexts: # new in 2.14 Enabled: true Rails/IgnoredColumnsAssignment: # new in 2.17 Enabled: true Rails/MigrationClassName: # new in 2.14 Enabled: true Rails/RedundantPresenceValidationOnBelongsTo: # new in 2.13 Enabled: true Rails/RedundantTravelBack: # new in 2.12 Enabled: true Rails/ResponseParsedBody: # new in 2.18 Enabled: true Rails/RootJoinChain: # new in 2.13 Enabled: true Rails/RootPathnameMethods: # new in 2.16 Enabled: true Rails/RootPublicPath: # new in 2.15 Enabled: true Rails/StripHeredoc: # new in 2.15 Enabled: true Rails/ThreeStateBooleanColumn: # new in 2.19 Enabled: true Rails/TimeZoneAssignment: # new in 2.10 Enabled: true Rails/ToFormattedS: # new in 2.15 Enabled: true Rails/ToSWithArgument: # new in 2.16 Enabled: true Rails/TopLevelHashWithIndifferentAccess: # new in 2.16 Enabled: true Rails/UnusedIgnoredColumns: # new in 2.11 Enabled: true Rails/WhereMissing: # new in 2.16 Enabled: true Rails/WhereNotWithMultipleConditions: # new in 2.17 Enabled: true For more information: https://docs.rubocop.org/rubocop/versioning.html Created .rubocop_todo.yml.
-
@splattael started a discussion: Suggestion (non-blocking) Could we use the
Include:
directive instead in.rubocop.yml
andgems/config/rubocop.yml
?🤔 -
@splattael started a discussion: Question (non-blocking) Instead of checking the location programmatically, could we disable cops related to usage data for gems?
🤔 -
@splattael started a discussion: We should be doing the opposite actually: gitlab-org/ruby/gems/gitlab-styles#51
Suggestion (non-blocking) Thoughts on making the
Include:
more generic instead in.rubocop.yml
andgems/config/rubocop.yml
?🤔 Rake/Require: Include: - '**/*.rake'
Also, we should upstream this
👮 finally💪