Skip to content

Files

Latest commit

 

History

History
28 lines (18 loc) · 542 Bytes

CouldBeElvis.md

File metadata and controls

28 lines (18 loc) · 542 Bytes

Pattern: Use of if instead of Elvis expression

Issue: -

Description

Catch an if block that could be written as an elvis expression.

Example of violations:

if (!x) {                   // violation
    x = 'some value'
}

if (!x)                     // violation
    x = "some value"

if (!params.max) {          // violation
  params.max = 10
}

x ?: 'some value'           // OK

Further Reading