Update documentation

TRAVIS_JOB_NUMBER=4194.2
TRAVIS_COMMIT_RANGE=8ac3a10020aa...9eaffbd3e612
This commit is contained in:
Travis CI (pmd-bot)
2019-09-14 15:28:26 +00:00
parent 267d9338a2
commit daa9ee57fd
5 changed files with 104 additions and 6 deletions

View File

@ -5,8 +5,8 @@
<description>Intended as a documentation theme based on Jekyll for technical writers documenting software and other technical products, this theme has all the elements you would need to handle multiple products with both multi-level sidebar navigation, tags, and other documentation features.</description>
<link>https://pmd.github.io/pmd/</link>
<atom:link href="https://pmd.github.io/pmd/feed.xml" rel="self" type="application/rss+xml"/>
<pubDate>Sat, 14 Sep 2019 00:11:39 +0000</pubDate>
<lastBuildDate>Sat, 14 Sep 2019 00:11:39 +0000</lastBuildDate>
<pubDate>Sat, 14 Sep 2019 15:27:19 +0000</pubDate>
<lastBuildDate>Sat, 14 Sep 2019 15:27:19 +0000</lastBuildDate>
<generator>Jekyll v3.7.4</generator>
</channel>

View File

@ -1328,11 +1328,18 @@ about the usage and features of the rule designer.</p>
<h4 id="new-rules">New rules</h4>
<ul>
<li>The Java rule <a href="pmd_rules_java_bestpractices.html#avoidmessagedigestfield"><code class="highlighter-rouge">AvoidMessageDigestField</code></a> (<code class="highlighter-rouge">java-bestpractices</code>) detects fields
<li>
<p>The Java rule <a href="pmd_rules_java_bestpractices.html#avoidmessagedigestfield"><code class="highlighter-rouge">AvoidMessageDigestField</code></a> (<code class="highlighter-rouge">java-bestpractices</code>) detects fields
of the type <code class="highlighter-rouge">java.security.MessageDigest</code>. 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 javas quickstart ruleset.</li>
a new instance should be created when needed. This rule is also active when using javas quickstart ruleset.</p>
</li>
<li>
<p>The Apex rule <a href="pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel"><code class="highlighter-rouge">DebugsShouldUseLoggingLevel</code></a> (<code class="highlighter-rouge">apex-bestpractices</code>) detects
usages of <code class="highlighter-rouge">System.debug()</code> method calls that are used without specifying the log level. Having the log
level specified provides a cleaner log, and improves readability of it.</p>
</li>
</ul>
<h4 id="modified-rules">Modified Rules</h4>
@ -1359,6 +1366,7 @@ wont be found by default by the rule anymore.</li>
<li>apex
<ul>
<li><a href="https://github.com/pmd/pmd/issues/1901">#1901</a>: [apex] Expose super type name of UserClass</li>
<li><a href="https://github.com/pmd/pmd/issues/1942">#1942</a>: [apex] Add best practice rule for debug statements in Apex</li>
</ul>
</li>
<li>java
@ -1458,6 +1466,7 @@ subpackages, except <a href="https://javadoc.io/page/net.sourceforge.pmd/pmd-jav
<h3 id="external-contributions">External Contributions</h3>
<ul>
<li><a href="https://github.com/pmd/pmd/pull/1943">#1943</a>: [apex] Adds “debug should use logging level” best practice rule for Apex - <a href="https://github.com/renatoliveira">Renato Oliveira</a></li>
<li><a href="https://github.com/pmd/pmd/pull/1965">#1965</a>: [scala] Use Scalameta for parsing - <a href="https://github.com/tophersmith">Chris Smith</a></li>
<li><a href="https://github.com/pmd/pmd/pull/1970">#1970</a>: [java] DoubleBraceInitialization: Fix example - <a href="https://github.com/tweimer">Tobias Weimer</a></li>
<li><a href="https://github.com/pmd/pmd/pull/1971">#1971</a>: [java] 1862 - Message Digest should not be used as class field - <a href="https://github.com/AnthonyKot">AnthonyKot</a></li>

View File

@ -1298,6 +1298,7 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<li><a href="pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue">ApexUnitTestShouldNotUseSeeAllDataTrue</a>: Apex unit tests should not use @isTest(seeAllData=true) because it opens up the existing database…</li>
<li><a href="pmd_rules_apex_bestpractices.html#avoidglobalmodifier">AvoidGlobalModifier</a>: Global classes should be avoided (especially in managed packages) as they can never be deleted or…</li>
<li><a href="pmd_rules_apex_bestpractices.html#avoidlogicintrigger">AvoidLogicInTrigger</a>: As triggers do not allow methods like regular classes they are less flexible and suited to apply …</li>
<li><a href="pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel">DebugsShouldUseLoggingLevel</a>: The first parameter of System.debug, when using the signature with two parameters, is a LoggingLe…</li>
</ul>
<h2 id="code-style">Code Style</h2>
@ -1461,7 +1462,7 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<p>It contains the following rules:</p>
<p><a href="pmd_rules_apex_security.html#apexbadcrypto">ApexBadCrypto</a>, <a href="pmd_rules_apex_security.html#apexcrudviolation">ApexCRUDViolation</a>, <a href="pmd_rules_apex_security.html#apexcsrf">ApexCSRF</a>, <a href="pmd_rules_apex_security.html#apexdangerousmethods">ApexDangerousMethods</a>, <a href="pmd_rules_apex_documentation.html#apexdoc">ApexDoc</a>, <a href="pmd_rules_apex_security.html#apexinsecureendpoint">ApexInsecureEndpoint</a>, <a href="pmd_rules_apex_security.html#apexopenredirect">ApexOpenRedirect</a>, <a href="pmd_rules_apex_security.html#apexsharingviolations">ApexSharingViolations</a>, <a href="pmd_rules_apex_security.html#apexsoqlinjection">ApexSOQLInjection</a>, <a href="pmd_rules_apex_security.html#apexsuggestusingnamedcred">ApexSuggestUsingNamedCred</a>, <a href="pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaveasserts">ApexUnitTestClassShouldHaveAsserts</a>, <a href="pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue">ApexUnitTestShouldNotUseSeeAllDataTrue</a>, <a href="pmd_rules_apex_security.html#apexxssfromescapefalse">ApexXSSFromEscapeFalse</a>, <a href="pmd_rules_apex_security.html#apexxssfromurlparam">ApexXSSFromURLParam</a>, <a href="pmd_rules_apex_design.html#avoiddeeplynestedifstmts">AvoidDeeplyNestedIfStmts</a>, <a href="pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap">AvoidDirectAccessTriggerMap</a>, <a href="pmd_rules_apex_performance.html#avoiddmlstatementsinloops">AvoidDmlStatementsInLoops</a>, <a href="pmd_rules_apex_bestpractices.html#avoidglobalmodifier">AvoidGlobalModifier</a>, <a href="pmd_rules_apex_errorprone.html#avoidhardcodingid">AvoidHardcodingId</a>, <a href="pmd_rules_apex_bestpractices.html#avoidlogicintrigger">AvoidLogicInTrigger</a>, <a href="pmd_rules_apex_errorprone.html#avoidnonexistentannotations">AvoidNonExistentAnnotations</a>, <a href="pmd_rules_apex_performance.html#avoidsoqlinloops">AvoidSoqlInLoops</a>, <a href="pmd_rules_apex_performance.html#avoidsoslinloops">AvoidSoslInLoops</a>, <a href="pmd_rules_apex_codestyle.html#classnamingconventions">ClassNamingConventions</a>, <a href="pmd_rules_apex_design.html#cyclomaticcomplexity">CyclomaticComplexity</a>, <a href="pmd_rules_apex_errorprone.html#emptycatchblock">EmptyCatchBlock</a>, <a href="pmd_rules_apex_errorprone.html#emptyifstmt">EmptyIfStmt</a>, <a href="pmd_rules_apex_errorprone.html#emptystatementblock">EmptyStatementBlock</a>, <a href="pmd_rules_apex_errorprone.html#emptytryorfinallyblock">EmptyTryOrFinallyBlock</a>, <a href="pmd_rules_apex_errorprone.html#emptywhilestmt">EmptyWhileStmt</a>, <a href="pmd_rules_apex_design.html#excessiveclasslength">ExcessiveClassLength</a>, <a href="pmd_rules_apex_design.html#excessiveparameterlist">ExcessiveParameterList</a>, <a href="pmd_rules_apex_design.html#excessivepubliccount">ExcessivePublicCount</a>, <a href="pmd_rules_apex_codestyle.html#fieldnamingconventions">FieldNamingConventions</a>, <a href="pmd_rules_apex_codestyle.html#forloopsmustusebraces">ForLoopsMustUseBraces</a>, <a href="pmd_rules_apex_codestyle.html#formalparameternamingconventions">FormalParameterNamingConventions</a>, <a href="pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces">IfElseStmtsMustUseBraces</a>, <a href="pmd_rules_apex_codestyle.html#ifstmtsmustusebraces">IfStmtsMustUseBraces</a>, <a href="pmd_rules_apex_codestyle.html#localvariablenamingconventions">LocalVariableNamingConventions</a>, <a href="pmd_rules_apex_codestyle.html#methodnamingconventions">MethodNamingConventions</a>, <a href="pmd_rules_apex_errorprone.html#methodwithsamenameasenclosingclass">MethodWithSameNameAsEnclosingClass</a>, <a href="pmd_rules_apex_design.html#ncssconstructorcount">NcssConstructorCount</a>, <a href="pmd_rules_apex_design.html#ncssmethodcount">NcssMethodCount</a>, <a href="pmd_rules_apex_design.html#ncsstypecount">NcssTypeCount</a>, <a href="pmd_rules_apex_codestyle.html#onedeclarationperline">OneDeclarationPerLine</a>, <a href="pmd_rules_apex_codestyle.html#propertynamingconventions">PropertyNamingConventions</a>, <a href="pmd_rules_apex_design.html#stdcyclomaticcomplexity">StdCyclomaticComplexity</a>, <a href="pmd_rules_apex_design.html#toomanyfields">TooManyFields</a>, <a href="pmd_rules_apex_codestyle.html#whileloopsmustusebraces">WhileLoopsMustUseBraces</a></p>
<p><a href="pmd_rules_apex_security.html#apexbadcrypto">ApexBadCrypto</a>, <a href="pmd_rules_apex_security.html#apexcrudviolation">ApexCRUDViolation</a>, <a href="pmd_rules_apex_security.html#apexcsrf">ApexCSRF</a>, <a href="pmd_rules_apex_security.html#apexdangerousmethods">ApexDangerousMethods</a>, <a href="pmd_rules_apex_documentation.html#apexdoc">ApexDoc</a>, <a href="pmd_rules_apex_security.html#apexinsecureendpoint">ApexInsecureEndpoint</a>, <a href="pmd_rules_apex_security.html#apexopenredirect">ApexOpenRedirect</a>, <a href="pmd_rules_apex_security.html#apexsharingviolations">ApexSharingViolations</a>, <a href="pmd_rules_apex_security.html#apexsoqlinjection">ApexSOQLInjection</a>, <a href="pmd_rules_apex_security.html#apexsuggestusingnamedcred">ApexSuggestUsingNamedCred</a>, <a href="pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaveasserts">ApexUnitTestClassShouldHaveAsserts</a>, <a href="pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue">ApexUnitTestShouldNotUseSeeAllDataTrue</a>, <a href="pmd_rules_apex_security.html#apexxssfromescapefalse">ApexXSSFromEscapeFalse</a>, <a href="pmd_rules_apex_security.html#apexxssfromurlparam">ApexXSSFromURLParam</a>, <a href="pmd_rules_apex_design.html#avoiddeeplynestedifstmts">AvoidDeeplyNestedIfStmts</a>, <a href="pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap">AvoidDirectAccessTriggerMap</a>, <a href="pmd_rules_apex_performance.html#avoiddmlstatementsinloops">AvoidDmlStatementsInLoops</a>, <a href="pmd_rules_apex_bestpractices.html#avoidglobalmodifier">AvoidGlobalModifier</a>, <a href="pmd_rules_apex_errorprone.html#avoidhardcodingid">AvoidHardcodingId</a>, <a href="pmd_rules_apex_bestpractices.html#avoidlogicintrigger">AvoidLogicInTrigger</a>, <a href="pmd_rules_apex_errorprone.html#avoidnonexistentannotations">AvoidNonExistentAnnotations</a>, <a href="pmd_rules_apex_performance.html#avoidsoqlinloops">AvoidSoqlInLoops</a>, <a href="pmd_rules_apex_performance.html#avoidsoslinloops">AvoidSoslInLoops</a>, <a href="pmd_rules_apex_codestyle.html#classnamingconventions">ClassNamingConventions</a>, <a href="pmd_rules_apex_design.html#cyclomaticcomplexity">CyclomaticComplexity</a>, <a href="pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel">DebugsShouldUseLoggingLevel</a>, <a href="pmd_rules_apex_errorprone.html#emptycatchblock">EmptyCatchBlock</a>, <a href="pmd_rules_apex_errorprone.html#emptyifstmt">EmptyIfStmt</a>, <a href="pmd_rules_apex_errorprone.html#emptystatementblock">EmptyStatementBlock</a>, <a href="pmd_rules_apex_errorprone.html#emptytryorfinallyblock">EmptyTryOrFinallyBlock</a>, <a href="pmd_rules_apex_errorprone.html#emptywhilestmt">EmptyWhileStmt</a>, <a href="pmd_rules_apex_design.html#excessiveclasslength">ExcessiveClassLength</a>, <a href="pmd_rules_apex_design.html#excessiveparameterlist">ExcessiveParameterList</a>, <a href="pmd_rules_apex_design.html#excessivepubliccount">ExcessivePublicCount</a>, <a href="pmd_rules_apex_codestyle.html#fieldnamingconventions">FieldNamingConventions</a>, <a href="pmd_rules_apex_codestyle.html#forloopsmustusebraces">ForLoopsMustUseBraces</a>, <a href="pmd_rules_apex_codestyle.html#formalparameternamingconventions">FormalParameterNamingConventions</a>, <a href="pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces">IfElseStmtsMustUseBraces</a>, <a href="pmd_rules_apex_codestyle.html#ifstmtsmustusebraces">IfStmtsMustUseBraces</a>, <a href="pmd_rules_apex_codestyle.html#localvariablenamingconventions">LocalVariableNamingConventions</a>, <a href="pmd_rules_apex_codestyle.html#methodnamingconventions">MethodNamingConventions</a>, <a href="pmd_rules_apex_errorprone.html#methodwithsamenameasenclosingclass">MethodWithSameNameAsEnclosingClass</a>, <a href="pmd_rules_apex_design.html#ncssconstructorcount">NcssConstructorCount</a>, <a href="pmd_rules_apex_design.html#ncssmethodcount">NcssMethodCount</a>, <a href="pmd_rules_apex_design.html#ncsstypecount">NcssTypeCount</a>, <a href="pmd_rules_apex_codestyle.html#onedeclarationperline">OneDeclarationPerLine</a>, <a href="pmd_rules_apex_codestyle.html#propertynamingconventions">PropertyNamingConventions</a>, <a href="pmd_rules_apex_design.html#stdcyclomaticcomplexity">StdCyclomaticComplexity</a>, <a href="pmd_rules_apex_design.html#toomanyfields">TooManyFields</a>, <a href="pmd_rules_apex_codestyle.html#whileloopsmustusebraces">WhileLoopsMustUseBraces</a></p>
</li>
<li>
<p>Security (<code class="highlighter-rouge">rulesets/apex/security.xml</code>):</p>

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Rules which enforce generally accepted best practices.">
<meta name="keywords" content=" Best Practices, ApexAssertionsShouldIncludeMessage, ApexUnitTestClassShouldHaveAsserts, ApexUnitTestMethodShouldHaveIsTestAnnotation, ApexUnitTestShouldNotUseSeeAllDataTrue, AvoidGlobalModifier, AvoidLogicInTrigger">
<meta name="keywords" content=" Best Practices, ApexAssertionsShouldIncludeMessage, ApexUnitTestClassShouldHaveAsserts, ApexUnitTestMethodShouldHaveIsTestAnnotation, ApexUnitTestShouldNotUseSeeAllDataTrue, AvoidGlobalModifier, AvoidLogicInTrigger, DebugsShouldUseLoggingLevel">
<title>Best Practices | PMD Source Code Analyzer</title>
<link rel="stylesheet" href="css/syntax.css">
@ -1663,6 +1663,85 @@ Therefore delegate the triggers work to a regular class (often called Trigger ha
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;rule</span> <span class="na">ref=</span><span class="s">"category/apex/bestpractices.xml/AvoidLogicInTrigger"</span> <span class="nt">/&gt;</span>
</code></pre></div></div>
<h2 id="debugsshoulduselogginglevel">DebugsShouldUseLoggingLevel</h2>
<p><strong>Since:</strong> PMD 6.18.0</p>
<p><strong>Priority:</strong> Medium (3)</p>
<p>The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum.</p>
<p>Having the Logging Level specified provides a cleaner log, and improves readability of it.</p>
<p><strong>This rule is defined by the following XPath expression:</strong></p>
<div class="language-xpath highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">//</span><span class="nt">MethodCallExpression</span><span class="p">[</span><span class="nf">lower-case</span><span class="p">(</span><span class="na">@FullMethodName</span><span class="p">)</span><span class="err">=</span><span class="s1">'system.debug'</span><span class="p">][</span><span class="nf">count</span><span class="p">(</span><span class="err">*</span><span class="p">)</span><span class="err">=</span><span class="m">2</span><span class="w">
</span><span class="ow">or</span><span class="w"> </span><span class="p">(</span><span class="nv">$strictMode</span><span class="err">=</span><span class="nf">true</span><span class="p">()</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="nf">count</span><span class="p">(</span><span class="err">*</span><span class="p">)</span><span class="err">=</span><span class="m">3</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="nf">lower-case</span><span class="p">(</span><span class="nt">VariableExpression</span><span class="err">/</span><span class="na">@Image</span><span class="p">)</span><span class="err">=</span><span class="s1">'debug'</span><span class="p">)]</span><span class="w">
</span></code></pre></div></div>
<p><strong>Example(s):</strong></p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nd">@isTest</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">Foo</span> <span class="o">{</span>
<span class="nd">@isTest</span>
<span class="kd">static</span> <span class="kt">void</span> <span class="nf">bar</span><span class="o">()</span> <span class="o">{</span>
<span class="n">System</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="err">'</span><span class="n">Hey</span> <span class="k">this</span> <span class="n">code</span> <span class="n">executed</span><span class="o">.</span><span class="err">'</span><span class="o">);</span> <span class="c1">// not good</span>
<span class="n">System</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="n">LoggingLevel</span><span class="o">.</span><span class="na">WARN</span><span class="o">,</span> <span class="err">'</span><span class="n">Hey</span><span class="o">,</span> <span class="n">something</span> <span class="n">might</span> <span class="n">be</span> <span class="n">wrong</span><span class="o">.</span><span class="err">'</span><span class="o">);</span> <span class="c1">// good</span>
<span class="n">System</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="n">LoggingLevel</span><span class="o">.</span><span class="na">DEBUG</span><span class="o">,</span> <span class="err">'</span><span class="n">Hey</span><span class="o">,</span> <span class="n">something</span> <span class="n">happened</span><span class="o">.</span><span class="err">'</span><span class="o">);</span> <span class="c1">// not good when on strict mode</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div></div>
<p><strong>This rule has the following properties:</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Default Value</th>
<th>Description</th>
<th>Multivalued</th>
</tr>
</thead>
<tbody>
<tr>
<td>cc_categories</td>
<td>Style</td>
<td><span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Code Climate Categories</td>
<td>yes. Delimiter is |.</td>
</tr>
<tr>
<td>cc_remediation_points_multiplier</td>
<td>1</td>
<td><span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Code Climate Remediation Points multiplier</td>
<td>no</td>
</tr>
<tr>
<td>cc_block_highlighting</td>
<td>false</td>
<td><span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Code Climate Block Highlighting</td>
<td>no</td>
</tr>
<tr>
<td>strictMode</td>
<td>false</td>
<td>If true, mark statements that use the DEBUG enum of LoggingLevel.</td>
<td>no</td>
</tr>
</tbody>
</table>
<p><strong>Use this rule with the default properties by just referencing it:</strong></p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;rule</span> <span class="na">ref=</span><span class="s">"category/apex/bestpractices.xml/DebugsShouldUseLoggingLevel"</span> <span class="nt">/&gt;</span>
</code></pre></div></div>
<p><strong>Use this rule and customize it:</strong></p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;rule</span> <span class="na">ref=</span><span class="s">"category/apex/bestpractices.xml/DebugsShouldUseLoggingLevel"</span><span class="nt">&gt;</span>
<span class="nt">&lt;properties&gt;</span>
<span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">"strictMode"</span> <span class="na">value=</span><span class="s">"false"</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;/properties&gt;</span>
<span class="nt">&lt;/rule&gt;</span>
</code></pre></div></div>
<div class="tags">

View File

@ -265,6 +265,15 @@
"url": "pmd_rules_apex_bestpractices.html#avoidlogicintrigger",
"summary": "Rules which enforce generally accepted best practices."
}
,
{
"title": "DebugsShouldUseLoggingLevel (Apex, Best Practices)",
"tags": "",
"keywords": "DebugsShouldUseLoggingLevel",
"url": "pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel",
"summary": "Rules which enforce generally accepted best practices."
}