@Test public void should_ignore_violation_on_unknown_resource() { org.sonar.api.rules.Rule sonarRule = createRuleInRuleFinder("RULE"); File unknownFile = new File("src/UNKNOWN.java"); RuleViolation pmdViolation = createPmdViolation(unknownFile, 42, "Description", "RULE"); pmdViolationRecorder.saveViolation(pmdViolation); verifyZeroInteractions(sonarRule); }
public void saveViolation(RuleViolation pmdViolation) { InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } Issuable issuable = perspectives.as(Issuable.class, inputFile); Rule rule = findRuleFor(pmdViolation); if (issuable == null || rule == null) { return; } IssueBuilder issueBuilder = issuable.newIssueBuilder() .ruleKey(rule.ruleKey()) .message(pmdViolation.getDescription()) .line(pmdViolation.getBeginLine()); issuable.addIssue(issueBuilder.build()); }
PmdViolationRecorder implements BatchExtension { public void saveViolation(RuleViolation pmdViolation) { InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } Issuable issuable = perspectives.as(Issuable.class, inputFile); Rule rule = findRuleFor(pmdViolation); if (issuable == null || rule == null) { return; } IssueBuilder issueBuilder = issuable.newIssueBuilder() .ruleKey(rule.ruleKey()) .message(pmdViolation.getDescription()) .line(pmdViolation.getBeginLine()); issuable.addIssue(issueBuilder.build()); } }
PmdViolationRecorder implements BatchExtension { public void saveViolation(RuleViolation pmdViolation) { InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } Issuable issuable = perspectives.as(Issuable.class, inputFile); Rule rule = findRuleFor(pmdViolation); if (issuable == null || rule == null) { return; } IssueBuilder issueBuilder = issuable.newIssueBuilder() .ruleKey(rule.ruleKey()) .message(pmdViolation.getDescription()) .line(pmdViolation.getBeginLine()); issuable.addIssue(issueBuilder.build()); } PmdViolationRecorder(FileSystem fs, RuleFinder ruleFinder, ResourcePerspectives perspectives); }
PmdViolationRecorder implements BatchExtension { public void saveViolation(RuleViolation pmdViolation) { InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } Issuable issuable = perspectives.as(Issuable.class, inputFile); Rule rule = findRuleFor(pmdViolation); if (issuable == null || rule == null) { return; } IssueBuilder issueBuilder = issuable.newIssueBuilder() .ruleKey(rule.ruleKey()) .message(pmdViolation.getDescription()) .line(pmdViolation.getBeginLine()); issuable.addIssue(issueBuilder.build()); } PmdViolationRecorder(FileSystem fs, RuleFinder ruleFinder, ResourcePerspectives perspectives); void saveViolation(RuleViolation pmdViolation); }
PmdViolationRecorder implements BatchExtension { public void saveViolation(RuleViolation pmdViolation) { InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } Issuable issuable = perspectives.as(Issuable.class, inputFile); Rule rule = findRuleFor(pmdViolation); if (issuable == null || rule == null) { return; } IssueBuilder issueBuilder = issuable.newIssueBuilder() .ruleKey(rule.ruleKey()) .message(pmdViolation.getDescription()) .line(pmdViolation.getBeginLine()); issuable.addIssue(issueBuilder.build()); } PmdViolationRecorder(FileSystem fs, RuleFinder ruleFinder, ResourcePerspectives perspectives); void saveViolation(RuleViolation pmdViolation);  }