Closed
Description
Hi,
New cop Performance/StringInclude
introduced by #117 is unsafe when use with --auto-correct
.
- It currently auto-corrects the usage of
match
and=~
. But the return values betweenmatch
or=~
andinclude?
are different. If the value is used, the behavior is altered. =~
doesn't raise an error in case ofnil =~ /foobar/
. Same, behavior is altered.
Two examples that broke in our codebase:
search_by_street_address = params[:types] =~ /street_address/
@agenda_requested_in_config ||= method.match(/agenda/)
I think it should only fix match?
and reserve match
and =~
in the case of --auto-correct-all
. I don't know if you can make that distinction?
If not, maybe move this cop as unsafe? What do you think?
Activity