Skip to content
Arthur van de Vondervoort edited this page Aug 20, 2024 · 2 revisions

LC0010 - Show warning about code metrics for each function or trigger

The goal of this rule is to warn if code becomes to complex.
Complex code is harder to read and harder to maintain.

This warning will show up if either the cyclomatic complexity is greater or equal 8 or if the maintainability index is below or equal to 20.
You can change those settings by creating a LinterCop.json file at project root.
See https://github.com/StefanMaron/BusinessCentral.LinterCop/blob/master/BusinessCentral.LinterCop/LinterCop.json

Cyclomatic Complexity

Cyclomatic complexity is a metric to show how complex a piece of code is. To calculate this value, the number of decisions or code paths is used.

This is the list of keywords considered as desision:

if
else if
and
or
for
foreach
while
until

Also each line of case will add up to this number

Read More: https://en.wikipedia.org/wiki/Cyclomatic_complexity#:~:text=Cyclomatic%20complexity%20is%20a%20software,through%20a%20program's%20source%20code.&text=Cyclomatic%20complexity%20may%20also%20be,or%20classes%20within%20a%20program.

Maintainability Index

Calculates an index value between 0 and 100 that represents the relative ease of maintaining the code. A high value means better maintainability. Color coded ratings can be used to quickly identify trouble spots in your code. A green rating is between 20 and 100 and indicates that the code has good maintainability. A yellow rating is between 10 and 19 and indicates that the code is moderately maintainable. A red rating is a rating between 0 and 9 and indicates low maintainability.

For more information, see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022

Clone this wiki locally