diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java index 823aced81c..551da0b39f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java @@ -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 { @@ -17,6 +20,14 @@ public class ASTUserTrigger extends ApexRootNode { @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(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java index ccdfffc8f6..b9f583e3fb 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java @@ -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 + ')' }); } }