Open acheshkov opened 4 years ago
Must have: CWORD – a certain percentage of comments in source code is a good practice. CBO – numbers of mutual dependencies between classes. Should be relatively low. COH – overall coherence in the source code file. Should be relatively low. May be pretty good: DIT – Depth of Inheritance Tree, the deeper inheritance is the more complex code becomes. NCO – number of methods returning a NULL value.
NOS - Total number of Java Statements in class. Simple to calculate using javalang.
NSUB - number of subclasses of this class. Simple to calculate using AST representation.
HIER - number of methods called that are defined in the hierarchy of the class.
Based on AST metrics: 1) maximum length of the path between leaves in AST 2) minimum length of the path between leaves in AST
MPC - the number of external methods called by all the methods in the class
LMC - number of local methods calls(calls to methods that are defined in this class)
MPC is has the most impact on readability, in my opinion. The more external methods you call, the less readable code is, since we switch from context into context. Also if we have a complicated domain (we have lots of classes in the package and they are all used in a function), it will also be taking into account. Also, I would add the number of used class fields to this metrics
A number of unique, non-primitive data types used in the code normalized by NCSS.
A number of unique, non-primitive data types used in the code normalized by NCSS.
looks similar to https://pmd.github.io/latest/pmd_java_metrics_index.html#class-fan-out-complexity-class_fan_out
I propose to implement metrics of associated AST. I believe these metrics correspond well to human perception: ~ max depth of AST ~ number of leaves (number of all possible paths) ~ max node degree in AST scaled by NCSS