private static String normalizedFilePath(AnalyzerMessage analyzerMessage) { String absolutePath = analyzerMessage.getFile().getPath(); return absolutePath.replace("\\", "/"); }
@Override public String toString() { return String.format("'%s' in %s:%d", getMessage(), getFile(), getLine()); } }
@Override public String toString() { return String.format("'%s' in %s:%d", getMessage(), getFile(), getLine()); } }
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); }
@VisibleForTesting void reportIssue(AnalyzerMessage analyzerMessage, RuleKey key, InputPath inputPath, Double cost) { Preconditions.checkNotNull(context); JavaIssue issue = JavaIssue.create(context, key, cost); AnalyzerMessage.TextSpan textSpan = analyzerMessage.primaryLocation(); if (textSpan == null) { // either an issue at file or folder level issue.setPrimaryLocationOnFile(inputPath, analyzerMessage.getMessage()); } else { if (!textSpan.onLine()) { Preconditions.checkState(!textSpan.isEmpty(), "Issue location should not be empty"); } issue.setPrimaryLocation((InputFile) inputPath, analyzerMessage.getMessage(), textSpan.startLine, textSpan.startCharacter, textSpan.endLine, textSpan.endCharacter); } issue.addFlow(inputFromIOFile(analyzerMessage.getFile()), analyzerMessage.flows).save(); }
@VisibleForTesting void reportIssue(AnalyzerMessage analyzerMessage, RuleKey key, InputPath inputPath, Double cost) { Preconditions.checkNotNull(context); JavaIssue issue = JavaIssue.create(context, key, cost); AnalyzerMessage.TextSpan textSpan = analyzerMessage.primaryLocation(); if (textSpan == null) { // either an issue at file or folder level issue.setPrimaryLocationOnFile(inputPath, analyzerMessage.getMessage()); } else { if (!textSpan.onLine()) { Preconditions.checkState(!textSpan.isEmpty(), "Issue location should not be empty"); } issue.setPrimaryLocation((InputFile) inputPath, analyzerMessage.getMessage(), textSpan.startLine, textSpan.startCharacter, textSpan.endLine, textSpan.endCharacter); } issue.addFlow(inputFromIOFile(analyzerMessage.getFile()), analyzerMessage.flows).save(); }
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()); } }
@VisibleForTesting void reportIssueAfterSQ52(AnalyzerMessage analyzerMessage, RuleKey key, InputPath inputPath, Double cost) { JavaIssue issue = JavaIssue.create(context, key, cost); AnalyzerMessage.TextSpan textSpan = analyzerMessage.primaryLocation(); if (textSpan == null) { // either an issue at file or folder level issue.setPrimaryLocationOnFile(inputPath, analyzerMessage.getMessage()); } else { issue.setPrimaryLocation((InputFile) inputPath, analyzerMessage.getMessage(), textSpan.startLine, textSpan.startCharacter, textSpan.endLine, textSpan.endCharacter); } for (AnalyzerMessage location : analyzerMessage.secondaryLocations) { AnalyzerMessage.TextSpan secondarySpan = location.primaryLocation(); issue.addSecondaryLocation( inputFromIOFile(location.getFile()), secondarySpan.startLine, secondarySpan.startCharacter, secondarySpan.endLine, secondarySpan.endCharacter, location.getMessage()); } issue.save(); }