intel / intel/dml-language-server

Implement rules tracking style of braces and parentheses

Open
#72 0 comments 0 reactions 0 assignees View on GitHub
enhancement Linter
Dominant language
Rust
Stars
9
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.