HAROSviz

C++
Python

n/a

Quality Progress

L0
L1
L2
L3
L4
L5
L6
L7
Back to Top

Metrics

How are lines of code measured?

HAROS supports several ways to measure lines of code:

LOC (Physical Lines of Code)
measures the number of line feeds in a text file.
SLOC (Source Lines of Code)
measures the number of physical lines, minus blank lines; it is the number of lines of source code and comments.
PLOC (Program Lines of Code)
measures the number of source code lines (no comments or blank lines).
LLOC (Logical Lines of Code)
measures the number of logical lines of code; e.g. if (condition) func(); counts as two lines.
ELOC (Executable Lines of Code)
measures the number of executable lines of code; e.g. this could exclude lines with braces and so on, depending on the language.

Note: HAROS, by itself, only counts LOC. All other types are provided by plugins. Since you may be running HAROS without any of the other LOC types, for calculating package score (colour) HAROS uses an estimate of the useful lines of code, calculated from the raw LOC value. This estimate tries to approximate a PLOC/ELOC value, but may be quite wrong.

What is Cyclomatic Complexity, and how to fix it?

Cyclomatic Complexity measures the amount of execution paths that result from decisions within a function. In English: the minimum value is 1, because there is always one path for the function; there is no maximum, by definition; it counts the amount of if, or, and, for, while... Typically, the greater the value, the harder it is to understand the function.

Normally, when CC is high, the functions also tend to be quite big. Try to split the function in smaller functions that make sense (and ideally, ones that can be reused).

Note: use your best judgement when breaking functions into smaller chunks. Sometimes, a function has many decisions, but may be easier to understand in the whole, rather than a bunch of smaller functions whose sole purpose is to decrease a number.

What is the Maintainability Index, and how can I increase it?

The Maintainability Index is a metric that is calculated from a bunch of other metrics (lines of code, comment ratio, Cyclomatic Complexity, Halstead Volume). It was designed to be a score for how maintainable your code is. However, it has received some criticism over time, and many people say that its current definition could improve. Use it as feedback, but not as a rule.

Naturally, to improve it, you need to improve these metrics. Decrease lines of code, document your code, and reduce its complexity.

Loading...