public class IdentifiersMetric extends ASTMetric
Constructor and Description |
---|
IdentifiersMetric(Node astNode) |
Modifier and Type | Method and Description |
---|---|
void |
addMetrics(ClassData data) |
NodeVisitor |
enter(Node parent,
Node n) |
void |
reset() |
enter, execute, getClassData, leave, printAstMetric
public IdentifiersMetric(Node astNode)
astNode
- This metric will take a measure of the "complexity" of each identifier used
within the program. An identifier's complexity is computed as follows:
First the alpha tokens are parsed by splitting on non-alphas and capitals:
example identifier: getASTNode alpha tokens: get, AST, Node
example identifier: ___Junk$$name alpha tokens: Junk, name)
The alpha tokens are then counted and a 'token complexity' is formed by the ratio
of total tokens to the number of tokens found in the dictionary:
example identifier: getASTNode Total: 3, Found: 2, Complexity: 1.5
Then the 'character complexity' is computed, which is a ratio of total number of
characters to the number of non-complex characters. Non-complex characters are
those which are NOT part of a multiple string of non-alphas.
example identifier: ___Junk$$name complex char strings: '___', '$$'
number of non-complex (Junk + name): 8, total: 13, Complexity: 1.625
Finally, the total identifier complexity is the sum of the token and character
complexities multipled by the 'importance' of an identifier:
Multipliers are as follows:
Class multiplier = 3;
Method multiplier = 4;
Field multiplier = 2;
Formal multiplier = 1.5;
Local multiplier = 1;public void addMetrics(ClassData data)
addMetrics
in class ASTMetric
public NodeVisitor enter(Node parent, Node n)