diff --git a/feed.xml b/feed.xml
index a81cdf0a96..1907cc9d92 100644
--- a/feed.xml
+++ b/feed.xml
@@ -5,8 +5,8 @@
AvoidMessageDigestField
(java-bestpractices
) detects fields
+ The Java rule AvoidMessageDigestField
(java-bestpractices
) detects fields
of the type java.security.MessageDigest
. Using a message digest instance as a field would need to be
synchronized, as it can easily be used by multiple threads. Without synchronization the calculated hash could
be entirely wrong. Instead of declaring this as a field and synchronize access to use it from multiple threads,
-a new instance should be created when needed. This rule is also active when using java’s quickstart ruleset.
The Apex rule DebugsShouldUseLoggingLevel
(apex-bestpractices
) detects
+usages of System.debug()
method calls that are used without specifying the log level. Having the log
+level specified provides a cleaner log, and improves readability of it.
It contains the following rules:
-ApexBadCrypto, ApexCRUDViolation, ApexCSRF, ApexDangerousMethods, ApexDoc, ApexInsecureEndpoint, ApexOpenRedirect, ApexSharingViolations, ApexSOQLInjection, ApexSuggestUsingNamedCred, ApexUnitTestClassShouldHaveAsserts, ApexUnitTestShouldNotUseSeeAllDataTrue, ApexXSSFromEscapeFalse, ApexXSSFromURLParam, AvoidDeeplyNestedIfStmts, AvoidDirectAccessTriggerMap, AvoidDmlStatementsInLoops, AvoidGlobalModifier, AvoidHardcodingId, AvoidLogicInTrigger, AvoidNonExistentAnnotations, AvoidSoqlInLoops, AvoidSoslInLoops, ClassNamingConventions, CyclomaticComplexity, EmptyCatchBlock, EmptyIfStmt, EmptyStatementBlock, EmptyTryOrFinallyBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveParameterList, ExcessivePublicCount, FieldNamingConventions, ForLoopsMustUseBraces, FormalParameterNamingConventions, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LocalVariableNamingConventions, MethodNamingConventions, MethodWithSameNameAsEnclosingClass, NcssConstructorCount, NcssMethodCount, NcssTypeCount, OneDeclarationPerLine, PropertyNamingConventions, StdCyclomaticComplexity, TooManyFields, WhileLoopsMustUseBraces
+ApexBadCrypto, ApexCRUDViolation, ApexCSRF, ApexDangerousMethods, ApexDoc, ApexInsecureEndpoint, ApexOpenRedirect, ApexSharingViolations, ApexSOQLInjection, ApexSuggestUsingNamedCred, ApexUnitTestClassShouldHaveAsserts, ApexUnitTestShouldNotUseSeeAllDataTrue, ApexXSSFromEscapeFalse, ApexXSSFromURLParam, AvoidDeeplyNestedIfStmts, AvoidDirectAccessTriggerMap, AvoidDmlStatementsInLoops, AvoidGlobalModifier, AvoidHardcodingId, AvoidLogicInTrigger, AvoidNonExistentAnnotations, AvoidSoqlInLoops, AvoidSoslInLoops, ClassNamingConventions, CyclomaticComplexity, DebugsShouldUseLoggingLevel, EmptyCatchBlock, EmptyIfStmt, EmptyStatementBlock, EmptyTryOrFinallyBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveParameterList, ExcessivePublicCount, FieldNamingConventions, ForLoopsMustUseBraces, FormalParameterNamingConventions, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LocalVariableNamingConventions, MethodNamingConventions, MethodWithSameNameAsEnclosingClass, NcssConstructorCount, NcssMethodCount, NcssTypeCount, OneDeclarationPerLine, PropertyNamingConventions, StdCyclomaticComplexity, TooManyFields, WhileLoopsMustUseBraces
Security (rulesets/apex/security.xml
):
<rule ref="category/apex/bestpractices.xml/AvoidLogicInTrigger" />
Since: PMD 6.18.0
+ +Priority: Medium (3)
+ +The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum.
+ +Having the Logging Level specified provides a cleaner log, and improves readability of it.
+ +This rule is defined by the following XPath expression:
+//MethodCallExpression[lower-case(@FullMethodName)='system.debug'][count(*)=2
+ or ($strictMode=true() and count(*)=3 and lower-case(VariableExpression/@Image)='debug')]
+
Example(s):
+ +@isTest
+public class Foo {
+ @isTest
+ static void bar() {
+ System.debug('Hey this code executed.'); // not good
+ System.debug(LoggingLevel.WARN, 'Hey, something might be wrong.'); // good
+ System.debug(LoggingLevel.DEBUG, 'Hey, something happened.'); // not good when on strict mode
+ }
+}
+
This rule has the following properties:
+ +Name | +Default Value | +Description | +Multivalued | +
---|---|---|---|
cc_categories | +Style | +Deprecated Code Climate Categories | +yes. Delimiter is ‘|’. | +
cc_remediation_points_multiplier | +1 | +Deprecated Code Climate Remediation Points multiplier | +no | +
cc_block_highlighting | +false | +Deprecated Code Climate Block Highlighting | +no | +
strictMode | +false | +If true, mark statements that use the DEBUG enum of LoggingLevel. | +no | +
Use this rule with the default properties by just referencing it:
+<rule ref="category/apex/bestpractices.xml/DebugsShouldUseLoggingLevel" />
+
Use this rule and customize it:
+<rule ref="category/apex/bestpractices.xml/DebugsShouldUseLoggingLevel">
+ <properties>
+ <property name="strictMode" value="false" />
+ </properties>
+</rule>
+