use of net.sourceforge.pmd.lang.rule.ParametricRuleViolation in project pmd by pmd.
the class XSLTRendererTest method testDefaultStylesheet.
@Test
public void testDefaultStylesheet() throws Exception {
XSLTRenderer renderer = new XSLTRenderer();
Report report = new Report();
DummyNode node = new DummyNode(1);
node.testingOnlySetBeginLine(1);
node.testingOnlySetBeginColumn(1);
RuleViolation rv = new ParametricRuleViolation<Node>(new FooRule(), new RuleContext(), node, "violation message");
report.addRuleViolation(rv);
String result = ReportTest.render(renderer, report);
Assert.assertTrue(result.contains("violation message"));
}
use of net.sourceforge.pmd.lang.rule.ParametricRuleViolation in project pmd by pmd.
the class SummaryHTMLRendererTest method createEmptyReportWithSuppression.
private Report createEmptyReportWithSuppression() {
Report rep = new Report();
Map<Integer, String> suppressions = new HashMap<>();
suppressions.put(1, "test");
rep.suppress(suppressions);
RuleContext ctx = new RuleContext();
ParametricRuleViolation<Node> violation = new ParametricRuleViolation<>(new FooRule(), ctx, null, "suppress test");
violation.setLines(1, 1);
rep.addRuleViolation(violation);
return rep;
}
use of net.sourceforge.pmd.lang.rule.ParametricRuleViolation in project pmd by pmd.
the class AbstractRendererTst method newRuleViolation.
private RuleViolation newRuleViolation(int endColumn) {
DummyNode node = createNode(endColumn);
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename(getSourceCodeFilename());
return new ParametricRuleViolation<Node>(new FooRule(), ctx, node, "blah");
}
use of net.sourceforge.pmd.lang.rule.ParametricRuleViolation in project pmd by pmd.
the class ReportTest method testTreeIterator.
@Test
public void testTreeIterator() {
Report r = new Report();
RuleContext ctx = new RuleContext();
Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
Node node1 = getNode(5, 5, true);
r.addRuleViolation(new ParametricRuleViolation<>(rule, ctx, node1, rule.getMessage()));
Node node2 = getNode(5, 6, true);
r.addRuleViolation(new ParametricRuleViolation<>(rule, ctx, node2, rule.getMessage()));
Iterator<RuleViolation> violations = r.iterator();
int violationCount = 0;
while (violations.hasNext()) {
violations.next();
violationCount++;
}
assertEquals(2, violationCount);
Iterator<RuleViolation> treeIterator = r.treeIterator();
int treeCount = 0;
while (treeIterator.hasNext()) {
treeIterator.next();
treeCount++;
}
assertEquals(2, treeCount);
}
use of net.sourceforge.pmd.lang.rule.ParametricRuleViolation in project pmd by pmd.
the class RuleViolationComparatorTest method createJavaRuleViolation.
private RuleViolation createJavaRuleViolation(Rule rule, String fileName, int beginLine, String description, int beginColumn, int endLine, int endColumn) {
RuleContext ruleContext = new RuleContext();
ruleContext.setSourceCodeFilename(fileName);
DummyNode simpleNode = new DummyNode(1);
simpleNode.testingOnlySetBeginLine(beginLine);
simpleNode.testingOnlySetBeginColumn(beginColumn);
simpleNode.testingOnlySetEndLine(endLine);
simpleNode.testingOnlySetEndColumn(endColumn);
RuleViolation ruleViolation = new ParametricRuleViolation<Node>(rule, ruleContext, simpleNode, description);
return ruleViolation;
}
Aggregations