forked from phoedos/pmd
Fix more tests
This commit is contained in:
@ -86,8 +86,10 @@ public class ApexSharingViolationsNestedClassTest extends RuleTst {
|
||||
public void testSharingPermutation() {
|
||||
String apexClass = generateClass(outerSharingDeclared, outerOperation, innerSharingDeclared, innerOperation);
|
||||
Report rpt = new Report();
|
||||
runTestFromString(apexClass, new ApexSharingViolationsRule(), rpt,
|
||||
LanguageRegistry.getLanguage(ApexLanguageModule.NAME).getDefaultVersion());
|
||||
ApexSharingViolationsRule rule = new ApexSharingViolationsRule();
|
||||
rule.setMessage("a message");
|
||||
runTestFromString(apexClass, rule, rpt,
|
||||
LanguageRegistry.getLanguage(ApexLanguageModule.NAME).getDefaultVersion());
|
||||
List<RuleViolation> violations = rpt.getViolations();
|
||||
assertEquals("Unexpected Violation Size\n" + apexClass, expectedViolations, violations.size());
|
||||
List<Integer> lineNumbers = violations.stream().map(v -> v.getBeginLine()).collect(Collectors.toList());
|
||||
|
@ -35,7 +35,7 @@ public class AvoidTabCharacterRule extends AbstractPLSQLRule {
|
||||
while ((line = in.readLine()) != null) {
|
||||
lineNumber++;
|
||||
if (line.indexOf('\t') != -1) {
|
||||
addViolationWithMessage(data, null, "Tab characters are not allowed. Use spaces for indentation",
|
||||
addViolationWithMessage(data, node, "Tab characters are not allowed. Use spaces for indentation",
|
||||
lineNumber, lineNumber);
|
||||
|
||||
if (!eachLine) {
|
||||
|
@ -43,7 +43,7 @@ public class LineLengthRule extends AbstractPLSQLRule {
|
||||
while ((line = in.readLine()) != null) {
|
||||
lineNumber++;
|
||||
if (line.length() > maxLineLength) {
|
||||
addViolationWithMessage(data, null, "The line is too long. Only " + maxLineLength + " characters are allowed.",
|
||||
addViolationWithMessage(data, node, "The line is too long. Only " + maxLineLength + " characters are allowed.",
|
||||
lineNumber, lineNumber);
|
||||
|
||||
if (!eachLine) {
|
||||
|
@ -59,6 +59,7 @@ public class PLSQLXPathRuleTest extends AbstractPLSQLParserTst {
|
||||
rule.setMessage("Test Violation");
|
||||
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setCurrentRule(rule);
|
||||
ctx.setLanguageVersion(plsql.getDefaultVersion());
|
||||
|
||||
rule.apply(singletonList(node), ctx);
|
||||
|
@ -42,6 +42,11 @@ public class ScalaRuleTest extends BaseScalaTest {
|
||||
@Test
|
||||
public void testDummyRule() {
|
||||
ScalaRule rule = new ScalaRule() {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "a message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleContext visit(ASTTermApply node, RuleContext data) {
|
||||
ASTTermName child = node.getFirstChildOfType(ASTTermName.class);
|
||||
|
Reference in New Issue
Block a user