Skip to content

Sonar violation: Cognitive Complexity of methods should not be too high (above 20) #7475

@romani

Description

@romani

https://sonarcloud.io/organizations/checkstyle/issues?resolved=false&rules=java%3AS3776

Rule description https://sonarcloud.io/organizations/checkstyle/rules?open=java%3AS3776&q=java%3AS3776

cases:
https://sonarcloud.io/project/issues?id=org.checkstyle%3Acheckstyle&issues=AW9t2w4mYD2QG1pPXIVE&open=AW9t2w4mYD2QG1pPXIVE
and
https://sonarcloud.io/project/issues?id=org.checkstyle%3Acheckstyle&issues=AW9t2wy2YD2QG1pPXITK&open=AW9t2wy2YD2QG1pPXITK

should be fixed as they most complicated cases for sure:
src/.../puppycrawl/tools/checkstyle/Main.java
Refactor this method to reduce its Cognitive Complexity from 23 to the 20 allowed.
L750

src/.../checkstyle/checks/imports/CustomImportOrderCheck.java
Refactor this method to reduce its Cognitive Complexity from 25 to the 20 allowed.
L552


FYI:
same method Main#validateCli is violated by Cyclomatic
[checkstyle] [ERROR] src/main/java/com/puppycrawl/tools/checkstyle/Main.java:749:9: Cyclomatic Complexity is 21 (max allowed is 10). [CyclomaticComplexity]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions