Skip to content

Scalastyle proposed rules (Block Checks)

Matthew Farwell edited this page Apr 2, 2012 · 4 revisions

This page contains proposed rules for Scalastyle, for the category Block Checks.

Block Checks

EmptyBlock

Checks for empty blocks.

LeftCurly

Checks for the placement of left curly braces ('{') for code blocks. The policy to verify is specified using property option.

NeedBraces

Checks for braces around code blocks.

RightCurly

Checks the placement of right curly braces ('}') for else, try, and catch tokens. The policy to verify is specified using property option.

AvoidNestedBlocks

Finds nested blocks, i.e. blocks that are used freely in the code. Rationale: Nested blocks are often leftovers from the debugging process, they confuse the reader. For example this Check finds the obsolete braces in public void guessTheOutput() { int whichIsWich = 0; { int whichIsWhich = 2; } System.out.println("value = " + whichIsWhich); } and debugging / refactoring leftovers such as // if (conditionThatIsNotUsedAnyLonger) { System.out.println("unconditional"); }