Find overly complex expressions

Proprietary

Marks expressions that use more than three conditional operators. Only &&, || and the ? : conditional are counted, each occurrence separately, so a && b && c && d contributes three; &, |, ^ and ! are not counted even on booleans. An expression this dense is hard to read and hard to test, and is usually better split into well-named boolean variables or methods. The whole outermost expression is counted as one unit, so a sub-expression inside a marked expression is never marked a second time, and the operators of a parenthesized part count towards the expression containing it. A class body, an array initializer, an annotation argument and the body of a lambda written as a block start counting again from zero, and equals methods are not marked because a long chain of field comparisons is idiomatic there. Test sources are not searched.

io.moderne.staticanalysis.FindOverlyComplexExpression
mod run . --recipe=io.moderne.staticanalysis.FindOverlyComplexExpression

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.