Main Content

jc_0736: Uniform indentations in Stateflow blocks

Since R2020a

Guideline Publication

Control Algorithm Modeling Guidelines - Using MATLAB®, Simulink®, and Stateflow®

Sub ID Recommendations

  • NA-MAAB — No recommendations

  • JMAAB — a, b, c

MATLAB Versions

All

Rule

Sub ID a

State action types shall not have blank spaces at the start of a line.

Executable statements shall have one single-byte space at the start of the line.

Custom Parameter

Number of single-byte spaces

Example — Correct

Executable statements use one single-byte space at the start of the line.

Example — Incorrect

Executable statements do not have a single-byte space at the start of the line.

Sub ID b

A blank space shall not be entered before the following:

  • [ of a transition condition

  • { of a condition action

  • / of a transition action

Custom Parameter

Not Applicable

Example — Correct

A blank space is not entered before the [ and { of the transition label condition, condition action, and transition action.

Example — Incorrect

A blank space is entered before the [ and { of the transition label condition, condition action, and transition action.

Sub ID c

At least one single-byte space shall be entered after the / of a transition action.

Custom Parameter

Number of single-byte spaces

Example — Correct

Single-byte spaces are entered after the / of the transition action.

Example — Incorrect

There are no single-byte spaces after the / of the transition action.

Rationale

Sub ID a:

  • Using uniform indents before the executable statement clarifies the link between the state action type of a state label and the execution statement, improving readability.

Sub ID b:

  • Using uniform indents for transition conditions, condition actions, and transition actions improves readability.

Sub ID c:

  • Consistent use of blank spaces improves readability.

Verification

Model Advisor check: Check indentation of code in Stateflow states (Simulink Check)

Last Changed

R2020a

Version History

Introduced in R2020a