Skip to content

Files

Latest commit

 

History

History
29 lines (18 loc) · 622 Bytes

Style-RedundantSelfAssignmentBranch.md

File metadata and controls

29 lines (18 loc) · 622 Bytes

Pattern: Redundant self-assignment branch

Issue: -

Description

Checks for places where conditional branch makes redundant self-assignment.

It only detects local variable because it may replace state of instance variable, class variable, and global variable that have state across methods with nil.

Examples

# bad
foo = condition ? bar : foo

# good
foo = bar if condition

# bad
foo = condition ? foo : bar

# good
foo = bar unless condition

Further Reading