Skip to content

Commit

Permalink
Issue #80 Associate issues with project / directory instead of file
Browse files Browse the repository at this point in the history
  • Loading branch information
Waleri Enns authored and Bertk committed Dec 28, 2013
1 parent d50865f commit 26e16e4
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected void saveViolation(Project project, SensorContext context, String rule
Rule rule = ruleFinder.find(ruleQuery);
if (rule != null) {
Violation violation = null;
if ((file != null) && (file.length() > 0)){
if (file != null){
org.sonar.api.resources.File resource =
org.sonar.api.resources.File.fromIOFile(new File(file), project);
if (context.getResource(resource) != null) {
Expand All @@ -166,17 +166,12 @@ protected void saveViolation(Project project, SensorContext context, String rule
CxxUtils.LOG.warn("Skipping invalid line number: {}", line);
}
}
// file level violation
violation.setMessage(msg);
context.saveViolation(violation);
} else {
CxxUtils.LOG.warn("Cannot find the file '{}', skipping violation '{}'", file, msg);
}
} else {
// project level violation
violation = Violation.create(rule, project);
violation.setMessage(msg);
context.saveViolation(violation);
}

if (violation != null){
Expand All @@ -187,7 +182,7 @@ protected void saveViolation(Project project, SensorContext context, String rule
CxxUtils.LOG.warn("Cannot find the rule {}, skipping violation", ruleId);
}
}

protected void processReport(Project project, SensorContext context, File report)
throws Exception
{
Expand Down

0 comments on commit 26e16e4

Please sign in to comment.