Search in sources :

Example 1 with FooRule

use of net.sourceforge.pmd.FooRule in project pmd by pmd.

the class XMLRendererTest method createRuleViolation.

private static RuleViolation createRuleViolation(String description) {
    DummyNode node = new DummyNode(1);
    node.testingOnlySetBeginLine(1);
    node.testingOnlySetBeginColumn(1);
    node.testingOnlySetEndLine(1);
    node.testingOnlySetEndColumn(1);
    RuleContext ctx = new RuleContext();
    ctx.setSourceCodeFilename("n/a");
    return new ParametricRuleViolation<Node>(new FooRule(), ctx, node, description);
}
Also used : ParametricRuleViolation(net.sourceforge.pmd.lang.rule.ParametricRuleViolation) FooRule(net.sourceforge.pmd.FooRule) RuleContext(net.sourceforge.pmd.RuleContext) DummyNode(net.sourceforge.pmd.lang.ast.DummyNode)

Example 2 with FooRule

use of net.sourceforge.pmd.FooRule 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"));
}
Also used : ParametricRuleViolation(net.sourceforge.pmd.lang.rule.ParametricRuleViolation) FooRule(net.sourceforge.pmd.FooRule) RuleContext(net.sourceforge.pmd.RuleContext) Report(net.sourceforge.pmd.Report) DummyNode(net.sourceforge.pmd.lang.ast.DummyNode) RuleViolation(net.sourceforge.pmd.RuleViolation) ParametricRuleViolation(net.sourceforge.pmd.lang.rule.ParametricRuleViolation) ReportTest(net.sourceforge.pmd.ReportTest) Test(org.junit.Test)

Example 3 with FooRule

use of net.sourceforge.pmd.FooRule 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;
}
Also used : ParametricRuleViolation(net.sourceforge.pmd.lang.rule.ParametricRuleViolation) FooRule(net.sourceforge.pmd.FooRule) RuleContext(net.sourceforge.pmd.RuleContext) Report(net.sourceforge.pmd.Report) HashMap(java.util.HashMap) Node(net.sourceforge.pmd.lang.ast.Node)

Example 4 with FooRule

use of net.sourceforge.pmd.FooRule 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");
}
Also used : ParametricRuleViolation(net.sourceforge.pmd.lang.rule.ParametricRuleViolation) FooRule(net.sourceforge.pmd.FooRule) RuleContext(net.sourceforge.pmd.RuleContext) DummyNode(net.sourceforge.pmd.lang.ast.DummyNode)

Example 5 with FooRule

use of net.sourceforge.pmd.FooRule in project pmd by pmd.

the class SuppressWarningsTest method testSpecificSuppressionValue3.

@Test
public void testSpecificSuppressionValue3() {
    Report rpt = new Report();
    runTestFromString(TEST9_VALUE3, new FooRule(), rpt, LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("1.5"));
    assertEquals(1, rpt.size());
}
Also used : FooRule(net.sourceforge.pmd.FooRule) Report(net.sourceforge.pmd.Report) Test(org.junit.Test)

Aggregations

FooRule (net.sourceforge.pmd.FooRule)21 Report (net.sourceforge.pmd.Report)19 Test (org.junit.Test)18 RuleContext (net.sourceforge.pmd.RuleContext)4 ParametricRuleViolation (net.sourceforge.pmd.lang.rule.ParametricRuleViolation)4 DummyNode (net.sourceforge.pmd.lang.ast.DummyNode)3 ReportTest (net.sourceforge.pmd.ReportTest)2 HashMap (java.util.HashMap)1 ConfigurationError (net.sourceforge.pmd.Report.ConfigurationError)1 RuleViolation (net.sourceforge.pmd.RuleViolation)1 Node (net.sourceforge.pmd.lang.ast.Node)1