Skip to content
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] Cyclomatic complexity is misreported (lack of clearing metrics cache) #1984

Closed
magwas opened this issue Aug 16, 2019 · 6 comments · Fixed by #2231
Closed

[java] Cyclomatic complexity is misreported (lack of clearing metrics cache) #1984

magwas opened this issue Aug 16, 2019 · 6 comments · Fixed by #2231
Assignees
Labels
a:bug PMD crashes or fails to analyse a file. in:metrics Affects the metrics framework
Milestone

Comments

@magwas
Copy link

magwas commented Aug 16, 2019

Affects PMD Version:

6.13.0

Rule:
CyclomaticComplexity

Description:

I had a function with a high cyclomatic complexity. I started to reduce it, but even when it became a linear one, I still have the warning:

Description	Resource	Path	Location	Type
The method 'createContract(List, Method, ContractRunnerData)' has a cyclomatic complexity of 9.	ContractCreationServiceImpl.java	/cdd/src/main/java/com/kodekonveyor/cdd/build/impl	line 32	PMD Marker (Prio 3)

I am using PMD Plug-in 4.2.0.v20190331-1136 in eclipse.
Tried to clear violations and check again, clean the source code and rebuild from eclipse, clean the source code with git clean -fdx, refresh the project from disk, and all combinations thereof.

Code Sample demonstrating the issue:
This code sample still have the warning above:

  @Override
  public ContractInfo<ServiceType> createContract(
      final List<ContractInfo<ServiceType>> contracts, final Method method,
      final ContractRunnerData<ServiceType> data
  ) throws AssertionError, Throwable {

    return null;
  }

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

eclipse

@oowekyala oowekyala added a:bug PMD crashes or fails to analyse a file. in:metrics Affects the metrics framework labels Aug 21, 2019
@oowekyala
Copy link
Member

We could probably disable the global metrics cache entirely until 7.0. I'm doubt it's very useful anyway. With 7.0 we can use a cache on the nodes, as described on the wiki.

@magwas
Copy link
Author

magwas commented Jan 12, 2020

I am stumbling to this issue again. How to clear the global metrics cache?

@magwas
Copy link
Author

magwas commented Jan 12, 2020

it seems exiting eclipse and deleting the directory .metadata/.plugins/net.sourceforge.pmd.eclipse.plugin/ in the workspace clears the cache. Please confirm.

@oowekyala oowekyala added this to the 6.21.0 milestone Jan 16, 2020
@adangel adangel self-assigned this Jan 17, 2020
@adangel
Copy link
Member

adangel commented Jan 17, 2020

I can reproduce it - it's definitively the metrics cache, that is not reset, when PMD is executed multiple times within the same JVM.

it seems exiting eclipse and deleting the directory .metadata/.plugins
/net.sourceforge.pmd.eclipse.plugin/ in the workspace clears the cache. Please confirm.

Restarting Eclipse is enough. You don't need to delete any files.

@magwas
Copy link
Author

magwas commented Jan 17, 2020

Restarting Eclipse is enough. You don't need to delete any files.

My experience does not confirm this.

@adangel adangel changed the title [java] Cyclomatic complexity is misreported (lack of clearing some cache?) [java] Cyclomatic complexity is misreported (lack of clearing metrics cache) Jan 17, 2020
@adangel adangel added the has:pr label Jan 17, 2020
@adangel
Copy link
Member

adangel commented Jan 17, 2020

Restarting Eclipse is enough. You don't need to delete any files.

My experience does not confirm this.

You'll also need to rerun PMD - otherwise eclipse shows the old markers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file. in:metrics Affects the metrics framework
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants