@Test void should_ignore_violation_on_unknown_resource() { final File unknownFile = new File("src/UNKNOWN.java"); final RuleViolation pmdViolation = createPmdViolation(unknownFile, "RULE"); pmdViolationRecorder.saveViolation(pmdViolation, mockContext); verifyNoMoreInteractions(mockActiveRules); verifyNoMoreInteractions(mockContext); verify(spiedFs).inputFile(any(FilePredicate.class)); }
public void saveViolation(RuleViolation pmdViolation, SensorContext context) { final InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } final RuleKey ruleKey = findActiveRuleKeyFor(pmdViolation); if (ruleKey == null) { return; } final NewIssue issue = context.newIssue() .forRule(ruleKey); final TextRange issueTextRange = TextRangeCalculator.calculate(pmdViolation, inputFile); final NewIssueLocation issueLocation = issue.newLocation() .on(inputFile) .message(pmdViolation.getDescription()) .at(issueTextRange); issue.at(issueLocation) .save(); }
PmdViolationRecorder { public void saveViolation(RuleViolation pmdViolation, SensorContext context) { final InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } final RuleKey ruleKey = findActiveRuleKeyFor(pmdViolation); if (ruleKey == null) { return; } final NewIssue issue = context.newIssue() .forRule(ruleKey); final TextRange issueTextRange = TextRangeCalculator.calculate(pmdViolation, inputFile); final NewIssueLocation issueLocation = issue.newLocation() .on(inputFile) .message(pmdViolation.getDescription()) .at(issueTextRange); issue.at(issueLocation) .save(); } }
PmdViolationRecorder { public void saveViolation(RuleViolation pmdViolation, SensorContext context) { final InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } final RuleKey ruleKey = findActiveRuleKeyFor(pmdViolation); if (ruleKey == null) { return; } final NewIssue issue = context.newIssue() .forRule(ruleKey); final TextRange issueTextRange = TextRangeCalculator.calculate(pmdViolation, inputFile); final NewIssueLocation issueLocation = issue.newLocation() .on(inputFile) .message(pmdViolation.getDescription()) .at(issueTextRange); issue.at(issueLocation) .save(); } PmdViolationRecorder(FileSystem fs, ActiveRules activeRules); }
PmdViolationRecorder { public void saveViolation(RuleViolation pmdViolation, SensorContext context) { final InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } final RuleKey ruleKey = findActiveRuleKeyFor(pmdViolation); if (ruleKey == null) { return; } final NewIssue issue = context.newIssue() .forRule(ruleKey); final TextRange issueTextRange = TextRangeCalculator.calculate(pmdViolation, inputFile); final NewIssueLocation issueLocation = issue.newLocation() .on(inputFile) .message(pmdViolation.getDescription()) .at(issueTextRange); issue.at(issueLocation) .save(); } PmdViolationRecorder(FileSystem fs, ActiveRules activeRules); void saveViolation(RuleViolation pmdViolation, SensorContext context); }
PmdViolationRecorder { public void saveViolation(RuleViolation pmdViolation, SensorContext context) { final InputFile inputFile = findResourceFor(pmdViolation); if (inputFile == null) { return; } final RuleKey ruleKey = findActiveRuleKeyFor(pmdViolation); if (ruleKey == null) { return; } final NewIssue issue = context.newIssue() .forRule(ruleKey); final TextRange issueTextRange = TextRangeCalculator.calculate(pmdViolation, inputFile); final NewIssueLocation issueLocation = issue.newLocation() .on(inputFile) .message(pmdViolation.getDescription()) .at(issueTextRange); issue.at(issueLocation) .save(); } PmdViolationRecorder(FileSystem fs, ActiveRules activeRules); void saveViolation(RuleViolation pmdViolation, SensorContext context);  }