Merge branch 'master' into pmd/7.0.x
This commit is contained in:
@ -8,6 +8,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.PMD.StatusCode;
|
||||
|
||||
/**
|
||||
* @author Romain Pelisse <belaran@gmail.com>
|
||||
*
|
||||
@ -15,9 +17,16 @@ import org.junit.Test;
|
||||
public class CLITest extends BaseCLITest {
|
||||
@Test
|
||||
public void useEcmaScript() {
|
||||
String[] args = { "-d", SOURCE_FOLDER, "-f", "xml", "-R", "ecmascript-basic", "-l",
|
||||
"ecmascript", "--debug", };
|
||||
String log = runTest(args);
|
||||
String log = runTest(StatusCode.VIOLATIONS_FOUND,
|
||||
"-d",
|
||||
SOURCE_FOLDER,
|
||||
"-f",
|
||||
"xml",
|
||||
"-R",
|
||||
"rulesets/testing/js-rset1.xml",
|
||||
"-l",
|
||||
"ecmascript",
|
||||
"--debug");
|
||||
assertThat(log, containsPattern("Adding file .*\\.js \\(lang: ecmascript ES6\\)"));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule;
|
||||
|
||||
/**
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
public class DummyJsRule extends AbstractEcmascriptRule {
|
||||
|
||||
@Override
|
||||
public void apply(List<? extends Node> nodes, RuleContext ctx) {
|
||||
for (Node node : nodes) {
|
||||
apply(node, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public void apply(Node node, RuleContext ctx) {
|
||||
|
||||
}
|
||||
|
||||
public static class DummyRuleOneViolationPerFile extends DummyJsRule {
|
||||
|
||||
@Override
|
||||
public void apply(Node node, RuleContext ctx) {
|
||||
ctx.addViolation(node);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Test Ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||
|
||||
<description>
|
||||
Ruleset used by test RuleSetReferenceIdTest
|
||||
</description>
|
||||
|
||||
<rule name="DummyRuleWithAViolationPerFile"
|
||||
language="ecmascript"
|
||||
since="1.0"
|
||||
message="Violation from test-rset-1.xml"
|
||||
class="net.sourceforge.pmd.lang.ecmascript.DummyJsRule$DummyRuleOneViolationPerFile">
|
||||
<description>
|
||||
Just for test
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
Reference in New Issue
Block a user