Quickstart configuration of PMD for Salesforce.com Apex. Includes the rules that are most likely to apply everywhere.

prioritymessagerefname_value
3Avoid really long classes (lines of code)category/apex/design.xml/ExcessiveClassLength
  • minimum: 1000
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 150
  • cc_block_highlighting: false
3Avoid long parameter listscategory/apex/design.xml/ExcessiveParameterList
  • minimum: 4
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 50
  • cc_block_highlighting: false
3This class has too many public methods and attributescategory/apex/design.xml/ExcessivePublicCount
  • minimum: 25
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 150
  • cc_block_highlighting: false
3The constructor has an NCSS line count of {0}category/apex/design.xml/NcssConstructorCount
  • minimum: 20
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 50
  • cc_block_highlighting: false
3The method {0}() has an NCSS line count of {1}category/apex/design.xml/NcssMethodCount
  • minimum: 60
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 50
  • cc_block_highlighting: false
3The type has an NCSS line count of {0}category/apex/design.xml/NcssTypeCount
  • minimum: 700
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 250
  • cc_block_highlighting: false
3The {0} ''{1}'' has a Standard Cyclomatic Complexity of {2}.category/apex/design.xml/StdCyclomaticComplexity
  • reportLevel: 10
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 250
  • cc_block_highlighting: false
3Too many fieldscategory/apex/design.xml/TooManyFields
  • maxfields: 20
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 200
  • cc_block_highlighting: false
3Deeply nested if..else statements are hard to readcategory/apex/design.xml/AvoidDeeplyNestedIfStmts
  • problemDepth: 4
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 200
  • cc_block_highlighting: false
3category/apex/design.xml/CyclomaticComplexity
  • cc_categories: Complexity
  • cc_remediation_points_multiplier: 200
  • cc_block_highlighting: false
3Avoid operations in loops that may hit governor limitscategory/apex/performance.xml/OperationWithLimitsInLoop
  • cc_categories: Performance
  • cc_remediation_points_multiplier: 150
  • cc_block_highlighting: false
3Avoid directly accessing Trigger.old and Trigger.newcategory/apex/errorprone.xml/AvoidDirectAccessTriggerMap
  • cc_categories: Performance
  • cc_remediation_points_multiplier: 150
  • cc_block_highlighting: false
3Avoid logic in triggerscategory/apex/bestpractices.xml/AvoidLogicInTrigger
  • cc_categories: Style
  • cc_remediation_points_multiplier: 200
  • cc_block_highlighting: false
3Avoid using global modifiercategory/apex/bestpractices.xml/AvoidGlobalModifier
  • cc_categories: Style
  • cc_remediation_points_multiplier: 100
  • cc_block_highlighting: false
category/apex/errorprone.xml/AvoidNonExistentAnnotations
  • cc_categories: Style
  • cc_remediation_points_multiplier: 100
  • cc_block_highlighting: false
3Avoid hardcoding ID'scategory/apex/errorprone.xml/AvoidHardcodingId
  • cc_categories: Security
  • cc_remediation_points_multiplier: 20
  • cc_block_highlighting: false
3Class names should begin with an uppercase charactercategory/apex/codestyle.xml/ClassNamingConventions
  • cc_categories: Style
  • cc_remediation_points_multiplier: 5
  • cc_block_highlighting: false
3Method name does not begin with a lower case character.category/apex/codestyle.xml/MethodNamingConventions
  • cc_categories: Style
  • cc_remediation_points_multiplier: 1
  • cc_block_highlighting: false
3Classes should not have non-constructor methods with the same name as the classcategory/apex/errorprone.xml/MethodWithSameNameAsEnclosingClass
  • cc_categories: Style
  • cc_remediation_points_multiplier: 50
  • cc_block_highlighting: false
3category/apex/codestyle.xml/FieldNamingConventions
  • cc_categories: Style
  • cc_remediation_points_multiplier: 5
  • cc_block_highlighting: false
3category/apex/codestyle.xml/FormalParameterNamingConventions
  • cc_categories: Style
  • cc_remediation_points_multiplier: 5
  • cc_block_highlighting: false
3category/apex/codestyle.xml/LocalVariableNamingConventions
  • cc_categories: Style
  • cc_remediation_points_multiplier: 5
  • cc_block_highlighting: false
3category/apex/codestyle.xml/PropertyNamingConventions
  • cc_categories: Style
  • cc_remediation_points_multiplier: 5
  • cc_block_highlighting: false
3Apex unit test classes should have at least one System.assert() or assertEquals() or AssertNotEquals() callcategory/apex/bestpractices.xml/ApexUnitTestClassShouldHaveAsserts
  • cc_categories: Bug Risk
  • cc_remediation_points_multiplier: 100
  • cc_block_highlighting: false
3@isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by testscategory/apex/bestpractices.xml/ApexUnitTestShouldNotUseSeeAllDataTrue
  • cc_categories: Bug Risk
  • cc_remediation_points_multiplier: 100
  • cc_block_highlighting: false
category/apex/bestpractices.xml/ApexUnitTestClassShouldHaveRunAs
    3Apex classes should declare a sharing model if DML or SOQL is usedcategory/apex/security.xml/ApexSharingViolations
    • cc_categories: Security
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Apex callouts should use encrypted communication channelscategory/apex/security.xml/ApexInsecureEndpoint
    • cc_categories: Security
    • cc_remediation_points_multiplier: 50
    • cc_block_highlighting: false
    3category/apex/errorprone.xml/ApexCSRF
    • cc_categories: Security
    • cc_remediation_points_multiplier: 100
    • cc_block_highlighting: false
    3Apex classes should safely redirect to a known locationcategory/apex/security.xml/ApexOpenRedirect
    • cc_categories: Security
    • cc_remediation_points_multiplier: 50
    • cc_block_highlighting: false
    3Apex classes should escape variables merged in DML querycategory/apex/security.xml/ApexSOQLInjection
    • cc_categories: Security
    • cc_remediation_points_multiplier: 20
    • cc_block_highlighting: false
    3Apex classes should escape Strings obtained from URL parameterscategory/apex/security.xml/ApexXSSFromURLParam
    • cc_categories: Security
    • cc_remediation_points_multiplier: 20
    • cc_block_highlighting: false
    3Apex classes should escape addError stringscategory/apex/security.xml/ApexXSSFromEscapeFalse
    • cc_categories: Security
    • cc_remediation_points_multiplier: 20
    • cc_block_highlighting: false
    3Apex Crypto should use random IV/keycategory/apex/security.xml/ApexBadCrypto
    • cc_categories: Security
    • cc_remediation_points_multiplier: 50
    • cc_block_highlighting: false
    3Validate CRUD permission before SOQL/DML operationcategory/apex/security.xml/ApexCRUDViolation
    • cc_categories: Security
    • cc_remediation_points_multiplier: 150
    • cc_block_highlighting: false
    3Calling potentially dangerous methodcategory/apex/security.xml/ApexDangerousMethods
    • cc_categories: Security
    • cc_remediation_points_multiplier: 50
    • cc_block_highlighting: false
    3Consider using named credentials for authenticated calloutscategory/apex/security.xml/ApexSuggestUsingNamedCred
    • cc_categories: Security
    • cc_remediation_points_multiplier: 20
    • cc_block_highlighting: false
    3Avoid using if statements without curly bracescategory/apex/codestyle.xml/IfStmtsMustUseBraces
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid using 'while' statements without curly bracescategory/apex/codestyle.xml/WhileLoopsMustUseBraces
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid using 'if...else' statements without curly bracescategory/apex/codestyle.xml/IfElseStmtsMustUseBraces
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid using 'for' statements without curly bracescategory/apex/codestyle.xml/ForLoopsMustUseBraces
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid empty catch blockscategory/apex/errorprone.xml/EmptyCatchBlock
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid empty 'if' statementscategory/apex/errorprone.xml/EmptyIfStmt
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid empty 'while' statementscategory/apex/errorprone.xml/EmptyWhileStmt
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid empty try or finally blockscategory/apex/errorprone.xml/EmptyTryOrFinallyBlock
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Avoid empty block statements.category/apex/errorprone.xml/EmptyStatementBlock
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3category/apex/codestyle.xml/OneDeclarationPerLine
    • cc_categories: Style
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false
    3Document classes, methods, and properties that are public or global.category/apex/documentation.xml/ApexDoc
    • cc_categories: Style
    • cc_remediation_points_multiplier: 50
    • cc_block_highlighting: false
    3category/apex/bestpractices.xml/DebugsShouldUseLoggingLevel
    • cc_categories: Clarity
    • cc_remediation_points_multiplier: 5
    • cc_block_highlighting: false