Enable another set of Lint/* cops
What does this MR do and why?
This commit enables the following cops:
Lint/IncompatibleIoSelectWithFiberScheduler
Lint/LambdaWithoutLiteralBlock
Lint/NonAtomicFileOperation
Lint/NoReturnInBeginEndBlocks
Lint/OrAssignmentToConstant
Lint/RedundantDirGlobSort
Lint/RefinementImportMethods
Lint/RequireRangeParentheses
Lint/RequireRelativeSelfPath
-
Lint/SymbolConversion
- Sticking with
EnforcedStyle: strict
to allow code like expires_in(max_age, public: allow_caching, 's-maxage': 1.minute)
- Sticking with
Lint/ToEnumArguments
Lint/TripleQuotes
Lint/UnexpectedBlockArity
Lint/UnmodifiedReduceAccumulator
-
Lint/UselessRuby2Keywords
- See https://github.com/rubocop/rubocop/pull/11459 for an upstream fix discovered during testing.
It also disables the following cops explicitly:
-
Lint/NumberedParameterAssignment
- Reason: Ruby >= 3.0 causes an error so no need to enable it.
Contributes to #40
Config diff
Via rubocop --show-cops
Click to expand
--- before 2023-01-16 11:33:40.282170788 +0100
+++ after 2023-01-16 13:41:41.906640631 +0100
@@ -1899,7 +1899,7 @@
# Supports --autocorrect
Lint/IncompatibleIoSelectWithFiberScheduler:
Description: Checks for `IO.select` that is incompatible with Fiber Scheduler.
- Enabled: pending
+ Enabled: true
SafeAutoCorrect: false
VersionAdded: '1.21'
VersionChanged: '1.24'
@@ -1933,7 +1933,7 @@
# Supports --autocorrect
Lint/LambdaWithoutLiteralBlock:
Description: Checks uses of lambda without a literal block.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.8'
Lint/LiteralAsCondition:
@@ -2004,14 +2004,14 @@
Lint/NoReturnInBeginEndBlocks:
Description: Do not `return` inside `begin..end` blocks in assignment contexts.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.2'
# Supports --autocorrect
Lint/NonAtomicFileOperation:
Description: Checks for non-atomic file operations.
StyleGuide: "#atomic-file-operations"
- Enabled: pending
+ Enabled: true
VersionAdded: '1.31'
SafeAutoCorrect: false
@@ -2073,13 +2073,13 @@
Lint/NumberedParameterAssignment:
Description: Checks for uses of numbered parameter assignment.
- Enabled: pending
+ Enabled: false
VersionAdded: '1.9'
# Supports --autocorrect
Lint/OrAssignmentToConstant:
Description: Checks unintended or-assignment to constant.
- Enabled: pending
+ Enabled: true
Safe: false
VersionAdded: '1.9'
@@ -2154,7 +2154,7 @@
# Supports --autocorrect
Lint/RedundantDirGlobSort:
Description: Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.8'
VersionChanged: '1.26'
SafeAutoCorrect: false
@@ -2210,7 +2210,7 @@
Lint/RefinementImportMethods:
Description: Use `Refinement#import_methods` when using `include` or `prepend` in
`refine` block.
- Enabled: pending
+ Enabled: true
SafeAutoCorrect: false
VersionAdded: '1.27'
@@ -2230,13 +2230,13 @@
Lint/RequireRangeParentheses:
Description: Checks that a range literal is enclosed in parentheses when the end of
the range is at a line break.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.32'
# Supports --autocorrect
Lint/RequireRelativeSelfPath:
Description: Checks for uses a file requiring itself with `require_relative`.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.22'
Lint/RescueException:
@@ -2345,7 +2345,7 @@
# Supports --autocorrect
Lint/SymbolConversion:
Description: Checks for unnecessary symbol conversions.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.9'
VersionChanged: '1.16'
EnforcedStyle: strict
@@ -2361,7 +2361,7 @@
Lint/ToEnumArguments:
Description: Ensures that `to_enum`/`enum_for`, called for the current method, has
correct arguments.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.1'
# Supports --autocorrect
@@ -2384,7 +2384,7 @@
# Supports --autocorrect
Lint/TripleQuotes:
Description: Checks for useless triple quote constructs.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.9'
Lint/UnderscorePrefixedVariableName:
@@ -2395,7 +2395,7 @@
Lint/UnexpectedBlockArity:
Description: Looks for blocks that have fewer arguments that the calling method expects.
- Enabled: pending
+ Enabled: true
Safe: false
VersionAdded: '1.5'
Methods:
@@ -2419,7 +2419,7 @@
Lint/UnmodifiedReduceAccumulator:
Description: Checks for `reduce` or `inject` blocks that do not update the accumulator
each iteration.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.1'
VersionChanged: '1.5'
@@ -2510,7 +2510,7 @@
Lint/UselessRuby2Keywords:
Description: Finds unnecessary uses of `ruby2_keywords`.
- Enabled: pending
+ Enabled: true
VersionAdded: '1.23'
# Supports --autocorrect
gitlab-org/gitlab
Impact on 1529 Lint/SymbolConversion
81 Lint/NonAtomicFileOperation
24 Lint/NoReturnInBeginEndBlocks
3 Lint/OrAssignmentToConstant
3 Lint/ToEnumArguments
2 Lint/TripleQuotes
2 Lint/UnexpectedBlockArity
1 Lint/IncompatibleIoSelectWithFiberScheduler
1 Lint/NumberedParameterAssignment
1 Lint/UnmodifiedReduceAccumulator
--
1647 Total in 235 files
Offense sample
Offenses:
app/controllers/projects/environments/sample_metrics_controller.rb:11:22: W: [Correctable] Lint/SymbolConversion: Unnecessary symbol conversion; use status: instead.
render json: { "status": "success", "data": { "resultType": "matrix", "result": result } }
^^^^^^^^
app/models/merge_request_diff.rb:856:5: W: Lint/NonAtomicFileOperation: Use atomic file operation method FileUtils.mkdir_p.
Dir.mkdir(external_diff_cache_dir) unless Dir.exist?(external_diff_cache_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/merge_request.rb:1755:7: W: Lint/NoReturnInBeginEndBlocks: Do not return in begin..end blocks in assignment contexts.
return commit_shas unless persisted?
^^^^^^^^^^^^^^^^^^
lib/gitlab/email/handler/base_handler.rb:9:35: W: [Correctable] Lint/OrAssignmentToConstant: Avoid using or-assignment with constants.
HANDLER_ACTION_BASE_REGEX ||= /(?<project_slug>.+)-(?<project_id>\d+)/.freeze
^^^
</details>
Edited by Peter Leitzen