Skip to content

Files

Latest commit

 

History

History
23 lines (16 loc) · 600 Bytes

Rails-DuplicateScope.md

File metadata and controls

23 lines (16 loc) · 600 Bytes

Pattern: Duplicate scope for same where clause.

Issue: -

Description

This rule checks for multiple scopes in a model that have the same where clause. This often means you copy/pasted a scope, updated the name, and forgot to change the condition.

Examples

# bad
scope :visible, -> { where(visible: true) }
scope :hidden, -> { where(visible: true) }

# good
scope :visible, -> { where(visible: true) }
scope :hidden, -> { where(visible: false) }

Further Reading