Overview
Highlights
Metrix++ is a tool to collect and analyse code metrics. Any metric is useless if it is not used. Metrix++ offers ease of introduction and integration with a variety of application use cases.
- Monitoring trends (eg. on daily basis. In order to take actions or make right decisions earlier.)
- Enforcing trends (eg. on hourly basis, at every commit of code changes.)
- Automated asistance to review agains standards (eg. on per minute basis during code refactoring and code development.) The workflow sections below demonstarate these basic application usecases.
Languages supported
The tool can parse C/C++, C# and Java source code files. The parser identifies certain regions in the code, such as classes, functions, namespaces, interfaces, etc. It detects comments, strings and code for the preprocessor. The identified regions form a tree of nested source code blocks, which are subsequently refered to and scanned by metrics plugins. Thus the tool attributes metrics to regions, which provides fine grained data to analysis tools. The following example demonstrates the regions concept. The right side comments describe Metrix++ properties attributed to each source line: type of region, name of a region and type of a content of a region).
// simple C++ code // file: __global__: comment
// file: __global__: code
#include <myapi.h> // file: __global__: preprocessor
// file: __global__: code
// I explain the following class // class: MyClass: comment
class MyClass { // class: MyClass: code
public: // class: MyClass: code
int m_var; // some member // class: MyClass: code, comment
// class: MyClass: code
// I explain the following function // function: MyClass: comment
MyClass(): m_var(0) { // function: MyClass: code
char str[] = "unused string" // function: MyClass: code, string
// function: MyClass: code, string
// nested region for good measure // function: MyClass: code
struct MyStruct {}; // struct: MyStruct: comment
} // struct: MyStruct: code
// function: MyClass: code
// Do not judge ugly code below // class: MyClass: code
#define get_max(a,b) ((a)>(b)?(a):(b)) // function: set_max: comment
set_max(int b) { // function: set_max: preprocessor
m_var = get_max(m_var, b); // function: set_max: code
} // function: set_max: code
}; // function: set_max: code
// this is the last line // file: __global__: comment
Metrics
The metrics highlighed in blue are per file metrics. The other metrics are per region metrics.
Metric (enable option) | Brief description | Motivation / Potential use | |
---|---|---|---|
std.general.size | Size of a file in bytes. |
| |
std.code.length.total | The same as 'std.general.size' metric, but attributed to code regions. | ||
std.code.filelines.total | Number of non-blank lines of code of any content type (exectuable, comments, etc.) per file | ||
std.code.lines.total | Number of non-blank lines of code of any content type (exectuable, comments, etc.) per region | ||
std.code.filelines.code | Number of non-blank lines of code excluding preprocessor and comments per file. | ||
std.code.lines.code | Number of non-blank lines of code excluding preprocessor and comments per region. | ||
std.code.filelines.preprocessor | Number of non-blank lines of preprocessor code per file. |
| |
std.code.lines.preprocessor | Number of non-blank lines of preprocessor code per region. | ||
std.code.filelines.comments | Number of non-blank lines of comments per file. |
| |
std.code.lines.comments | Number of non-blank lines of comments per region. | ||
std.code.ratio.comments | Ratio of non-empty lines of comments to non-empty lines of (code + comments) per region. | ||
std.code.complexity.cyclomatic | McCabe cyclomatic complexity metric. |
| |
std.code.complexity.cyclomatic_switch_case_once | Modified McCabe cyclomatic complexity metric which counts switch case constructs only once. |
| |
std.code.complexity.maxindent | Maximum level of indentation of blocks within a region. | ||
std.code.magic.numbers | Number of magic numbers. There is an option to exclude 0, -1 and 1 numbers from counting. | Magic numbers are dangerous. The discussion on stackoverflow explains why. | |
std.code.todo.comments, std.code.todo.strings | Number of TODO/FIXME/etc markers in comments and strings accordingly. There is an option to configure a list of markers. | Manage potentially incomplete work. If project manager dispatches issues only in a tracker tool, todo markers are lost in the source code. The metric could make these 'lost' issues visible. | |
std.general.proctime | Seconds spent on processing a file. |
| |
std.suppress | An option enables collection of Metrix++ suppressions and 2 metrics: 'std.suppress:count' and 'std.suppress.file:count'. The first is number of suppressions per region. The second is the same but applies for file-scope metrics. |
| |
std.general.procerrors | Number of errors detected by Metrix++ code parser. |
| |
std.code.maintindex.simple | Simple variant of maintainability index - a measure of maintainability. It uses std.code.lines:code and std.code.complexity:cyclomatic metrics to evaluate level of maintainability. Lower value of this index indicates better level maintainability | Identify code, which may benefit the most from refactoring. |