private static String ruleKey(AnalyzerMessage issue) { String ruleKey; RspecKey rspecKeyAnnotation = AnnotationUtils.getAnnotation(issue.getCheck().getClass(), RspecKey.class); if(rspecKeyAnnotation != null) { ruleKey = rspecKeyAnnotation.value(); } else { Rule ruleAnnotation = AnnotationUtils.getAnnotation(issue.getCheck().getClass(), Rule.class); if (ruleAnnotation != null) { ruleKey = ruleAnnotation.key(); } else { Fail.fail("Rules should be annotated with '@Rule(key = \"...\")' annotation (org.sonar.check.Rule)."); // unreachable return null; } } return ruleKey; }
public void reportIssue(AnalyzerMessage analyzerMessage) { JavaCheck check = analyzerMessage.getCheck(); Preconditions.checkNotNull(check); Preconditions.checkNotNull(analyzerMessage.getMessage()); RuleKey key = getRuleKey(check); if (key == null) { return; } File file = analyzerMessage.getFile(); InputPath inputPath = inputPathFromIOFile(file); if (inputPath == null) { return; } Double cost = analyzerMessage.getCost(); reportIssue(analyzerMessage, key, inputPath, cost); }
public void reportIssue(AnalyzerMessage analyzerMessage) { JavaCheck check = analyzerMessage.getCheck(); Preconditions.checkNotNull(check); Preconditions.checkNotNull(analyzerMessage.getMessage()); RuleKey key = getRuleKey(check); if (key == null) { return; } File file = analyzerMessage.getFile(); InputPath inputPath = inputPathFromIOFile(file); if (inputPath == null) { return; } Double cost = analyzerMessage.getCost(); reportIssue(analyzerMessage, key, inputPath, cost); }
public void reportIssue(AnalyzerMessage analyzerMessage) { JavaCheck check = analyzerMessage.getCheck(); Preconditions.checkNotNull(check); Preconditions.checkNotNull(analyzerMessage.getMessage()); RuleKey key = getRuleKey(check); if (key == null) { return; } File file = analyzerMessage.getFile(); InputPath inputPath = inputPathFromIOFile(file); if (inputPath == null) { return; } Double cost = analyzerMessage.getCost(); assertEffortToFixIsNotRequired(check, cost); if (IS_SONARQUBE_52) { reportIssueAfterSQ52(analyzerMessage, key, inputPath, cost); } else { reportIssueBeforeSQ52(inputPath, key, cost, analyzerMessage.getMessage(), analyzerMessage.getLine()); } }