[doc] [apex] Adjust externalInfoUrl properties to new site - Part 5
Note: I also took the chance to fix tab damage
This commit is contained in:
@ -20,7 +20,7 @@ import net.sourceforge.pmd.lang.apex.ast.ApexNode;
|
||||
*
|
||||
* @author a.subramanian
|
||||
*/
|
||||
public class ApexUnitTestClassShouldHaveAsserts extends AbstractApexUnitTestRule {
|
||||
public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTestRule {
|
||||
|
||||
private static final Set<String> ASSERT_METHODS = new HashSet<>();
|
||||
|
@ -25,7 +25,7 @@ import apex.jorje.services.Version;
|
||||
*
|
||||
* @author a.subramanian
|
||||
*/
|
||||
public class ApexUnitTestShouldNotUseSeeAllDataTrue extends AbstractApexUnitTestRule {
|
||||
public class ApexUnitTestShouldNotUseSeeAllDataTrueRule extends AbstractApexUnitTestRule {
|
||||
|
||||
@Override
|
||||
public Object visit(final ASTUserClass node, final Object data) {
|
@ -11,8 +11,8 @@
|
||||
<rule name="ApexUnitTestClassShouldHaveAsserts"
|
||||
since="5.5.1"
|
||||
message="Apex unit tests should System.assert() or assertEquals() or assertNotEquals()"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestClassShouldHaveAsserts"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/apexunit.html#ApexUnitTestClassShouldHaveAsserts">
|
||||
class="net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestClassShouldHaveAssertsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_apexunit.html#apexunittestclassshouldhaveasserts">
|
||||
<description>
|
||||
Apex unit tests should include at least one assertion. This makes the tests more robust, and using assert
|
||||
with messages provide the developer a clearer idea of what the test does.
|
||||
@ -35,8 +35,8 @@ public class Foo {
|
||||
<rule name="ApexUnitTestShouldNotUseSeeAllDataTrue"
|
||||
since="5.5.1"
|
||||
message="Apex unit tests should not use @isTest(seeAllData = true)"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestShouldNotUseSeeAllDataTrue"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/apexunit.html#ApexUnitTestShouldNotUseSeeAllDataTrue">
|
||||
class="net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestShouldNotUseSeeAllDataTrueRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_apexunit.html#apexunittestshouldnotuseseealldatatrue">
|
||||
<description>
|
||||
Apex unit tests should not use @isTest(seeAllData=true) because it opens up the existing database data for unexpected modification by tests.
|
||||
</description>
|
||||
|
@ -8,135 +8,133 @@
|
||||
The Braces ruleset contains rules regarding the use and placement of braces.
|
||||
</description>
|
||||
|
||||
<rule name="IfStmtsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using if statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/braces.html#IfStmtsMustUseBraces">
|
||||
<description>
|
||||
<rule name="IfStmtsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using if statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_braces.html#ifstmtsmustusebraces">
|
||||
<description>
|
||||
Avoid using if statements without using braces to surround the code block. If the code
|
||||
formatting or indentation is lost then it becomes difficult to separate the code being
|
||||
controlled from the rest.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//IfBlockStatement/BlockStatement[@CurlyBrace='false']
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
if (foo) // not recommended
|
||||
x++;
|
||||
|
||||
if (foo) // not recommended
|
||||
x++;
|
||||
|
||||
if (foo) { // preferred approach
|
||||
x++;
|
||||
if (foo) { // preferred approach
|
||||
x++;
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="WhileLoopsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using 'while' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/braces.html#WhileLoopsMustUseBraces">
|
||||
<description>
|
||||
<rule name="WhileLoopsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using 'while' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_braces.html#whileloopsmustusebraces">
|
||||
<description>
|
||||
Avoid using 'while' statements without using braces to surround the code block. If the code
|
||||
formatting or indentation is lost then it becomes difficult to separate the code being
|
||||
controlled from the rest.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//WhileLoopStatement/BlockStatement[@CurlyBrace='false']
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
while (true) // not recommended
|
||||
x++;
|
||||
while (true) // not recommended
|
||||
x++;
|
||||
|
||||
while (true) { // preferred approach
|
||||
x++;
|
||||
while (true) { // preferred approach
|
||||
x++;
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="IfElseStmtsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using 'if...else' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/braces.html#IfElseStmtsMustUseBraces">
|
||||
<description>
|
||||
<rule name="IfElseStmtsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using 'if...else' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_braces.html#ifelsestmtsmustusebraces">
|
||||
<description>
|
||||
Avoid using if..else statements without using surrounding braces. If the code formatting
|
||||
or indentation is lost then it becomes difficult to separate the code being controlled
|
||||
from the rest.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//IfBlockStatement/BlockStatement[@CurlyBrace='false'][count(child::*) > 0]
|
||||
|
|
||||
//IfElseBlockStatement/BlockStatement[@CurlyBrace='false'][count(child::*) > 0]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
// this is OK
|
||||
// this is OK
|
||||
if (foo) x++;
|
||||
|
||||
// but this is not
|
||||
// but this is not
|
||||
if (foo)
|
||||
x = x+1;
|
||||
else
|
||||
x = x-1;
|
||||
x = x+1;
|
||||
else
|
||||
x = x-1;
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="ForLoopsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using 'for' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/braces.html#ForLoopsMustUseBraces">
|
||||
<description>
|
||||
<rule name="ForLoopsMustUseBraces"
|
||||
language="apex"
|
||||
since="5.6.0"
|
||||
message="Avoid using 'for' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_braces.html#forloopsmustusebraces">
|
||||
<description>
|
||||
Avoid using 'for' statements without using surrounding braces. If the code formatting or
|
||||
indentation is lost then it becomes difficult to separate the code being controlled
|
||||
from the rest.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ForLoopStatement/BlockStatement[@CurlyBrace='false']
|
||||
|
|
||||
//ForEachStatement/BlockStatement[@CurlyBrace='false']
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
for (int i = 0; i < 42; i++) // not recommended
|
||||
foo();
|
||||
@ -145,7 +143,7 @@ for (int i = 0; i < 42; i++) { // preferred approach
|
||||
foo();
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@
|
||||
since="6.0.0"
|
||||
class="net.sourceforge.pmd.lang.apex.metrics.rule.CyclomaticComplexityRule"
|
||||
metrics="true"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/metrics.html#CyclomaticComplexity">
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_metrics.html#cyclomaticcomplexity">
|
||||
<description>
|
||||
<![CDATA[
|
||||
The complexity of methods directly affects maintenance costs and readability. Concentrating too much decisional logic
|
||||
|
@ -12,43 +12,46 @@ The Performance ruleset contains a collection of good practices which should be
|
||||
since="5.5.0"
|
||||
message="Avoid Soql queries inside loops"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.performance.AvoidSoqlInLoopsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/performance.html#AvoidSoqlInLoops">
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_performance.html#avoidsoqlinloops">
|
||||
<description>
|
||||
New objects created within loops should be checked to see if they can created outside them and reused.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[public class Something {
|
||||
public static void main( String as[] ) {
|
||||
for (Integer i = 0; i < 10; i++) {
|
||||
List<Account> accounts = [SELECT Id FROM Account];
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidDmlStatementsInLoops"
|
||||
since="5.5.0"
|
||||
message="Avoid DML statements inside loops"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.performance.AvoidDmlStatementsInLoopsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/performance.html#AvoidDmlStatementsInLoops">
|
||||
<description>Avoid DML statements inside loops to avoid hitting the DML governor limit. Instead, try to batch up the data into a list and invoke your DML once on that list of data outside the loop.</description>
|
||||
<priority>3</priority>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Something {
|
||||
public void foo() {
|
||||
for (Integer i = 0; i < 151; i++) {
|
||||
Account account;
|
||||
...
|
||||
insert account;
|
||||
}
|
||||
}
|
||||
public static void main( String as[] ) {
|
||||
for (Integer i = 0; i < 10; i++) {
|
||||
List<Account> accounts = [SELECT Id FROM Account];
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
<rule name="AvoidDmlStatementsInLoops"
|
||||
since="5.5.0"
|
||||
message="Avoid DML statements inside loops"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.performance.AvoidDmlStatementsInLoopsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_performance.html#avoiddmlstatementsinloops">
|
||||
<description>
|
||||
Avoid DML statements inside loops to avoid hitting the DML governor limit. Instead, try to batch up the data into a list and invoke your DML once on that list of data outside the loop.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Something {
|
||||
public void foo() {
|
||||
for (Integer i = 0; i < 151; i++) {
|
||||
Account account;
|
||||
// ...
|
||||
insert account;
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
|
@ -2,4 +2,10 @@
|
||||
# BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
#
|
||||
|
||||
rulesets.filenames=rulesets/apex/complexity.xml,rulesets/apex/performance.xml,rulesets/apex/style.xml,rulesets/apex/apexunit.xml,rulesets/apex/security.xml,rulesets/apex/braces.xml
|
||||
rulesets.filenames=\
|
||||
rulesets/apex/apexunit.xml,\
|
||||
rulesets/apex/braces.xml,\
|
||||
rulesets/apex/complexity.xml,\
|
||||
rulesets/apex/performance.xml,\
|
||||
rulesets/apex/security.xml,\
|
||||
rulesets/apex/style.xml
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,105 +8,110 @@
|
||||
The Style Ruleset contains rules regarding preferred usage of names and identifiers.
|
||||
</description>
|
||||
|
||||
<rule name="VariableNamingConventions"
|
||||
since="5.5.0"
|
||||
message="{0} variable {1} should begin with {2}"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.VariableNamingConventionsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/style.html#VariableNamingConventions">
|
||||
<description>
|
||||
<rule name="VariableNamingConventions"
|
||||
since="5.5.0"
|
||||
message="{0} variable {1} should begin with {2}"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.VariableNamingConventionsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_style.html#variablenamingconventions">
|
||||
<description>
|
||||
A variable naming conventions rule - customize this to your liking. Currently, it
|
||||
checks for final variables that should be fully capitalized and non-final variables
|
||||
that should not include underscores.
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<example>
|
||||
<![CDATA[public class Foo {
|
||||
public static final Integer MY_NUM = 0;
|
||||
public String myTest = '';
|
||||
DataModule dmTest = new DataModule();
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Foo {
|
||||
public static final Integer MY_NUM = 0;
|
||||
public String myTest = '';
|
||||
DataModule dmTest = new DataModule();
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="MethodNamingConventions"
|
||||
since="5.5.0"
|
||||
message="Method name does not begin with a lower case character."
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.MethodNamingConventionsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/style.html#MethodNamingConventions">
|
||||
<description>
|
||||
<rule name="MethodNamingConventions"
|
||||
since="5.5.0"
|
||||
message="Method name does not begin with a lower case character."
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.MethodNamingConventionsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_style.html#methodnamingconventions">
|
||||
<description>
|
||||
Method names should always begin with a lower case character, and should not contain underscores.
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<example>
|
||||
<![CDATA[public class Foo {
|
||||
public void fooStuff() {
|
||||
}
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Foo {
|
||||
public void fooStuff() {
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="ClassNamingConventions"
|
||||
since="5.5.0"
|
||||
message="Class names should begin with an uppercase character"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.ClassNamingConventionsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/style.html#ClassNamingConventions">
|
||||
<description>
|
||||
<rule name="ClassNamingConventions"
|
||||
since="5.5.0"
|
||||
message="Class names should begin with an uppercase character"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.ClassNamingConventionsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_style.html#classnamingconventions">
|
||||
<description>
|
||||
Class names should always begin with an upper case character.
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<example>
|
||||
<![CDATA[public class Foo {}
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Foo {}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="MethodWithSameNameAsEnclosingClass"
|
||||
since="5.5.0"
|
||||
message="Classes should not have non-constructor methods with the same name as the class"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.MethodWithSameNameAsEnclosingClassRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/style.html#MethodWithSameNameAsEnclosingClass">
|
||||
<description>
|
||||
<rule name="MethodWithSameNameAsEnclosingClass"
|
||||
since="5.5.0"
|
||||
message="Classes should not have non-constructor methods with the same name as the class"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.MethodWithSameNameAsEnclosingClassRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_style.html#methodwithsamenameasenclosingclass">
|
||||
<description>
|
||||
Non-constructor methods should not have the same name as the enclosing class.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[public class MyClass {
|
||||
// this is OK because it is a constructor
|
||||
public MyClass() {}
|
||||
// this is bad because it is a method
|
||||
public void MyClass() {}
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class MyClass {
|
||||
// this is OK because it is a constructor
|
||||
public MyClass() {}
|
||||
// this is bad because it is a method
|
||||
public void MyClass() {}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidLogicInTrigger"
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidLogicInTrigger"
|
||||
since="5.5.0"
|
||||
message="Avoid logic in triggers"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.AvoidLogicInTriggerRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/style.html#AvoidLogicInTrigger">
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_style.html#avoidlogicintrigger">
|
||||
<description>
|
||||
As triggers do not allow methods like regular classes they are less flexible and suited to apply good encapsulation style.
|
||||
Therefore delegate the triggers work to a regular class (often called Trigger handler class).
|
||||
|
||||
See more here: https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[trigger Accounts on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) {
|
||||
for(Account acc : Trigger.new) {
|
||||
if(Trigger.isInsert) {
|
||||
...
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
if(Trigger.isDelete) {
|
||||
...
|
||||
}
|
||||
}
|
||||
<![CDATA[
|
||||
trigger Accounts on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) {
|
||||
for(Account acc : Trigger.new) {
|
||||
if(Trigger.isInsert) {
|
||||
// ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
if(Trigger.isDelete) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
@ -116,17 +121,18 @@ See more here: https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex
|
||||
since="5.5.0"
|
||||
message="Avoid using global modifier"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.style.AvoidGlobalModifierRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/apex/style.html#AvoidGlobalModifier">
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_style.html#avoidglobalmodifier">
|
||||
<description>
|
||||
Global classes should be avoided (especially in managed packages) as they can never be deleted or changed in signature. Always check twice if something needs to be global.
|
||||
Many interfaces (e.g. Batch) required global modifiers in the past but don't require this anymore. Don't lock yourself in.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[global class Unchangeable {
|
||||
global UndeletableType unchangable(UndeletableType param) {
|
||||
// ...
|
||||
}
|
||||
<![CDATA[
|
||||
global class Unchangeable {
|
||||
global UndeletableType unchangable(UndeletableType param) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
|
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex;
|
||||
|
||||
import net.sourceforge.pmd.AbstractRuleSetFactoryTest;
|
||||
import net.sourceforge.pmd.lang.apex.rule.ApexXPathRule;
|
||||
|
||||
public class RuleSetFactoryTest extends AbstractRuleSetFactoryTest {
|
||||
public RuleSetFactoryTest() {
|
||||
super();
|
||||
validXPathClassNames.add(ApexXPathRule.class.getName());
|
||||
}
|
||||
}
|
@ -17,10 +17,13 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
@ -49,6 +52,12 @@ public abstract class AbstractRuleSetFactoryTest {
|
||||
private static ValidateDefaultHandler validateDefaultHandlerDtd;
|
||||
private static SAXParser saxParser;
|
||||
|
||||
protected Set<String> validXPathClassNames = new HashSet<>();
|
||||
|
||||
public AbstractRuleSetFactoryTest() {
|
||||
validXPathClassNames.add(XPathRule.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Setups the XML parser with validation.
|
||||
*
|
||||
@ -134,7 +143,7 @@ public abstract class AbstractRuleSetFactoryTest {
|
||||
String expectedClassName = "net.sourceforge.pmd.lang." + language.getTerseName() + ".rule." + group
|
||||
+ "." + rule.getName() + "Rule";
|
||||
if (!rule.getRuleClass().equals(expectedClassName)
|
||||
&& !rule.getRuleClass().equals(XPathRule.class.getName())) {
|
||||
&& !validXPathClassNames.contains(rule.getRuleClass())) {
|
||||
invalidClassName++;
|
||||
messages += "Rule " + fileName + "/" + rule.getName() + " seems to have an invalid 'class' value ("
|
||||
+ rule.getRuleClass() + "), it should be:" + expectedClassName + PMD.EOL;
|
||||
|
Reference in New Issue
Block a user