Skip to content

Files

Latest commit

 

History

History
34 lines (24 loc) · 1.2 KB

SpaceAroundOperator.md

File metadata and controls

34 lines (24 loc) · 1.2 KB

Pattern: Malformed space around operator

Issue: -

Description

Checks that there is at least one space (blank) or whitespace around each binary operator, including: +, -, *, /, >>, <<, &&, ||, &, |, ?:, =, "as".

Does not check dot ('.') operator. Does not check unary operators (!, +, -, ++, --, ?.). Does not check array ('[') operator.

Known limitations:

  • Does not catch violations of missing space around equals operator (=) within a declaration expression, e.g. def x=23
  • Does not catch violations of certain ternary expressions and standalone elvis operator (?:) expressions

Examples of violations:

def someMethod() {
    3+ 5-x*23/ 100              // violation
    list \<\<123                // violation
    other\>\> writer            // violation
    x=99                        // violation
    x&& y                       // violation
    x ||y                       // violation
    x &y                        // violation
    x| y                        // violation
    [1,2]as String              // violation
}

Further Reading