Update documentation

TRAVIS_JOB_NUMBER=6022.2
TRAVIS_COMMIT_RANGE=2f4079ed8f3c...47d3e1b9f983
This commit is contained in:
Travis CI (pmd-bot)
2020-10-22 20:48:29 +00:00
parent ea619607d8
commit 6c67fa988c
5 changed files with 135 additions and 7 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>Thu, 22 Oct 2020 14:44:13 +0000</pubDate>
<lastBuildDate>Thu, 22 Oct 2020 14:44:13 +0000</lastBuildDate>
<pubDate>Thu, 22 Oct 2020 20:45:56 +0000</pubDate>
<lastBuildDate>Thu, 22 Oct 2020 20:45:56 +0000</lastBuildDate>
<generator>Jekyll v3.9.0</generator>
</channel>

View File

@@ -1411,6 +1411,15 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<h3 id="new-and-noteworthy">New and noteworthy</h3>
<h4 id="new-rules">New Rules</h4>
<ul>
<li>The new Apex rule <a href="pmd_rules_apex_performance.html#operationwithlimitsinloop"><code class="language-plaintext highlighter-rouge">OperationWithLimitsInLoop</code></a> (<code class="language-plaintext highlighter-rouge">apex-performance</code>)
finds operations in loops that may hit governor limits such as DML operations, SOQL
queries and more. The rule replaces the three rules “AvoidDmlStatementsInLoops”, “AvoidSoqlInLoops”,
and “AvoidSoslInLoops”.</li>
</ul>
<h4 id="renamed-rules">Renamed Rules</h4>
<ul>
@@ -1420,9 +1429,24 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
the Java VM, which is bad, if the VM runs an application server which many independent applications.</li>
</ul>
<h4 id="deprecated-rules">Deprecated Rules</h4>
<ul>
<li>The Apex rules <a href="pmd_rules_apex_performance.html#avoiddmlstatementsinloops"><code class="language-plaintext highlighter-rouge">AvoidDmlStatementsInLoops</code></a>,
<a href="pmd_rules_apex_performance.html#avoidsoqlinloops"><code class="language-plaintext highlighter-rouge">AvoidSoqlInLoops</code></a> and <a href="pmd_rules_apex_performance.html#avoidsoslinloops"><code class="language-plaintext highlighter-rouge">AvoidSoslInLoops</code></a>
(<code class="language-plaintext highlighter-rouge">apex-performance</code>) are deprecated in favour of the new rule
<a href="pmd_rules_apex_performance.html#operationwithlimitsinloop"><code class="language-plaintext highlighter-rouge">OperationWithLimitsInLoop</code></a>. The deprecated rules will be removed
with PMD 7.0.0.</li>
</ul>
<h3 id="fixed-issues">Fixed Issues</h3>
<ul>
<li>apex-performance
<ul>
<li><a href="https://github.com/pmd/pmd/issues/1713">#1713</a>: [apex] Mark Database DML statements in For Loop</li>
</ul>
</li>
<li>core
<ul>
<li><a href="https://github.com/pmd/pmd/pull/2831">#2831</a>: [core] Fix XMLRenderer newlines when running under IBM Java</li>
@@ -1456,6 +1480,7 @@ the Java VM, which is bad, if the VM runs an application server which many indep
<li><a href="https://github.com/pmd/pmd/pull/2810">#2810</a>: [core] Move method “renderTempFile” to XMLRendererTest - <a href="https://github.com/stefanbirkner">Stefan Birkner</a></li>
<li><a href="https://github.com/pmd/pmd/pull/2811">#2811</a>: [java] CloseResource - Fix #2764: False-negative when re-assigning variable - <a href="https://github.com/andipabst">Andi Pabst</a></li>
<li><a href="https://github.com/pmd/pmd/pull/2813">#2813</a>: [core] Use JUnits TemporaryFolder rule - <a href="https://github.com/stefanbirkner">Stefan Birkner</a></li>
<li><a href="https://github.com/pmd/pmd/pull/2816">#2816</a>: [apex] Detect Database method invocations inside loops - <a href="https://github.com/jbartolotta-sfdc">Jeff Bartolotta</a></li>
<li><a href="https://github.com/pmd/pmd/pull/2829">#2829</a>: [doc] Small correction in pmd_report_formats.md - <a href="https://github.com/gustavopcassol">Gustavo Krieger</a></li>
<li><a href="https://github.com/pmd/pmd/pull/2834">#2834</a>: [vf] Allow attributes with dot in Visualforce - <a href="https://github.com/rmohan20">rmohan20</a></li>
<li><a href="https://github.com/pmd/pmd/pull/2842">#2842</a>: [core] Bump antlr4 from 4.7 to 4.7.2 - <a href="https://github.com/alecharp">Adrien Lecharpentier</a></li>

View File

@@ -1490,9 +1490,10 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<div class="bs-callout bs-callout-">Rules that flag suboptimal code.</div>
<ul>
<li><a href="pmd_rules_apex_performance.html#avoiddmlstatementsinloops">AvoidDmlStatementsInLoops</a>: Avoid DML statements inside loops to avoid hitting the DML governor limit. Instead, try to batch …</li>
<li><a href="pmd_rules_apex_performance.html#avoidsoqlinloops">AvoidSoqlInLoops</a>: New objects created within loops should be checked to see if they can created outside them and re…</li>
<li><a href="pmd_rules_apex_performance.html#avoidsoslinloops">AvoidSoslInLoops</a>: Sosl calls within loops can cause governor limit exceptions.</li>
<li><a href="pmd_rules_apex_performance.html#avoiddmlstatementsinloops">AvoidDmlStatementsInLoops</a>: <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> Avoid DML statements inside loops to avoid hitting the DML governor limit. Instead, try to batch …</li>
<li><a href="pmd_rules_apex_performance.html#avoidsoqlinloops">AvoidSoqlInLoops</a>: <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> New objects created within loops should be checked to see if they can created outside them and re…</li>
<li><a href="pmd_rules_apex_performance.html#avoidsoslinloops">AvoidSoslInLoops</a>: <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> Sosl calls within loops can cause governor limit exceptions. This rule is deprecated and will be …</li>
<li><a href="pmd_rules_apex_performance.html#operationwithlimitsinloop">OperationWithLimitsInLoop</a>: Database class methods, DML operations, SOQL queries, or SOSL queries within loops can cause gove…</li>
</ul>
<h2 id="security">Security</h2>
@@ -1586,7 +1587,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_errorprone.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>
<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_errorprone.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_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_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_performance.html#operationwithlimitsinloop">OperationWithLimitsInLoop</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="language-plaintext 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 that flag suboptimal code.">
<meta name="keywords" content=" Performance, AvoidDmlStatementsInLoops, AvoidSoqlInLoops, AvoidSoslInLoops">
<meta name="keywords" content=" Performance, AvoidDmlStatementsInLoops, AvoidSoqlInLoops, AvoidSoslInLoops, OperationWithLimitsInLoop">
<title>Performance | PMD Source Code Analyzer</title>
<link rel="stylesheet" href="css/syntax.css">
@@ -1408,12 +1408,17 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<!-- DO NOT EDIT THIS FILE. This file is generated from file ../pmd-apex/src/main/resources/category/apex/performance.xml. -->
<h2 id="avoiddmlstatementsinloops">AvoidDmlStatementsInLoops</h2>
<p><span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span></p>
<p><strong>Since:</strong> PMD 5.5.0</p>
<p><strong>Priority:</strong> Medium (3)</p>
<p>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.</p>
<p>This rule is deprecated and will be removed with PMD 7.0.0. The rule is replaced
by the more general rule <a href="pmd_rules_apex_performance.html#operationwithlimitsinloop"><code class="language-plaintext highlighter-rouge">OperationWithLimitsInLoop</code></a>.</p>
<p><strong>This rule is defined by the following Java class:</strong> <a href="https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsRule.java">net.sourceforge.pmd.lang.apex.rule.performance.AvoidDmlStatementsInLoopsRule</a></p>
<p><strong>Example(s):</strong></p>
@@ -1468,12 +1473,17 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<h2 id="avoidsoqlinloops">AvoidSoqlInLoops</h2>
<p><span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span></p>
<p><strong>Since:</strong> PMD 5.5.0</p>
<p><strong>Priority:</strong> Medium (3)</p>
<p>New objects created within loops should be checked to see if they can created outside them and reused.</p>
<p>This rule is deprecated and will be removed with PMD 7.0.0. The rule is replaced
by the more general rule <a href="pmd_rules_apex_performance.html#operationwithlimitsinloop"><code class="language-plaintext highlighter-rouge">OperationWithLimitsInLoop</code></a>.</p>
<p><strong>This rule is defined by the following Java class:</strong> <a href="https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsRule.java">net.sourceforge.pmd.lang.apex.rule.performance.AvoidSoqlInLoopsRule</a></p>
<p><strong>Example(s):</strong></p>
@@ -1526,12 +1536,17 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<h2 id="avoidsoslinloops">AvoidSoslInLoops</h2>
<p><span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span></p>
<p><strong>Since:</strong> PMD 6.0.0</p>
<p><strong>Priority:</strong> Medium (3)</p>
<p>Sosl calls within loops can cause governor limit exceptions.</p>
<p>This rule is deprecated and will be removed with PMD 7.0.0. The rule is replaced
by the more general rule <a href="pmd_rules_apex_performance.html#operationwithlimitsinloop"><code class="language-plaintext highlighter-rouge">OperationWithLimitsInLoop</code></a>.</p>
<p><strong>This rule is defined by the following Java class:</strong> <a href="https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoslInLoopsRule.java">net.sourceforge.pmd.lang.apex.rule.performance.AvoidSoslInLoopsRule</a></p>
<p><strong>Example(s):</strong></p>
@@ -1582,6 +1597,84 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
<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/performance.xml/AvoidSoslInLoops"</span> <span class="nt">/&gt;</span>
</code></pre></div></div>
<h2 id="operationwithlimitsinloop">OperationWithLimitsInLoop</h2>
<p><strong>Since:</strong> PMD 6.29.0</p>
<p><strong>Priority:</strong> Medium (3)</p>
<p>Database class methods, DML operations, SOQL queries, or SOSL queries within loops can cause governor limit exceptions. Instead, try to batch up the data into a list and invoke the operation once on that list of data outside the loop.</p>
<p><strong>This rule is defined by the following Java class:</strong> <a href="https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopRule.java">net.sourceforge.pmd.lang.apex.rule.performance.OperationWithLimitsInLoopRule</a></p>
<p><strong>Example(s):</strong></p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Something</span> <span class="o">{</span>
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">databaseMethodInsideOfLoop</span><span class="o">(</span><span class="nc">List</span><span class="o">&lt;</span><span class="nc">Account</span><span class="o">&gt;</span> <span class="n">accounts</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nc">Account</span> <span class="n">a</span> <span class="o">:</span> <span class="n">accounts</span><span class="o">)</span> <span class="o">{</span>
<span class="nc">Database</span><span class="o">.</span><span class="na">insert</span><span class="o">(</span><span class="n">a</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">dmlInsideOfLoop</span><span class="o">()</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nc">Integer</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="mi">151</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="nc">Account</span> <span class="n">account</span><span class="o">;</span>
<span class="c1">// ...</span>
<span class="n">insert</span> <span class="n">account</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">soqlInsideOfLoop</span><span class="o">()</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nc">Integer</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="mi">10</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="nc">List</span><span class="o">&lt;</span><span class="nc">Account</span><span class="o">&gt;</span> <span class="n">accounts</span> <span class="o">=</span> <span class="o">[</span><span class="no">SELECT</span> <span class="nc">Id</span> <span class="no">FROM</span> <span class="nc">Account</span><span class="o">];</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">soslInsideOfLoop</span><span class="o">()</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nc">Integer</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="mi">10</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="nc">List</span><span class="o">&lt;</span><span class="nc">List</span><span class="o">&lt;</span><span class="nc">SObject</span><span class="o">&gt;&gt;</span> <span class="n">searchList</span> <span class="o">=</span> <span class="o">[</span><span class="no">FIND</span> <span class="err">'</span><span class="n">map</span><span class="o">*</span><span class="err">'</span> <span class="no">IN</span> <span class="no">ALL</span> <span class="no">FIELDS</span> <span class="no">RETURNING</span> <span class="nf">Account</span> <span class="o">(</span><span class="nc">Id</span><span class="o">,</span> <span class="nc">Name</span><span class="o">),</span> <span class="nc">Contact</span><span class="o">,</span> <span class="nc">Opportunity</span><span class="o">,</span> <span class="nc">Lead</span><span class="o">];</span>
<span class="o">}</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>Performance</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>150</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>
</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/performance.xml/OperationWithLimitsInLoop"</span> <span class="nt">/&gt;</span>
</code></pre></div></div>
<div class="tags">

View File

@@ -4801,6 +4801,15 @@
"url": "pmd_rules_apex_performance.html#avoidsoslinloops",
"summary": "Rules that flag suboptimal code."
}
,
{
"title": "OperationWithLimitsInLoop (Apex, Performance)",
"tags": "",
"keywords": "OperationWithLimitsInLoop",
"url": "pmd_rules_apex_performance.html#operationwithlimitsinloop",
"summary": "Rules that flag suboptimal code."
}