Skip to content

Suggestion for a new cop: Replace !foo.include?(bar) with foo.exclude?(bar) #17

Closed
@ndbroadbent

Description

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 to unless vs if.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions