New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use CyclomaticComplexity.switchBlockAsSingleDecisionPoint in checkstyle_checks.xml #2874

Closed
romani opened this Issue Feb 4, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@romani
Member

romani commented Feb 4, 2016

Comment in suppression.xml: https://github.com/checkstyle/checkstyle/blob/master/config/suppressions.xml#L129 is obsolete
Issue #2029" is resolved but new option is not used .

update like:

--- a/config/checkstyle_checks.xml
+++ b/config/checkstyle_checks.xml
@@ -301,7 +301,9 @@
         <!-- Default classes are also listed-->
         <property name="excludedClasses" value="boolean, byte, char, double, float, int, long, short,  void, Boolean, Byte, Chara
     </module>
-    <module name="CyclomaticComplexity"/>
+    <module name="CyclomaticComplexity">
+      <property name="switchBlockAsSingleDecisionPoint" value="true"/>
+    </module>
     <module name="JavaNCSS"/>

and

<!-- Just big switches. Cannot be split to several methods. Till https://github.com/checkstyle/checkstyle/issues/2029 -->
    <!--<suppress checks="CyclomaticComplexity" files="(AbstractDeclarationCollector|RequireThisCheck|SuppressWarningsHolder|LeftCurlyCheck|FallThroughCheck|FinalLocalVariableCheck|ModifiedControlVariableCheck)\.java"/> -->
    <!--<suppress checks="CyclomaticComplexity" files="(ParameterAssignmentCheck|VariableDeclarationUsageDistanceCheck|BooleanExpressionComplexityCheck|NPathComplexityCheck|CheckUtils)\.java"/> -->

generates output:

[checkstyle] [ERROR] /home/rivanov/java/git-others/checkstyle/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java:150:5: Cyclomatic Complexity is 13 (max allowed is 10). [CyclomaticComplexity]
[checkstyle] [ERROR] /home/rivanov/java/git-others/checkstyle/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java:175:5: Cyclomatic Complexity is 14 (max allowed is 10). [CyclomaticComplexity]
[checkstyle] [ERROR] /home/rivanov/java/git-others/checkstyle/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java:272:5: Cyclomatic Complexity is 12 (max allowed is 10). [CyclomaticComplexity]

New option need to be used and violations are resolved.

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Mar 2, 2016

Member

Just as a note.

The violation on SuppressWarningsHolder isn't a switch, so it should probably remain unless it can be fixed.
There is a new violation that has a switch: VariableDeclarationUsageDistanceCheck.java:390:5: Cyclomatic Complexity is 11 (max allowed is 10).

There are atleast 2 other suppressions that can be removed with this fix:

<suppress checks="CyclomaticComplexity" files="[\\/]XDocsPagesTest\.java"/>
<suppress checks="CyclomaticComplexity" files="RightCurlyCheck\.java" lines="317"/>
Member

rnveach commented Mar 2, 2016

Just as a note.

The violation on SuppressWarningsHolder isn't a switch, so it should probably remain unless it can be fixed.
There is a new violation that has a switch: VariableDeclarationUsageDistanceCheck.java:390:5: Cyclomatic Complexity is 11 (max allowed is 10).

There are atleast 2 other suppressions that can be removed with this fix:

<suppress checks="CyclomaticComplexity" files="[\\/]XDocsPagesTest\.java"/>
<suppress checks="CyclomaticComplexity" files="RightCurlyCheck\.java" lines="317"/>
@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Apr 26, 2016

Member

Assigned to @orlovnikita.

Member

romani commented Apr 26, 2016

Assigned to @orlovnikita.

orlovnikita pushed a commit to orlovnikita/checkstyle that referenced this issue Apr 28, 2016

MEZk added a commit to MEZk/checkstyle that referenced this issue Aug 6, 2016

MEZk added a commit to MEZk/checkstyle that referenced this issue Sep 8, 2016

romani added a commit that referenced this issue Sep 8, 2016

@romani romani added this to the 7.2 milestone Sep 8, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Sep 8, 2016

Member

fix is merged.

Member

romani commented Sep 8, 2016

fix is merged.

@romani romani closed this Sep 8, 2016

MEZk added a commit to MEZk/checkstyle that referenced this issue Sep 8, 2016

romani added a commit that referenced this issue Sep 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment