Metrix++ is a tool to collect and analyse code metrics. Any metric is useless if it is not used. Metrix++ offers great usage capabilities and assists with variety of application use cases:
The workflow sections explain basic application principles.
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 obviously detects comments, strings and code for preprocessor. The identified regions form a tree of nested source code blocks, which are refered after and additionally scanned by metrics plugins. This concept allows to attribute metrics per regions, what gives fine grained data and rich input to analysis tools. The following example demonstrates this.
Source code | Regions tree [type: name: content type] |
---|---|
// simple C++ code #include <myapi.h> // I explain the following class class MyClass { public: int m_var; // some member // I explain the following function MyClass(): m_var(0) { char str[] = "unused string" // nested region for good measure struct MyStruct {}; } // Do not judge ugly code below #define get_max(a,b) ((a)>(b)?(a):(b)) set_max(int b) { m_var = get_max(m_var, b); } }; // this is the last line |
file: __global__: comment file: __global__: code file: __global__: preprocessor file: __global__: code class: MyClass: comment class: MyClass: code class: MyClass: code class: MyClass: code, comment class: MyClass: code function: MyClass: comment function: MyClass: code function: MyClass: code, string function: MyClass: code struct: MyStruct: comment struct: MyStruct: code function: MyClass: code class: MyClass: code function: set_max: comment function: set_max: preprocessor function: set_max: code function: set_max: code function: set_max: code class: MyClass: code file: __global__: comment |
Metrics highlighed in blue are per file metrics. Other metrics are per region metrics. Region term is explained in the previous chapter.
Metric (enable option) | Brief description | Motivation |
---|---|---|
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.lines.total | Number of non-blank lines of code of any content type (exectuable, comments, etc.) | |
std.code.lines.code | Number of non-blank lines of code excluding preprocessor, comments and strings. | |
std.code.lines.preprocessor | Number of non-blank lines of preprocessor code. |
|
std.code.lines.comments | Number of non-blank lines of comments. |
|
std.code.complexity.cyclomatic | McCabe cyclomatic complexity metric. |
|
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. Errors, like mismatched brackets, may result in bad identification of regions. |
|
std.general.proctime | Seconds spent on processing a file. |
|
In order to get the tool working, dowload the archive with the latest stable version and unpack it to some folder. First run of the tool will trigger the installation within the folder, where it was launched.
Corresponding checkout from the version control system is the following:
svn checkout svn://svn.code.sf.net/p/metrixplusplus/code/releases/latest Metrix++
In order to checkout the latest version under development, use this command:
svn checkout svn://svn.code.sf.net/p/metrixplusplus/code/mainline Metrix++
Python Runtime Environment (version 2.7.* or later, version 3.* has not been tested)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the Metrix++; if not, contact Project Administrator
...
...
...
Metrix++ has got suppressions capability. Suppressions are collected from comments in code and used by post-processing tools, like 'limit'. It allows to take fine grained control over false-positive warnings, if there are.
describe METRIXPLUSPLUS_PATH environment variable
...
...
...