Skip to content

Files

Latest commit

 

History

History
48 lines (35 loc) · 1.41 KB

IfBrace.md

File metadata and controls

48 lines (35 loc) · 1.41 KB

Pattern: if without braces

Issue: -

Description

Some people find if clauses with braces easier to read. The singleLineAllowed property allows if constructions of the type:

if (bool_expression) expression1 else expression2

The doubleLineAllowed property allows if constructions of the type:

if (bool_expression) expression1
else expression2

Note: If you intend to enable only if expressions in the format below, disable the IfBraceChecker altogether.

if (bool_expression)
  expression1
else
  expression2

Parameters

NameDescriptionTypeDefault Value
singleLineAllowed Single Line Allowed boolean true
doubleLineAllowed Double Line Allowed boolean false

Example configuration

<check enabled="true" class="org.scalastyle.scalariform.IfBraceChecker" level="warning">
 <parameters>
  <parameter name="singleLineAllowed">true</parameter>
  <parameter name="doubleLineAllowed">false</parameter>
 </parameters>
</check>