New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce numblock
verification for ALL the cops that check block
nodes
#10915
Enforce numblock
verification for ALL the cops that check block
nodes
#10915
Commits on Aug 12, 2022
-
Introduce InternalAffairs/NumblockHandler
The `InternalAffairs/NumblockHandler` ensures cops that handle `block` nodes will also handle `numblock` nodes or disable it explicitly. We have exceptions for this check like cops that check block parameters but for the majority of the cases we want `numblock` nodes to handled.
-
Disable InternalAffairs/NumbockHandler for block cops
While, technically, we can use gemspec definitions like: ``` Gem::Specification.new do _1.metadata['rubygems_mfa_required'] = 'true' end ```
-
-
-
Disable InternalAffairs/NumblockHandler for HashTransformMethod
This mixin (`HashTransformMethod`) holds implementation details for the cops Style/HashTransformKeys and Style/HashTransformValues. Their usage is based on named block arguments and destructuring, which is not how one would use numbered arguments. I'll delay (avoid) this implementation.
-
-
-
-
-
-
Fix Layout/LineLength with numblocks
While applying the cop to `numbock`s, I have found a bug with regular `block` nodes and singe-line do-end blocks without arguments. This got autocorrected to... ```ruby foo.select do 4444000039123123129993912312312999199291203123 end ``` ... that 👇 ```ruby foo.select d o 4444000039123123129993912312312999199291203123 end ``` This is not valid Ruby code, so I fixed that while at it.
-
-
-
-
-
-
-
-
-
-
Fix Metrics{AbcSize,CyclomaticComplexity} with numblocks
Both of them use `MethodComplexity` which now supports `define_method` with numblocks.
-
-
-
The autocorrect can and will generate broken code when using numbered arguments as `_1` is not a valid local variable name outside numblocks.
-
-
-
-
-
-
-
-
-
-
-
Fix Style/EachWithObject with numblocks
The autocorrection does not remove the return value in `each_with_object`, but the numbered arguments are swapped. Not the best autocorrection, but it is still correct as `each_with_object` ignores the return value of its block.
-