Update documentation
https://github.com/pmd/pmd/actions/runs/875813091
e69855c69d...993ae828cf
This commit is contained in:
4
feed.xml
4
feed.xml
@ -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>
|
<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>
|
<link>https://pmd.github.io/pmd/</link>
|
||||||
<atom:link href="https://pmd.github.io/pmd/feed.xml" rel="self" type="application/rss+xml"/>
|
<atom:link href="https://pmd.github.io/pmd/feed.xml" rel="self" type="application/rss+xml"/>
|
||||||
<pubDate>Tue, 25 May 2021 11:37:20 +0000</pubDate>
|
<pubDate>Tue, 25 May 2021 17:49:39 +0000</pubDate>
|
||||||
<lastBuildDate>Tue, 25 May 2021 11:37:20 +0000</lastBuildDate>
|
<lastBuildDate>Tue, 25 May 2021 17:49:39 +0000</lastBuildDate>
|
||||||
<generator>Jekyll v3.9.0</generator>
|
<generator>Jekyll v3.9.0</generator>
|
||||||
|
|
||||||
</channel>
|
</channel>
|
||||||
|
@ -1444,6 +1444,12 @@ to analyze JavaScript code. Note that PMD core still only requires Java 7.</p>
|
|||||||
enforces the convention that JUnit 5 tests should have minimal visibility.
|
enforces the convention that JUnit 5 tests should have minimal visibility.
|
||||||
You can try out this rule like so:
|
You can try out this rule like so:
|
||||||
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><rule</span> <span class="na">ref=</span><span class="s">"category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate"</span> <span class="nt">/></span>
|
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><rule</span> <span class="na">ref=</span><span class="s">"category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate"</span> <span class="nt">/></span>
|
||||||
|
</code></pre></div> </div>
|
||||||
|
</li>
|
||||||
|
<li>The new Java rule <a href="pmd_rules_java_design.html#mutablestaticstate"><code class="language-plaintext highlighter-rouge">MutableStaticState</code></a> finds non-private static fields
|
||||||
|
that are not final. These fields break encapsulation since these fields can be modified from anywhere
|
||||||
|
within the program. You can try out this rule like so:
|
||||||
|
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><rule</span> <span class="na">ref=</span><span class="s">"category/java/design.xml/MutableStaticState"</span> <span class="nt">/></span>
|
||||||
</code></pre></div> </div>
|
</code></pre></div> </div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -1524,6 +1530,7 @@ However, <code class="language-plaintext highlighter-rouge">Object.clone()</code
|
|||||||
<li><a href="https://github.com/pmd/pmd/issues/2219">#2219</a>: [java] Document Reasons to Avoid Reassigning Parameters</li>
|
<li><a href="https://github.com/pmd/pmd/issues/2219">#2219</a>: [java] Document Reasons to Avoid Reassigning Parameters</li>
|
||||||
<li><a href="https://github.com/pmd/pmd/issues/2737">#2737</a>: [java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch</li>
|
<li><a href="https://github.com/pmd/pmd/issues/2737">#2737</a>: [java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch</li>
|
||||||
<li><a href="https://github.com/pmd/pmd/issues/3236">#3236</a>: [java] LiteralsFirstInComparisons should consider constant fields (cont’d)</li>
|
<li><a href="https://github.com/pmd/pmd/issues/3236">#3236</a>: [java] LiteralsFirstInComparisons should consider constant fields (cont’d)</li>
|
||||||
|
<li><a href="https://github.com/pmd/pmd/issues/3239">#3239</a>: [java] PMD could enforce non-public methods for Junit5 / Jupiter test methods</li>
|
||||||
<li><a href="https://github.com/pmd/pmd/issues/3254">#3254</a>: [java] AvoidReassigningParameters reports violations on wrong line numbers</li>
|
<li><a href="https://github.com/pmd/pmd/issues/3254">#3254</a>: [java] AvoidReassigningParameters reports violations on wrong line numbers</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@ -1541,6 +1548,7 @@ However, <code class="language-plaintext highlighter-rouge">Object.clone()</code
|
|||||||
<li>java-design
|
<li>java-design
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://github.com/pmd/pmd/issues/2780">#2780</a>: [java] DataClass example from documentation results in false-negative</li>
|
<li><a href="https://github.com/pmd/pmd/issues/2780">#2780</a>: [java] DataClass example from documentation results in false-negative</li>
|
||||||
|
<li><a href="https://github.com/pmd/pmd/issues/2987">#2987</a>: [java] New Rule: Public and protected static fields must be final</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>java-errorprone
|
<li>java-errorprone
|
||||||
@ -1566,6 +1574,8 @@ However, <code class="language-plaintext highlighter-rouge">Object.clone()</code
|
|||||||
<h3 id="external-contributions">External Contributions</h3>
|
<h3 id="external-contributions">External Contributions</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://github.com/pmd/pmd/pull/3272">#3272</a>: [apex] correction for ApexUnitTestMethodShouldHaveIsTestAnnotation false positives - <a href="https://github.com/YodaDaCoda">William Brockhus</a></li>
|
<li><a href="https://github.com/pmd/pmd/pull/3272">#3272</a>: [apex] correction for ApexUnitTestMethodShouldHaveIsTestAnnotation false positives - <a href="https://github.com/YodaDaCoda">William Brockhus</a></li>
|
||||||
|
<li><a href="https://github.com/pmd/pmd/pull/3246">#3246</a>: [java] New Rule: MutableStaticState - <a href="https://github.com/vszholobov">Vsevolod Zholobov</a></li>
|
||||||
|
<li><a href="https://github.com/pmd/pmd/pull/3247">#3247</a>: [java] New rule: JUnit5TestShouldBePackagePrivate - <a href="https://github.com/ajeans">Arnaud Jeansen</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1588,6 +1588,7 @@ $('#toc').toc({ minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: 'h2,h3
|
|||||||
<li><a href="pmd_rules_java_design.html#logicinversion">LogicInversion</a>: Use opposite operator instead of negating the whole expression with a logic complement operator.</li>
|
<li><a href="pmd_rules_java_design.html#logicinversion">LogicInversion</a>: Use opposite operator instead of negating the whole expression with a logic complement operator.</li>
|
||||||
<li><a href="pmd_rules_java_design.html#loosepackagecoupling">LoosePackageCoupling</a>: Avoid using classes from the configured package hierarchy outside of the package hierarchy, excep…</li>
|
<li><a href="pmd_rules_java_design.html#loosepackagecoupling">LoosePackageCoupling</a>: Avoid using classes from the configured package hierarchy outside of the package hierarchy, excep…</li>
|
||||||
<li><a href="pmd_rules_java_design.html#modifiedcyclomaticcomplexity">ModifiedCyclomaticComplexity</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> Complexity directly affects maintenance costs is determined by the number of decision points in a…</li>
|
<li><a href="pmd_rules_java_design.html#modifiedcyclomaticcomplexity">ModifiedCyclomaticComplexity</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> Complexity directly affects maintenance costs is determined by the number of decision points in a…</li>
|
||||||
|
<li><a href="pmd_rules_java_design.html#mutablestaticstate">MutableStaticState</a>: Non-private static fields should be made constants (or immutable references) by declaring them fi…</li>
|
||||||
<li><a href="pmd_rules_java_design.html#ncssconstructorcount">NcssConstructorCount</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> This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l…</li>
|
<li><a href="pmd_rules_java_design.html#ncssconstructorcount">NcssConstructorCount</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> This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l…</li>
|
||||||
<li><a href="pmd_rules_java_design.html#ncsscount">NcssCount</a>: This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of line…</li>
|
<li><a href="pmd_rules_java_design.html#ncsscount">NcssCount</a>: This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of line…</li>
|
||||||
<li><a href="pmd_rules_java_design.html#ncssmethodcount">NcssMethodCount</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> This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l…</li>
|
<li><a href="pmd_rules_java_design.html#ncssmethodcount">NcssMethodCount</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> This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l…</li>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="description" content="Rules that help you discover design issues.">
|
<meta name="description" content="Rules that help you discover design issues.">
|
||||||
<meta name="keywords" content=" Design, AbstractClassWithoutAnyMethod, AvoidCatchingGenericException, AvoidDeeplyNestedIfStmts, AvoidRethrowingException, AvoidThrowingNewInstanceOfSameException, AvoidThrowingNullPointerException, AvoidThrowingRawExceptionTypes, AvoidUncheckedExceptionsInSignatures, ClassWithOnlyPrivateConstructorsShouldBeFinal, CollapsibleIfStatements, CouplingBetweenObjects, CyclomaticComplexity, DataClass, DoNotExtendJavaLangError, ExceptionAsFlowControl, ExcessiveClassLength, ExcessiveImports, ExcessiveMethodLength, ExcessiveParameterList, ExcessivePublicCount, FinalFieldCouldBeStatic, GodClass, ImmutableField, LawOfDemeter, LogicInversion, LoosePackageCoupling, ModifiedCyclomaticComplexity, NcssConstructorCount, NcssCount, NcssMethodCount, NcssTypeCount, NPathComplexity, SignatureDeclareThrowsException, SimplifiedTernary, SimplifyBooleanAssertion, SimplifyBooleanExpressions, SimplifyBooleanReturns, SimplifyConditional, SingularField, StdCyclomaticComplexity, SwitchDensity, TooManyFields, TooManyMethods, UselessOverridingMethod, UseObjectForClearerAPI, UseUtilityClass">
|
<meta name="keywords" content=" Design, AbstractClassWithoutAnyMethod, AvoidCatchingGenericException, AvoidDeeplyNestedIfStmts, AvoidRethrowingException, AvoidThrowingNewInstanceOfSameException, AvoidThrowingNullPointerException, AvoidThrowingRawExceptionTypes, AvoidUncheckedExceptionsInSignatures, ClassWithOnlyPrivateConstructorsShouldBeFinal, CollapsibleIfStatements, CouplingBetweenObjects, CyclomaticComplexity, DataClass, DoNotExtendJavaLangError, ExceptionAsFlowControl, ExcessiveClassLength, ExcessiveImports, ExcessiveMethodLength, ExcessiveParameterList, ExcessivePublicCount, FinalFieldCouldBeStatic, GodClass, ImmutableField, LawOfDemeter, LogicInversion, LoosePackageCoupling, ModifiedCyclomaticComplexity, NcssConstructorCount, NcssCount, NcssMethodCount, NcssTypeCount, NPathComplexity, SignatureDeclareThrowsException, SimplifiedTernary, SimplifyBooleanAssertion, SimplifyBooleanExpressions, SimplifyBooleanReturns, SimplifyConditional, SingularField, StdCyclomaticComplexity, SwitchDensity, TooManyFields, TooManyMethods, UselessOverridingMethod, UseObjectForClearerAPI, UseUtilityClass, MutableStaticState">
|
||||||
<title>Design | PMD Source Code Analyzer</title>
|
<title>Design | PMD Source Code Analyzer</title>
|
||||||
<link rel="stylesheet" href="css/syntax.css">
|
<link rel="stylesheet" href="css/syntax.css">
|
||||||
|
|
||||||
@ -2777,6 +2777,38 @@ by the rule <a href="pmd_rules_java_design.html#cyclomaticcomplexity"><code clas
|
|||||||
<span class="nt"></rule></span>
|
<span class="nt"></rule></span>
|
||||||
</code></pre></div></div>
|
</code></pre></div></div>
|
||||||
|
|
||||||
|
<h2 id="mutablestaticstate">MutableStaticState</h2>
|
||||||
|
|
||||||
|
<p><strong>Since:</strong> PMD 6.35.0</p>
|
||||||
|
|
||||||
|
<p><strong>Priority:</strong> Medium (3)</p>
|
||||||
|
|
||||||
|
<p>Non-private static fields should be made constants (or immutable references) by
|
||||||
|
declaring them final.</p>
|
||||||
|
|
||||||
|
<p>Non-private non-final static fields break encapsulation and can lead to hard to find
|
||||||
|
bugs, since these fields can be modified from anywhere within the program.
|
||||||
|
Callers can trivially access and modify non-private non-final static fields. Neither
|
||||||
|
accesses nor modifications can be guarded against, and newly set values cannot
|
||||||
|
be validated.</p>
|
||||||
|
|
||||||
|
<p>If you are using this rule, then you don’t need this
|
||||||
|
rule <a href="pmd_rules_java_errorprone.html#assignmenttononfinalstatic"><code class="language-plaintext highlighter-rouge">AssignmentToNonFinalStatic</code></a>.</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">FieldDeclaration</span><span class="p">[</span><span class="na">@Static</span><span class="w"> </span><span class="err">=</span><span class="w"> </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="na">@Private</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="nf">false</span><span class="p">()</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="na">@Final</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="nf">false</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="kd">public</span> <span class="kd">class</span> <span class="nc">Greeter</span> <span class="o">{</span> <span class="kd">public</span> <span class="kd">static</span> <span class="nc">Foo</span> <span class="n">foo</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">Foo</span><span class="o">();</span> <span class="o">...</span> <span class="o">}</span> <span class="c1">// avoid this</span>
|
||||||
|
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">Greeter</span> <span class="o">{</span> <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="nc">Foo</span> <span class="no">FOO</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">Foo</span><span class="o">();</span> <span class="o">...</span> <span class="o">}</span> <span class="c1">// use this instead</span>
|
||||||
|
</code></pre></div></div>
|
||||||
|
|
||||||
|
<p><strong>Use this rule by referencing it:</strong></p>
|
||||||
|
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><rule</span> <span class="na">ref=</span><span class="s">"category/java/design.xml/MutableStaticState"</span> <span class="nt">/></span>
|
||||||
|
</code></pre></div></div>
|
||||||
|
|
||||||
<h2 id="ncssconstructorcount">NcssConstructorCount</h2>
|
<h2 id="ncssconstructorcount">NcssConstructorCount</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><span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span></p>
|
||||||
|
@ -2730,6 +2730,15 @@
|
|||||||
"url": "pmd_rules_java_design.html#useutilityclass",
|
"url": "pmd_rules_java_design.html#useutilityclass",
|
||||||
"summary": "Rules that help you discover design issues."
|
"summary": "Rules that help you discover design issues."
|
||||||
}
|
}
|
||||||
|
,
|
||||||
|
|
||||||
|
{
|
||||||
|
"title": "MutableStaticState (Java, Design)",
|
||||||
|
"tags": "",
|
||||||
|
"keywords": "MutableStaticState",
|
||||||
|
"url": "pmd_rules_java_design.html#mutablestaticstate",
|
||||||
|
"summary": "Rules that help you discover design issues."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user