use of net.sourceforge.pmd.RuleContext in project pmd by pmd.
the class AbstractRule method addViolation.
/**
* @see RuleViolationFactory#addViolation(RuleContext, Rule, Node, String,
* Object[])
*/
public void addViolation(Object data, Node node) {
RuleContext ruleContext = (RuleContext) data;
ruleContext.getLanguageVersion().getLanguageVersionHandler().getRuleViolationFactory().addViolation(ruleContext, this, node, this.getMessage(), null);
}
use of net.sourceforge.pmd.RuleContext in project pmd by pmd.
the class AbstractRule method addViolation.
/**
* @see RuleViolationFactory#addViolation(RuleContext, Rule, Node, String,
* Object[])
*/
public void addViolation(Object data, Node node, String arg) {
RuleContext ruleContext = (RuleContext) data;
ruleContext.getLanguageVersion().getLanguageVersionHandler().getRuleViolationFactory().addViolation(ruleContext, this, node, this.getMessage(), new Object[] { arg });
}
use of net.sourceforge.pmd.RuleContext in project pmd by pmd.
the class AbstractRule method addViolationWithMessage.
/**
* @see RuleViolationFactory#addViolation(RuleContext, Rule, Node, String,
* Object[])
*/
public void addViolationWithMessage(Object data, Node node, String message) {
RuleContext ruleContext = (RuleContext) data;
ruleContext.getLanguageVersion().getLanguageVersionHandler().getRuleViolationFactory().addViolation(ruleContext, this, node, message, null);
}
use of net.sourceforge.pmd.RuleContext in project pmd by pmd.
the class AbstractRendererTst method testRuleWithProperties.
@Test
public void testRuleWithProperties() throws Exception {
DummyNode node = createNode(1);
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename(getSourceCodeFilename());
Report report = new Report();
RuleWithProperties theRule = new RuleWithProperties();
theRule.setProperty(RuleWithProperties.STRING_PROPERTY_DESCRIPTOR, "the string value\nsecond line with \"quotes\"");
report.addRuleViolation(new ParametricRuleViolation<Node>(theRule, ctx, node, "blah"));
String rendered = ReportTest.render(getRenderer(), report);
assertEquals(filter(getExpectedWithProperties()), filter(rendered));
}
use of net.sourceforge.pmd.RuleContext in project pmd by pmd.
the class MultiThreadProcessorTest method setUpForTest.
public void setUpForTest(final String ruleset) {
PMDConfiguration configuration = new PMDConfiguration();
configuration.setRuleSets(ruleset);
configuration.setThreads(2);
files = new ArrayList<>();
files.add(new StringDataSource("file1-violation.dummy", "ABC"));
files.add(new StringDataSource("file2-foo.dummy", "DEF"));
reportListener = new SimpleReportListener();
ctx = new RuleContext();
ctx.getReport().addListener(reportListener);
processor = new MultiThreadProcessor(configuration);
ruleSetFactory = new RuleSetFactory();
}
Aggregations