Implement rules tracking style of braces and parentheses
jvsqzj opened this issue · 0 comments
jvsqzj commented
This issue defines requirement to extend the lint module to include the following set of rules, as detailed in DML style guide:
Braces
- BR1 No braces are required around single-statement blocks (but see the rule for comments)
- BR2 Empty DML object declarations should be written with a semicolon instead of an empty brace pair
- BR3 Methods should have the opening brace on the same line as the method declaration
Parentheses
-
PA1 Parentheses not required by the language may be added to expressions for clarity or indentation
-
PA2 Parentheses should be added when the operator precedence is not intuitively obvious. This is mandatory to resolve precedence between the following operators, even if it is well-defined by the language:
1. || vs && 2. bitwise operators (|, &, ^) vs each other 3. bitwise operators vs arithmetic operators (+, -, *, /, %) 4. bitwise operators vs comparisons (==, !=, >, <, >=, <=) 5. shift operators (<<, >>) vs arithmetic operators 6. comparisons vs each other 7. shift operators vs each other -
PA3 When neither language nor understanding or layout require parentheses, they should be omitted
-
PA4 Parentheses should also be added to assignment statements inside expressions, to clearly show that they were intended