Skip to content

Files

Latest commit

 

History

History
34 lines (23 loc) · 826 Bytes

ForBrace.md

File metadata and controls

34 lines (23 loc) · 826 Bytes

Pattern: Missing braces in for

Issue: -

Description

Usage of braces (rather than parentheses) within a for comprehension means that you don't have to specify a semicolon at the end of every line:

for {      // braces
  t <- List(1,2,3)
  if (i % 2 == 0)
} yield t

is preferred to

for (      // parentheses
  t <- List(1,2,3);
  if (i % 2 == 0)
) yield t

To fix it, replace the () with {}. And then remove the ; at the end of the lines.

Example configuration

<check enabled="true" class="org.scalastyle.scalariform.ForBraceChecker" level="warning"/>