Metrics

Maximum Nesting

Maximum nesting is a number of nested blocks that are present inside a class/method. This helps to identify how the class is deeply nested. The blocks with if, else, else if, do, while, for,foreach, switch, catch, etc statements are generally the part of nested loops. Example: Maximum Nesting is 5…

0
Read More

Response for Class (RFC)

Response for Class (RFC) is the number of methods that will be executed when any method of the class is invoked. In other words, it as a count of methods implemented by this class (including inherited methods, if any) plus a number of methods called on other classes (excluding base classes). Higher…

0
Read More

Depth of Inheritance Hierarchy (DOIH)

Depth of Inheritance Hierarchy (DOIH) is the inheritance level of a class from its topmost class in the hierarchy. It is the maximum length of the path from a class to its root class in the inheritance structure. High DOIH indicates high reuse.  However, a high DOIH makes the behaviour unpredictable.

0
Read More

Lines of Code (LOC)

Lines of Code (LOC) as the name suggests is the total number of lines in a class or method. The comment lines and the blank lines are also counted. A longer class is often difficult to maintain. LOC is the most basic metric. Example: LOC is 14 in below code…

0
Read More

Comment Ratio (CR)

Comment Ratio (CR) is simply the ratio of the line of comments to the total number of lines of code. A good comment ratio makes the code easier to understand, maintain and expand. If the comment ratio is too low, the file will be hard to maintain. A new developer…

0
Read More

Coupling Between Objects (CBO)

Coupling Between Objects (CBO) is the degree by which one object depends on each of the other objects. The coupling can occur through method calls, field accesses, inheritance, arguments, return types, etc. The degree of coupling should be low. A high value represents poor encapsulation. This makes reuse of components…

1
Read More

Cyclomatic Complexity (CC)

Cyclomatic Complexity (CC) is a measure of the program’s complexity achieved by measuring the number of linearly independent paths through a program’s source code. This measure needs to be applied to sections of source like methods of each class. Presence of IF-ELSE statements or SWITCH statements and FOR loops increases…

0
Read More

Number of Public Attributes (NOPA)

The number of Public Attributes (NOPA) is the measure of publicly exposed data of a class. It is the count of public fields. Example: Class ‘SimplePojo’ have a NOPA of 19 which is high. /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements.…

0
Read More