From e39cbba24aa663eda230b81325cfe5216df19cfe Mon Sep 17 00:00:00 2001 From: oowekyala Date: Thu, 13 Jul 2017 14:54:05 +0200 Subject: [PATCH] Added overloads of setProperty for multivalued properties --- .../apexunit/AbstractApexUnitTestRule.java | 4 +-- .../complexity/AbstractNcssCountRule.java | 4 +-- .../AvoidDeeplyNestedIfStmtsRule.java | 4 +-- .../complexity/ExcessiveClassLengthRule.java | 4 +-- .../ExcessiveParameterListRule.java | 4 +-- .../complexity/ExcessivePublicCountRule.java | 4 +-- .../complexity/NcssConstructorCountRule.java | 4 +-- .../rule/complexity/NcssMethodCountRule.java | 4 +-- .../rule/complexity/NcssTypeCountRule.java | 4 +-- .../StdCyclomaticComplexityRule.java | 3 +- .../rule/complexity/TooManyFieldsRule.java | 3 +- .../AvoidDmlStatementsInLoopsRule.java | 4 +-- .../performance/AvoidSoqlInLoopsRule.java | 4 +-- .../apex/rule/security/ApexBadCryptoRule.java | 3 +- .../rule/security/ApexCRUDViolationRule.java | 2 +- .../lang/apex/rule/security/ApexCSRFRule.java | 4 +-- .../security/ApexDangerousMethodsRule.java | 3 +- .../security/ApexInsecureEndpointRule.java | 3 +- .../rule/security/ApexOpenRedirectRule.java | 3 +- .../rule/security/ApexSOQLInjectionRule.java | 3 +- .../security/ApexSharingViolationsRule.java | 3 +- .../ApexSuggestUsingNamedCredRule.java | 3 +- .../security/ApexXSSFromEscapeFalseRule.java | 3 +- .../security/ApexXSSFromURLParamRule.java | 3 +- .../rule/style/AvoidGlobalModifierRule.java | 4 +-- .../rule/style/AvoidLogicInTriggerRule.java | 3 +- .../style/ClassNamingConventionsRule.java | 4 +-- .../style/MethodNamingConventionsRule.java | 4 +-- ...ethodWithSameNameAsEnclosingClassRule.java | 3 +- .../style/VariableNamingConventionsRule.java | 3 +- .../pmd/AbstractPropertySource.java | 36 +++++++++++++++++-- .../net/sourceforge/pmd/PropertySource.java | 35 +++++++++++++++++- .../pmd/lang/rule/AbstractDelegateRule.java | 20 +++++++++++ .../pmd/lang/rule/RuleReference.java | 5 +++ .../pmd/properties/PropertyAccessorTest.java | 2 +- 35 files changed, 124 insertions(+), 78 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/apexunit/AbstractApexUnitTestRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/apexunit/AbstractApexUnitTestRule.java index d4bb22d466..d74b34ef04 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/apexunit/AbstractApexUnitTestRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/apexunit/AbstractApexUnitTestRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.apexunit; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTModifierNode; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ApexNode; @@ -21,7 +19,7 @@ import apex.jorje.services.Version; public abstract class AbstractApexUnitTestRule extends AbstractApexRule { public AbstractApexUnitTestRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Bug Risk")); + setProperty(CODECLIMATE_CATEGORIES, "Bug Risk"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AbstractNcssCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AbstractNcssCountRule.java index 9f6b69386c..e1bcf2b59a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AbstractNcssCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AbstractNcssCountRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTBreakStatement; import net.sourceforge.pmd.lang.apex.ast.ASTContinueStatement; import net.sourceforge.pmd.lang.apex.ast.ASTDoLoopStatement; @@ -45,7 +43,7 @@ public abstract class AbstractNcssCountRule extends AbstractStatisticalApexRule this.nodeClass = nodeClass; setProperty(MINIMUM_DESCRIPTOR, 1000d); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AvoidDeeplyNestedIfStmtsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AvoidDeeplyNestedIfStmtsRule.java index 758080f9d3..46635ff6f4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AvoidDeeplyNestedIfStmtsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AvoidDeeplyNestedIfStmtsRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTIfBlockStatement; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; @@ -22,7 +20,7 @@ public class AvoidDeeplyNestedIfStmtsRule extends AbstractApexRule { public AvoidDeeplyNestedIfStmtsRule() { definePropertyDescriptor(PROBLEM_DEPTH_DESCRIPTOR); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); // Note: Remedy needs better OO design and therefore high effort setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 200); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveClassLengthRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveClassLengthRule.java index c4addbf62d..66961ef534 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveClassLengthRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveClassLengthRule.java @@ -6,8 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; import static apex.jorje.semantic.symbol.type.AnnotationTypeInfos.IS_TEST; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; /** @@ -19,7 +17,7 @@ public class ExcessiveClassLengthRule extends ExcessiveLengthRule { super(ASTUserClass.class); setProperty(MINIMUM_DESCRIPTOR, 1000d); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 150); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveParameterListRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveParameterListRule.java index 192cea0aeb..08f6abd87b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveParameterListRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveParameterListRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.lang.apex.ast.ASTParameter; import net.sourceforge.pmd.util.NumericConstants; @@ -19,7 +17,7 @@ public class ExcessiveParameterListRule extends ExcessiveNodeCountRule { public ExcessiveParameterListRule() { super(ASTMethod.class); setProperty(MINIMUM_DESCRIPTOR, 4d); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 50); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessivePublicCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessivePublicCountRule.java index 5f0406bf78..1da2781e3e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessivePublicCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessivePublicCountRule.java @@ -7,8 +7,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.PUBLIC; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.STATIC; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclarationStatements; import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; @@ -33,7 +31,7 @@ public class ExcessivePublicCountRule extends ExcessiveNodeCountRule { public ExcessivePublicCountRule() { super(ASTUserClass.class); setProperty(MINIMUM_DESCRIPTOR, 20d); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 150); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssConstructorCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssConstructorCountRule.java index 9536f5729b..912e7688b9 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssConstructorCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssConstructorCountRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.stat.DataPoint; import net.sourceforge.pmd.util.NumericConstants; @@ -23,7 +21,7 @@ public class NcssConstructorCountRule extends AbstractNcssCountRule { public NcssConstructorCountRule() { super(ASTMethod.class); setProperty(MINIMUM_DESCRIPTOR, 20d); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 50); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssMethodCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssMethodCountRule.java index b0606c53ef..19a3261ee3 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssMethodCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssMethodCountRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.stat.DataPoint; import net.sourceforge.pmd.util.NumericConstants; @@ -23,7 +21,7 @@ public class NcssMethodCountRule extends AbstractNcssCountRule { public NcssMethodCountRule() { super(ASTMethod.class); setProperty(MINIMUM_DESCRIPTOR, 40d); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 50); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssTypeCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssTypeCountRule.java index 671d6df53e..1d1fb9489e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssTypeCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssTypeCountRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclaration; import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; @@ -28,7 +26,7 @@ public class NcssTypeCountRule extends AbstractNcssCountRule { public NcssTypeCountRule() { super(ASTUserClass.class); setProperty(MINIMUM_DESCRIPTOR, 500d); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 250); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java index 9428990be3..bc50c96bf1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; -import java.util.Arrays; import java.util.Stack; import net.sourceforge.pmd.lang.apex.ast.ASTBooleanExpression; @@ -79,7 +78,7 @@ public class StdCyclomaticComplexityRule extends AbstractApexRule { definePropertyDescriptor(SHOW_CLASSES_COMPLEXITY_DESCRIPTOR); definePropertyDescriptor(SHOW_METHODS_COMPLEXITY_DESCRIPTOR); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 250); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/TooManyFieldsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/TooManyFieldsRule.java index fa5fca8883..dc0db3c886 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/TooManyFieldsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/TooManyFieldsRule.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.apex.rule.complexity; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.FINAL; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.STATIC; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,7 +31,7 @@ public class TooManyFieldsRule extends AbstractApexRule { public TooManyFieldsRule() { definePropertyDescriptor(MAX_FIELDS_DESCRIPTOR); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Complexity")); + setProperty(CODECLIMATE_CATEGORIES, "Complexity"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 200); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsRule.java index cdeaf0ef25..ff7649ab97 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTDmlDeleteStatement; import net.sourceforge.pmd.lang.apex.ast.ASTDmlInsertStatement; import net.sourceforge.pmd.lang.apex.ast.ASTDmlMergeStatement; @@ -23,7 +21,7 @@ import net.sourceforge.pmd.lang.ast.Node; public class AvoidDmlStatementsInLoopsRule extends AbstractApexRule { public AvoidDmlStatementsInLoopsRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Performance")); + setProperty(CODECLIMATE_CATEGORIES, "Performance"); // Note: Often more complicated as just moving the SOQL a few lines. // Involves Maps... setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 150); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsRule.java index 345bcae677..e6dbb26cd7 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTDoLoopStatement; import net.sourceforge.pmd.lang.apex.ast.ASTForEachStatement; import net.sourceforge.pmd.lang.apex.ast.ASTForLoopStatement; @@ -18,7 +16,7 @@ import net.sourceforge.pmd.lang.ast.Node; public class AvoidSoqlInLoopsRule extends AbstractApexRule { public AvoidSoqlInLoopsRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Performance")); + setProperty(CODECLIMATE_CATEGORIES, "Performance"); // Note: Often more complicated as just moving the SOQL a few lines. // Involves Maps... setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 150); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java index deffa03d2d..942cf25e25 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -35,7 +34,7 @@ public class ApexBadCryptoRule extends AbstractApexRule { private final Set potentiallyStaticBlob = new HashSet<>(); public ApexBadCryptoRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java index c715e5db57..959e11fb0a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java @@ -90,7 +90,7 @@ public class ApexCRUDViolationRule extends AbstractApexRule { private static final String[] RESERVED_KEYS_FLS = new String[] { "Schema", S_OBJECT_TYPE, }; public ApexCRUDViolationRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCSRFRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCSRFRule.java index 7c55adf594..d4aff9c94d 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCSRFRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCSRFRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ApexNode; @@ -22,7 +20,7 @@ public class ApexCSRFRule extends AbstractApexRule { public static final String INIT = "init"; public ApexCSRFRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java index d80b21de92..c3726a8b89 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.regex.Pattern; @@ -40,7 +39,7 @@ public class ApexDangerousMethodsRule extends AbstractApexRule { public ApexDangerousMethodsRule() { super.addRuleChainVisit(ASTUserClass.class); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java index b8819f35e2..847c6ce4cd 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.regex.Pattern; @@ -33,7 +32,7 @@ public class ApexInsecureEndpointRule extends AbstractApexRule { private final Set httpEndpointStrings = new HashSet<>(); public ApexInsecureEndpointRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java index 0c23b3a7f4..7a3e25e35b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java @@ -5,7 +5,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import java.lang.reflect.Field; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -38,7 +37,7 @@ public class ApexOpenRedirectRule extends AbstractApexRule { public ApexOpenRedirectRule() { super.addRuleChainVisit(ASTUserClass.class); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java index 01365fa4e2..94a46f3211 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -50,7 +49,7 @@ public class ApexSOQLInjectionRule extends AbstractApexRule { private final HashMap selectContainingVariables = new HashMap<>(); public ApexSOQLInjectionRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java index c2ff1787db..824c80e651 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.List; import java.util.WeakHashMap; @@ -27,7 +26,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule { private WeakHashMap, Object> localCacheOfReportedNodes = new WeakHashMap<>(); public ApexSharingViolationsRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java index c8124e8f37..234a023d16 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -35,7 +34,7 @@ public class ApexSuggestUsingNamedCredRule extends AbstractApexRule { public ApexSuggestUsingNamedCredRule() { super.addRuleChainVisit(ASTUserClass.class); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java index 748d97e552..e17db570b0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.List; import net.sourceforge.pmd.lang.apex.ast.ASTLiteralExpression; @@ -23,7 +22,7 @@ public class ApexXSSFromEscapeFalseRule extends AbstractApexRule { private static final String ADD_ERROR = "addError"; public ApexXSSFromEscapeFalseRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java index e96dc6b1a7..73db6e6111 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -51,7 +50,7 @@ public class ApexXSSFromURLParamRule extends AbstractApexRule { private final Set urlParameterStrings = new HashSet<>(); public ApexXSSFromURLParamRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Security")); + setProperty(CODECLIMATE_CATEGORIES, "Security"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 50); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidGlobalModifierRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidGlobalModifierRule.java index 742a8c140a..46045bd497 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidGlobalModifierRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidGlobalModifierRule.java @@ -6,8 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.style; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.GLOBAL; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTModifierNode; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ASTUserInterface; @@ -17,7 +15,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; public class AvoidGlobalModifierRule extends AbstractApexRule { public AvoidGlobalModifierRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Style")); + setProperty(CODECLIMATE_CATEGORIES, "Style"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidLogicInTriggerRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidLogicInTriggerRule.java index f6d871acbf..c282ca9e68 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidLogicInTriggerRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidLogicInTriggerRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.style; -import java.util.Arrays; import java.util.List; import net.sourceforge.pmd.lang.apex.ast.ASTBlockStatement; @@ -14,7 +13,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; public class AvoidLogicInTriggerRule extends AbstractApexRule { public AvoidLogicInTriggerRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Style")); + setProperty(CODECLIMATE_CATEGORIES, "Style"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 200); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/ClassNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/ClassNamingConventionsRule.java index 6d9554559b..8a9a1dfaa3 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/ClassNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/ClassNamingConventionsRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.style; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ASTUserInterface; import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; @@ -13,7 +11,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; public class ClassNamingConventionsRule extends AbstractApexRule { public ClassNamingConventionsRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Style")); + setProperty(CODECLIMATE_CATEGORIES, "Style"); // Note: x10 as Apex has not automatic refactoring setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 5); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodNamingConventionsRule.java index 301d5be2c9..1d251a6fdf 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodNamingConventionsRule.java @@ -6,8 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.style; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.OVERRIDE; -import java.util.Arrays; - import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.lang.apex.ast.ASTProperty; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; @@ -16,7 +14,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; public class MethodNamingConventionsRule extends AbstractApexRule { public MethodNamingConventionsRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Style")); + setProperty(CODECLIMATE_CATEGORIES, "Style"); // Note: x10 as Apex has not automatic refactoring setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 1); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodWithSameNameAsEnclosingClassRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodWithSameNameAsEnclosingClassRule.java index 177299ac01..1cbc197aac 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodWithSameNameAsEnclosingClassRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodWithSameNameAsEnclosingClassRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.style; -import java.util.Arrays; import java.util.List; import net.sourceforge.pmd.lang.apex.ast.ASTMethod; @@ -14,7 +13,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; public class MethodWithSameNameAsEnclosingClassRule extends AbstractApexRule { public MethodWithSameNameAsEnclosingClassRule() { - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Style")); + setProperty(CODECLIMATE_CATEGORIES, "Style"); // Note: x10 as Apex has not automatic refactoring setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 50); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/VariableNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/VariableNamingConventionsRule.java index 911f288bb9..daef74e51e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/VariableNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/VariableNamingConventionsRule.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.apex.rule.style; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.FINAL; import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.STATIC; -import java.util.Arrays; import java.util.List; import net.sourceforge.pmd.PropertyDescriptor; @@ -81,7 +80,7 @@ public class VariableNamingConventionsRule extends AbstractApexRule { definePropertyDescriptor(PARAMETER_PREFIXES_DESCRIPTOR); definePropertyDescriptor(PARAMETER_SUFFIXES_DESCRIPTOR); - setProperty(CODECLIMATE_CATEGORIES, Arrays.asList("Style")); + setProperty(CODECLIMATE_CATEGORIES, "Style"); // Note: x10 as Apex has not automatic refactoring setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 5); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java index c371492e1a..b6b297e3b8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -122,14 +123,45 @@ public abstract class AbstractPropertySource implements PropertySource { @Override public void setProperty(PropertyDescriptor propertyDescriptor, T value) { checkValidPropertyDescriptor(propertyDescriptor); - propertyValuesByDescriptor.put(propertyDescriptor, value); + if (value instanceof List) { + propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList((List) value)); + + } else { + propertyValuesByDescriptor.put(propertyDescriptor, value); + } } + @Override + public void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value) { + checkValidPropertyDescriptor(propertyDescriptor); + propertyValuesByDescriptor.put(propertyDescriptor, Collections.singletonList(value)); + } + + + @Override + public void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value1, V value2) { + checkValidPropertyDescriptor(propertyDescriptor); + propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList(Arrays.asList(value1, value2))); + } + + + @Override + public void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value1, V value2, V... values) { + checkValidPropertyDescriptor(propertyDescriptor); + propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList(Arrays.asList(value1, value2, values))); + } + + + /** + * Checks whether this property descriptor is defined for this property source. + * + * @param propertyDescriptor The property descriptor to check + */ private void checkValidPropertyDescriptor(PropertyDescriptor propertyDescriptor) { if (!propertyDescriptors.contains(propertyDescriptor)) { throw new IllegalArgumentException( - "Property descriptor not defined for Rule " + getName() + ": " + propertyDescriptor); + "Property descriptor not defined for Rule " + getName() + ": " + propertyDescriptor); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java index e208f8a8e7..836d26b328 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java @@ -46,7 +46,7 @@ public interface PropertySource { /** - * Get the typed value for the given property. + * Get the typed value for the given property. Multi valued properties return immutable lists. * * @param The underlying type of the property descriptor. * @param propertyDescriptor The property descriptor. @@ -66,6 +66,39 @@ public interface PropertySource { void setProperty(PropertyDescriptor propertyDescriptor, T value); + /** + * Sets the value of a multi value property descriptor with only one argument. + * + * @param propertyDescriptor The property descriptor for which to add a value + * @param value Value + * @param The type of the values + */ + void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value); + + + /** + * Sets the value of a multi value property descriptor with two arguments. + * + * @param propertyDescriptor The property descriptor for which to add a value + * @param value1 First value + * @param value2 Second value + * @param The type of the values + */ + void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value1, V value2); + + + /** + * Sets the value of a multi value property descriptor with a variable number of arguments. + * + * @param propertyDescriptor The property descriptor for which to add a value + * @param value1 First value + * @param value2 Second value + * @param values Rest of the values + * @param The type of the values + */ + void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value1, V value2, V... values); + + /** * Returns all the current property values for the receiver or an immutable * empty map if none are specified. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java index 0e346113b4..78727fc8d4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.pmd.MultiValuePropertyDescriptor; import net.sourceforge.pmd.PropertyDescriptor; import net.sourceforge.pmd.PropertySource; import net.sourceforge.pmd.Rule; @@ -206,6 +207,25 @@ public abstract class AbstractDelegateRule implements Rule { rule.setProperty(propertyDescriptor, value); } + + @Override + public void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value) { + rule.setProperty(propertyDescriptor, value); + } + + + @Override + public void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value1, V value2) { + rule.setProperty(propertyDescriptor, value1, value2); + } + + + @Override + public void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V value1, V value2, V... values) { + rule.setProperty(propertyDescriptor, value1, value2, values); + } + + @Override public Map, Object> getPropertiesByPropertyDescriptor() { return rule.getPropertiesByPropertyDescriptor(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java index c378022373..6a79e157f3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java @@ -252,6 +252,11 @@ public class RuleReference extends AbstractDelegateRule { } } + + + + + public RuleSetReference getRuleSetReference() { return ruleSetReference; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java index 685705d0af..338e37eaf4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java @@ -78,7 +78,7 @@ public class PropertyAccessorTest { rule.setProperty(NonRuleWithAllPropertyTypes.SINGLE_STR, "brian"); assertEquals(rule.getProperty(NonRuleWithAllPropertyTypes.SINGLE_STR), "brian"); - rule.setProperty(NonRuleWithAllPropertyTypes.MULTI_STR, Arrays.asList("hello", "world")); + rule.setProperty(NonRuleWithAllPropertyTypes.MULTI_STR, "hello", "world"); assertEquals(rule.getProperty(NonRuleWithAllPropertyTypes.MULTI_STR), Arrays.asList("hello", "world")); }