-
-
Notifications
You must be signed in to change notification settings - Fork 281
Description
Is your feature request related to a problem? Please describe.
The IndexedLet
cop is complaining about let-vars that are named specifically to match keyword args (in particular, keyword args in the UUT). Adhering to this cop makes the let-vars inconsistent with the keyword args, and worse, makes it so kwarg shorthand can't be used.
Describe the solution you'd like
I would like the IndexedLet
cop to automatically allow (without any configuration) any offending let-vars used as kwarg values. (ie, any let-vars whose name matches a kwarg and would be using kwarg shorthand)
Describe alternatives you've considered
One option is to rename the kwarg to match the IndexedLet
-compliant names. However, in many (most?) cases, this would mean that a rubocop-rspec rule is forcing changes to application code, which is a tenuous line to cross.
Another option would be to explicitly list the allowed values. However, whether a let-var should be flagged or allowed is context dependent. In one case that maps to kwargs and uses shorthand, they should be allowed; but in another case where they are positional args or any other regular variable reference they should still be flagged. So listing them as exceptions is overly broad.
Additional context
Example that presently violates IndexedLet
that should be allowed:
let(:line1) { "333 Green St" }
let(:line2) { "Unit 1000" }
let(:address) { Address.new(line1:, line2:, city:, state:, zip:) }