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

[java] NPath complexity false negative due to overflow #1226

maikelsteneker opened this Issue Jul 4, 2018 · 4 comments


None yet
4 participants

maikelsteneker commented Jul 4, 2018

Affects PMD Version: 6.5.0


Description: On some methods, the NPath complexity is not reported, even though the threshold for reporting it is set to the minimum value. In earlier versions of PMD (e.g., 5.3), NPath complexity was reported for these methods.

Code Sample demonstrating the issue:

No NPath complexity is reported for the method readVar() in the sample below:

Running PMD through: CLI

The ruleset: pmd.xml.gz

    <rule ref="category/java/design.xml/NPathComplexity">
            <property name="reportLevel" value="0"/>

This comment has been minimized.


oowekyala commented Jul 9, 2018

Interesting, thanks for the report. Apparently NPath is too high for the method and we get an integer overflow. I'll schedule this for the next release

@oowekyala oowekyala added this to the 6.6.0 milestone Jul 9, 2018


This comment has been minimized.


jsotuyod commented Jul 9, 2018

@oowekyala that's interesting... the detector should stop looking into a method once it's certain the threshold has been exceeded.


This comment has been minimized.


oowekyala commented Jul 16, 2018

@jsotuyod I don't think that would interact well with the metrics' caching since every rule may have a separate report level. Granted, for now metrics are mostly one-to-one with rules, so the caching may not be very useful (until we implement multifile analysis).

For this metric we could probably just use a long, or a BigInteger, and clip the computed value to Double.MAX_VALUE before caching


This comment has been minimized.


adangel commented Jul 28, 2018

With PMD 5.3.8:
/home/andreas/PMD/source/pmd-it/issue-1226/src/ The method readVar() has an NPath complexity of 613528536

@adangel adangel changed the title from [java] NPath complexity false negative to [java] NPath complexity false negative due to overflow Jul 28, 2018

@adangel adangel self-assigned this Jul 28, 2018

adangel added a commit to adangel/pmd that referenced this issue Jul 28, 2018

@adangel adangel added the has:pr label Jul 28, 2018

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