Skip to content

Add YoctoScannerParser

ci.jenkins.io / PMD failed Aug 31, 2024 in 0s

7 new issues

Total New Outstanding Fixed Trend
7 7 0 0 👎

Reference build: Plugins » analysis-model » main #244

Details

Severity distribution of new issues

Error Warning High Warning Normal Warning Low
0 0 7 0

Annotations

Check warning on line 68 in src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / PMD

CyclomaticComplexity

NORMAL:
The method 'mapSeverity(JSONObject)' has a cyclomatic complexity of 12.
Raw output
The complexity of methods directly affects maintenance costs and readability. Concentrating too much decisional logic in a single method makes its behaviour hard to read and change. Cyclomatic complexity assesses the complexity of a method by counting the number of decision points in a method, plus one for the method entry. Decision points are places where the control flow jumps to another place in the program. As such, they include all control flow statements, such as `if`, `while`, `for`, and `case`. For more details on the calculation, see the documentation {% jdoc java::lang.java.metrics.JavaMetrics#CYCLO %}. Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote high complexity, and 11+ is very high complexity. By default, this rule reports methods with a complexity >= 10. Additionally, classes with many methods of moderate complexity get reported as well once the total of their methods' complexities reaches 80, even if none of the methods was directly reported. Reported methods should be broken down into several smaller methods. Reported classes should probably be broken down into subcomponents. <pre> <code> class Foo { void baseCyclo() { // Cyclo = 1 highCyclo(); } void highCyclo() { // Cyclo = 10: reported! int x = 0, y = 2; boolean a = false, b = true; if (a &amp;&amp; (y == 1 ? b : true)) { // +3 if (y == x) { // +1 while (true) { // +1 if (x++ &lt; 20) { // +1 break; // +1 } } } else if (y == t &amp;&amp; !d) { // +2 x = a ? y : x; // +1 } else { x = 2; } } } } </code> </pre> <a href="https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_design.html#cyclomaticcomplexity"> See PMD documentation. </a>

Check warning on line 68 in src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / PMD

NPathComplexity

NORMAL:
The method 'mapSeverity(JSONObject)' has an NPath complexity of 864, current threshold is 200.
Raw output
The NPath complexity of a method is the number of acyclic execution paths through that method. While cyclomatic complexity counts the number of decision points in a method, NPath counts the number of full paths from the beginning to the end of the block of the method. That metric grows exponentially, as it multiplies the complexity of statements in the same block. For more details on the calculation, see the documentation {% jdoc java::lang.java.metrics.JavaMetrics#NPATH %}. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity and increase readability. <pre> <code> public class Foo { public static void bar() { // Ncss = 252: reported! boolean a, b = true; try { // 2 * 2 + 2 = 6 if (true) { // 2 List buz = new ArrayList(); } for(int i = 0; i &lt; 19; i++) { // * 2 List buz = new ArrayList(); } } catch(Exception e) { if (true) { // 2 e.printStackTrace(); } } while (j++ &lt; 20) { // * 2 List buz = new ArrayList(); } switch(j) { // * 7 case 1: case 2: break; case 3: j = 5; break; case 4: if (b &amp;&amp; a) { bar(); } break; default: break; } do { // * 3 List buz = new ArrayList(); } while (a &amp;&amp; j++ &lt; 30); } } </code> </pre> <a href="https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_design.html#npathcomplexity"> See PMD documentation. </a>

Check warning on line 81 in src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / PMD

AvoidLiteralsInIfCondition

NORMAL:
Avoid using literals in if statements.
Raw output
Avoid using hard-coded literals in conditional statements. By declaring them as static variables or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored. More exceptions can be defined with the property "ignoreMagicNumbers". The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`. With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case, the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression. <pre> <code> private static final int MAX_NUMBER_OF_REQUESTS = 10; public void checkRequests() { if (i == 10) { // magic number, buried in a method doSomething(); } if (i == MAX_NUMBER_OF_REQUESTS) { // preferred approach doSomething(); } if (aString.indexOf(&#x27;.&#x27;) != -1) {} // magic number -1, by default ignored if (aString.indexOf(&#x27;.&#x27;) &gt;= 0) { } // alternative approach if (aDouble &gt; 0.0) {} // magic number 0.0 if (aDouble &gt;= Double.MIN_VALUE) {} // preferred approach // with rule property &quot;ignoreExpressions&quot; set to &quot;false&quot; if (i == pos + 5) {} // violation: magic number 5 within an (additive) expression if (i == pos + SUFFIX_LENGTH) {} // preferred approach if (i == 5 &amp;&amp; &quot;none&quot;.equals(aString)) {} // 2 violations: magic number 5 and literal &quot;none&quot; } </code> </pre> <a href="https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_errorprone.html#avoidliteralsinifcondition"> See PMD documentation. </a>

Check warning on line 82 in src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / PMD

AvoidLiteralsInIfCondition

NORMAL:
Avoid using literals in if statements.
Raw output
Avoid using hard-coded literals in conditional statements. By declaring them as static variables or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored. More exceptions can be defined with the property "ignoreMagicNumbers". The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`. With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case, the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression. <pre> <code> private static final int MAX_NUMBER_OF_REQUESTS = 10; public void checkRequests() { if (i == 10) { // magic number, buried in a method doSomething(); } if (i == MAX_NUMBER_OF_REQUESTS) { // preferred approach doSomething(); } if (aString.indexOf(&#x27;.&#x27;) != -1) {} // magic number -1, by default ignored if (aString.indexOf(&#x27;.&#x27;) &gt;= 0) { } // alternative approach if (aDouble &gt; 0.0) {} // magic number 0.0 if (aDouble &gt;= Double.MIN_VALUE) {} // preferred approach // with rule property &quot;ignoreExpressions&quot; set to &quot;false&quot; if (i == pos + 5) {} // violation: magic number 5 within an (additive) expression if (i == pos + SUFFIX_LENGTH) {} // preferred approach if (i == 5 &amp;&amp; &quot;none&quot;.equals(aString)) {} // 2 violations: magic number 5 and literal &quot;none&quot; } </code> </pre> <a href="https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_errorprone.html#avoidliteralsinifcondition"> See PMD documentation. </a>

Check warning on line 93 in src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / PMD

AvoidLiteralsInIfCondition

NORMAL:
Avoid using literals in if statements.
Raw output
Avoid using hard-coded literals in conditional statements. By declaring them as static variables or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored. More exceptions can be defined with the property "ignoreMagicNumbers". The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`. With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case, the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression. <pre> <code> private static final int MAX_NUMBER_OF_REQUESTS = 10; public void checkRequests() { if (i == 10) { // magic number, buried in a method doSomething(); } if (i == MAX_NUMBER_OF_REQUESTS) { // preferred approach doSomething(); } if (aString.indexOf(&#x27;.&#x27;) != -1) {} // magic number -1, by default ignored if (aString.indexOf(&#x27;.&#x27;) &gt;= 0) { } // alternative approach if (aDouble &gt; 0.0) {} // magic number 0.0 if (aDouble &gt;= Double.MIN_VALUE) {} // preferred approach // with rule property &quot;ignoreExpressions&quot; set to &quot;false&quot; if (i == pos + 5) {} // violation: magic number 5 within an (additive) expression if (i == pos + SUFFIX_LENGTH) {} // preferred approach if (i == 5 &amp;&amp; &quot;none&quot;.equals(aString)) {} // 2 violations: magic number 5 and literal &quot;none&quot; } </code> </pre> <a href="https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_errorprone.html#avoidliteralsinifcondition"> See PMD documentation. </a>

Check warning on line 97 in src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / PMD

AvoidLiteralsInIfCondition

NORMAL:
Avoid using literals in if statements.
Raw output
Avoid using hard-coded literals in conditional statements. By declaring them as static variables or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored. More exceptions can be defined with the property "ignoreMagicNumbers". The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`. With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case, the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression. <pre> <code> private static final int MAX_NUMBER_OF_REQUESTS = 10; public void checkRequests() { if (i == 10) { // magic number, buried in a method doSomething(); } if (i == MAX_NUMBER_OF_REQUESTS) { // preferred approach doSomething(); } if (aString.indexOf(&#x27;.&#x27;) != -1) {} // magic number -1, by default ignored if (aString.indexOf(&#x27;.&#x27;) &gt;= 0) { } // alternative approach if (aDouble &gt; 0.0) {} // magic number 0.0 if (aDouble &gt;= Double.MIN_VALUE) {} // preferred approach // with rule property &quot;ignoreExpressions&quot; set to &quot;false&quot; if (i == pos + 5) {} // violation: magic number 5 within an (additive) expression if (i == pos + SUFFIX_LENGTH) {} // preferred approach if (i == 5 &amp;&amp; &quot;none&quot;.equals(aString)) {} // 2 violations: magic number 5 and literal &quot;none&quot; } </code> </pre> <a href="https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_errorprone.html#avoidliteralsinifcondition"> See PMD documentation. </a>

Check warning on line 106 in src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / PMD

ControlStatementBraces

NORMAL:
This statement should have braces.
Raw output
Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... else' statements and loop statements, even if they are optional. This usually makes the code clearer, and helps prepare the future when you need to add another statement. That said, this rule lets you control which statements are required to have braces via properties. From 6.2.0 on, this rule supersedes WhileLoopMustUseBraces, ForLoopMustUseBraces, IfStmtMustUseBraces, and IfElseStmtMustUseBraces. <pre> <code> while (true) // not recommended x++; while (true) { // preferred approach x++; } </code> </pre> <a href="https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_codestyle.html#controlstatementbraces"> See PMD documentation. </a>