Fixed Trigger name is reported incorrectly
https://github.com/Up2Go/codeclimate-apexmetrics/issues/23
This commit is contained in:
@ -3,6 +3,9 @@
|
||||
*/
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import apex.jorje.data.ast.Identifier;
|
||||
import apex.jorje.semantic.ast.compilation.UserTrigger;
|
||||
|
||||
public class ASTUserTrigger extends ApexRootNode<UserTrigger> {
|
||||
@ -17,6 +20,14 @@ public class ASTUserTrigger extends ApexRootNode<UserTrigger> {
|
||||
|
||||
@Override
|
||||
public String getImage() {
|
||||
return node.getClass().getName();
|
||||
try {
|
||||
Field field = node.getClass().getDeclaredField("name");
|
||||
field.setAccessible(true);
|
||||
Identifier name = (Identifier) field.get(node);
|
||||
return name.value;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return super.getImage();
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class StdCyclomaticComplexityRule extends AbstractApexRule {
|
||||
if (showClassesComplexity) {
|
||||
Entry classEntry = entryStack.pop();
|
||||
if (classEntry.getComplexityAverage() >= reportLevel || classEntry.highestDecisionPoints >= reportLevel) {
|
||||
addViolation(data, node, new String[] { "class", node.getImage(),
|
||||
addViolation(data, node, new String[] { "trigger", node.getImage(),
|
||||
classEntry.getComplexityAverage() + " (Highest = " + classEntry.highestDecisionPoints + ')' });
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user