Main Content

Check number of lines of functions

Check ID: mathworks.jmaab_v6.mp_0034

Guideline: mp_0034: Number of lines of functions

Description

Checks if the number of lines in a function is less than or equal to the maximum value specified by the input parameter.

Note

This check considers function help comments as one line.

This check applies to the following target components:

  • MATLAB Function blocks in Simulink®.

  • MATLAB® functions in a Stateflow® chart.

  • External MATLAB files referenced in a model.

This check requires a Simulink Check™ license.

Check Parameterization

This check does not include sub-checks because the JMAAB modeling guideline provides one sub ID.

For reference, the guideline sub ID(s) that are recommended for use by the JMAAB modeling standards organizations are:

  • JMAAB — a

Select Check external .m files referenced in the model, to include .m files referenced by a model in the analysis. The check box is selected by default.

Enter a value in the Maximum lines of code per function box to specify the maximum number of lines allowed in a function. The default value is 60.

Select Exclude comments and blank lines, to prevent comments or blank lines from being considered as part of line count. The check box is not selected by default.

Results and Recommended Actions

ConditionRecommended Action
The number of lines in one or more functions exceeds the maximum value.Rewrite functions so that the number of lines is less than or equal to the maximum allowed value.

Capabilities and Limitations

  • Analyzes content of library-linked blocks. By default, the input parameter Follow links is set to on.

  • Analyzes content in masked subsystems. By default, the input parameter Look under masks is set to all.

  • Runs on library models.

  • Allows exclusion of blocks and charts.