Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

Class-level metrics

Name Description Metric code ID Languages
Lines of code in class number of lines of code in a class; calculated as (last line number) - (first line number) + 1 LOC_CLASS 65 C++, Java
Number of methods number of methods defined in the current class. Inherited methods are not counted. This metric includes methods whose declaration is met in the class but whose body is outside the class (for example, in another file). NOMETH 66 C++, Java
Level of inheritance For classes, this is the level of the class in the class hierarchy tree. For interfaces, it is always 1. LEVINHER 67 C++, Java
Number of data declarations in the class number of fields in the class (methods and inherited fields are not counted) NOCLASSDATADECL 68 C++, Java
Number of class data types in the class number of class data types in the class NODATACLASS 69 Java
Number of private attributes for the class number of private attributes (private data fields) for a class NOPRIVDATADEC 70 C++, Java
Number of protected methods in the class number of protected attributes (protected data fields) for a class NOPROTDATADECL 71 C++, Java
Number of public attributes for the class number of public attributes (public data fields) for a class NOPUBDATADECL 72 C++, Java
Number of static attributes for the class number of static attributes (static data fields) for a class NOSTDATADECL 73 C++, Java
Number of private methods in the class number of private methods in a class NOPRIVMETH 74 C++, Java
Number of protected methods in the class number of protected methods in a class NOPROTMETH 75 C++, Java
Number of public methods in the class number of public methods in a class NOPUBMETH 76 C++, Java
Number of ways the class can be accessed total number of messages about how a class can be accessed. Messages include public/protected methods for Java and C++ classes as well as private methods for C++ classes that have friends. NOMSG 77 C++, Java
Number of pointer data items declared in the class number of pointer data items declared in the class NOPTRDECL 78 C++, Java
Class has pointer items and has no destructor class has pointer items and has no destructor HASPTRWODESTR 79 C++
Number of in-line methods declared in the class number of in-line methods declared in the class NOINLINEMETH 80 C++
Size of the class in bytes Size of the class in bytes. For more information about calculating this metric, see Specifying sizes for built-in types. BYTESDATADECL 81 C++
Number of methods declared constant number of methods declared constant NOCONSTMETH 82 C++
Number of pure virtual methods in the class number of pure virtual methods in the class NOVIRTMETH 83 C++
Non-comment, non-blank lines of code in the class the number of lines of code in a class, not including comment lines and blank lines NCNBLOC_CLASS 84 C++, Java
ancestor class-attribute import coupling See 'Coupling metrics for object-oriented languages' below. ACAIC 205 C++, Java
ancestor class-method import coupling ACMIC 206 C++, Java
descendant class-attribute export coupling DCAEC 207 C++, Java
descendant class-method export coupling DCMEC 208 C++, Java
class-attribute import coupling OCAIC 209 C++, Java
class-attribute export coupling OCAEC 210 C++, Java
class-method import coupling OCMIC 211 C++, Java
class-method export coupling OCMEC 212 C++, Java
ancestor class-method-class-method import coupling AMMIC 213 C++, Java
descendant class-method-class-method export coupling DMMEC 214 C++, Java
class-method-class-method import coupling OMMIC 215 C++, Java
class-method-class-method export coupling OMMEC 216 C++, Java

Coupling metrics for object-oriented languages

For a given class, these metrics count relationships where source or destination is presented by the class or by its methods/attributes.

All these relationships are divided into groups according to three factors.

  1. Type of relationship between a given class and an interacting class: their relationship (whether it is a parent-child relationship or other);
  2. Type of interaction (whether current class has an attribute, method parameter, or return type of another class, or class-method from one class invoke class-method from another class);
  3. Focus of impact (whether a class is using another class through its attributes, methods or method types — import — or it is used by another class - export).

One should notice that all the names of the metrics are acronyms of the metric's description. First letters in the acronyms stand for these 3 types of interactions: A for ancestor, D for descendant, O for other (neither ancestor nor descendant), 2nd and 3rd letters encode interaction CA for class-attribute, CM for class-method, MM for method-method, IC for import coupling and EC for export coupling.

Coupling metrics in the Klocwork system-level Java reports

The Klocwork system-level Java reports use the sum of the coupling metrics to indicate relative connectedness of classes.

Used by (export) coupling is OCAEC+OMMEC+OCMEC for each class.

Uses (import) coupling is OCAIC+OCMIC+OMMIC for each class.

Example

----------A.java-------------
public class A extends B {
public C mal(int i) { C c = new C(); /*...*/return c; }
private B b1;
private D d1;
}
-----------------------------

----------B.java-------------
public class B extends D {
    public int mb1(D d) { int res = 0; /*....*/return res;}
    private C c1;
    private C c2;
}
-----------------------------

----------C.java-------------
public class C {
    public int mc1() { int res=k; /*...*/ return res;}
    private int k;
    private A a1;
    private A a2;
}
-----------------------------

----------D.java-------------
public class D {
    public void md1(int v) { }
}
-----------------------------