Closed corsonknowles closed 1 week ago
Can you please give an example?
Yes, here you go!
I don’t think we have to account for RSpec DSL in case/if. RSpec has rich metadata capabilities, and those should be used instead
Thanks @pirj -- It took my a moment to figure out what that means, I think it's that code like this should be refactored to pass params into the before block, etc and bring the case statements inside so that these errors are not generated by the autocorrect.
I'm convinced that the Rubocop rule here doesn't need to accomadate these cases, but I'm not convinced that it should remain marked as safe for autocorrection.
The examples here were perfectly validy Ruby/RSpec before, but are not after the autocorrect runs.
In fact, for the example of hoisting to a higher context, I'm not convinced that is good behavior at all.
But I'm confident neither case should be considered equivalent by design, as is the guideline for cops marked SafeForAutocorrect.
Cop Doc: https://www.rubydoc.info/gems/rubocop-rspec/1.10.0/RuboCop/Cop/RSpec/ScatteredSetup
RSpec/ScatteredSetup
is not safe for autocorrection because it will movebefore
logic out of case statements and into one giant and many empty case statements