CodingStyle-AllmanBraces

Use Allman bracing style

Required inputs: IR

This rule enforces the usage of Allman bracing style.
  • Opening braces should be on a separate line and at the same column as the parent statement/expression.
  • Closing braces should be on the same column as opening brace.
  • Children should be indented and must not further to the left than braces.

Possible Messages

Key

Text

Severity

Disabled

all_children_misindented

Use {} bracing style. All statements in this sequence should be corrected to start in column {}.

None

False

child_should_be_indented

Use {} bracing style. {} should be indented to start in column {}.

None

False

child_should_be_outdented

Use {} bracing style. {} should be outdented to start in column {}.

None

False

close_wrong_column

Use {} bracing style. Closing brace not in same column as opening one (should be in column {}, but is in column {}).

None

False

open_wrong_column

Use {} bracing style. Opening brace for body of {} in wrong column (should be in column {}, but is in column {}).

None

False

open_wrong_line

Use {} bracing style. Opening brace for body of {} in wrong line (should be in line {}).

None

False

Options

allow_single_line_empty_seq

allow_single_line_empty_seq : bool = False

Whether empty statement sequences on the same line are accepted: {} This is always assumed if allow_single_line_seq is true.
 

allow_single_line_lambda_seq

allow_single_line_lambda_seq : bool = False

Whether statement sequences on the same line within lambdas are accepted: {} This is always assumed if allow_single_line_seq is true.
 

allow_single_line_seq

allow_single_line_seq : bool = False

Whether all statement sequences on the same line are accepted: {...}
 

always_relative_to_enclosing_braces

always_relative_to_enclosing_braces : bool = False

Whether indentation should be checked relative to enclosing braces, even if the braces are misplaced themselves.
 

empty_macro_invocations

empty_macro_invocations : set[str] | None = None

Macro invocations which expand to empty strings "" can be considered as taking up a location. This is intended to support constructs like Qt's emit signal_func() where emit expands to "". In this case, the column of emit should start the line of source code. By default (value None): empty macro invocations will be supported as taking up a location. If configured as set of strings, only the macros whose name is in the set will be considered, other macros which expand to "" will be ignored. If the set is empty, macros which expand to "" will always be ignored.
 

expected_indent

expected_indent

Type: dict[bauhaus.ir.PIR_Class_Name, list[int | str] | None]

Default:

{
   'Catch_Block': [0],
   'Named_Label': ['1'],
   'Statement': [4],
   'Switch_Case_Label': [0]
}
Dictionary mapping PIR class names to expected number of indent columns for statements of this type. A missing value for a statement type means that these nodes are not checked at all, and a number string means that the node types have to be in exactly this column (not relative to surrounding sequence). Relative indents can be negative as well (clipped at 1). Statement as key is used for the default value. If the value is a list of the above, then the element is accepted if any of the indents matches. Preprocessor directives (Line_Directive, Macro_Definition, Include_Declaration, Undef_Directive, Conditional_Compilation_Interface, Pragma_Directive) are expected to start in column 1 without being part of the map. The exact column can be changed by adding an entry into the map. Explicitly using an empty list as entry for a directive will disable corresponding violations.
 

ignore_braces_inside_lambdas

ignore_braces_inside_lambdas : bool = False

Whether opening or closing braces inside lambdas should be checked. Note, that indentation is still checked inside lambdas.