Skip to content

Cop idea: Rails/Without #1436

Open
Open
@vlad-pisanov

Description

@vlad-pisanov

This cop would be a spiritual successor to Style/HashExcept, but it would leverage the convenient without method which works for both hashes and lists:

# bad
list.select { it != 42 }
list.reject { it == 42 }
hash.reject { it.in? [:foo, :bar] }
hash.keep_if { ![:foo, :bar].include?(it) }

# good
list.without(42)
hash.without(:foo, :bar)

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