Metastatic.Analysis.SimplifyConditional (Metastatic v0.10.4)

View Source

Suggests simplification of redundant conditionals.

Detects conditionals that return boolean literals and can be simplified to direct boolean expressions.

Patterns Detected

  1. if condition then true else falsecondition
  2. if condition then false else truenot condition
  3. if condition then condition else falsecondition
  4. if condition then true else conditioncondition

Examples

# Before
if x > 5 then true else false

# After
x > 5

# Before
if is_valid then false else true

# After
not is_valid