Skip to content

Instantly share code, notes, and snippets.

@realFranco
Last active June 26, 2025 22:42
Show Gist options
  • Save realFranco/68b44853843ff95de992420c286999c0 to your computer and use it in GitHub Desktop.
Save realFranco/68b44853843ff95de992420c286999c0 to your computer and use it in GitHub Desktop.
Cyclomatic complextity for Java

Cyclomatic complexity for Java

filename: checkstyle.xml

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
          "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
  <module name="TreeWalker">
    <module name="CyclomaticComplexity">
      <property name="max" value="4"/>
    </module>
  </module>
</module>

On vs Code open settings and type: "java check"

verifies if the if the file checkstyle.xml is correctly declared.

on vs code, right click on the .xml created before and select the option "use this .xml"

See more

https://checkstyle.sourceforge.io/checks/metrics/cyclomaticcomplexity.html

https://marketplace.visualstudio.com/items?itemName=shengchen.vscode-checkstyle

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