You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to suggest a new cop that detects usage of !foo.include?(bar), and can auto-fix it to: foo.exclude?(bar).
Does that seem like a good idea to anyone else? I really like the exclude? method because it's easier to see the intention. (Similar to unless vs if.)
The text was updated successfully, but these errors were encountered:
ndbroadbent
changed the title
Suggestion for a new cop: Replace !include? with exclude?
Suggestion for a new cop: Replace !foo.include?(bar) with foo.exclude?(bar)
Nov 15, 2018
I would be happy to submit a PR, but would like to ask for some help because I'm not familiar with the codebase. I think there's already a similar cop that converts if !foo into unless foo. Do you think it would be easy to copy that one and use it as an example? Or are there are some other cops that I should look at for inspiration?
EDIT: Oh I just found a much better example - !blank? vs. present?. I'll copy that one for include? vs. exclude?.
I recently remembered that ActiveSupport adds an
exclude?
method to Array and String. Before that, I was just using!foo.include?
.I would like to suggest a new cop that detects usage of
!foo.include?(bar)
, and can auto-fix it to:foo.exclude?(bar)
.Does that seem like a good idea to anyone else? I really like the
exclude?
method because it's easier to see the intention. (Similar tounless
vsif
.)The text was updated successfully, but these errors were encountered: