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

CC less than one? #69

Open
michaelradionov opened this issue Nov 13, 2024 · 4 comments
Open

CC less than one? #69

michaelradionov opened this issue Nov 13, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@michaelradionov
Copy link

Hello, Jean-François. I love your tool AST metrics, many thanks for that. I have a question about. How could Cyclomatic Complexity be less than 1? I see CC less than 1 both per method and per class.
Снимок экрана 2024-11-13 в 18 42 41

@Halleck45 Halleck45 added the bug Something isn't working label Nov 13, 2024
@Halleck45
Copy link
Owner

Greetings!

I suspect that there may be a problem with the results aggregation (which calculates the distribution). Could I request a sample of the code that generated this output?"

@michaelradionov
Copy link
Author

I think the problem might be that this tool assumes that code with no "if" has zero CC. For example, this piece of code results this report. Maybe result should be 1, not 0 in this case?
Снимок экрана 2024-11-13 в 19 17 16
Снимок экрана 2024-11-13 в 19 21 41

@Halleck45
Copy link
Owner

Indeed, there are 2 issues:

  1. The function itself is not counted in the complexity calculation. This is fixed with this PR: #69 fixes incorrect CCN calculation for methods and cases #72

  2. (under analysis, to be confirmed) When calculating the average, we do not distinguish between interface methods and class methods. This can lead to averages below 0. I will investigate how to solve this point.

Halleck45 added a commit that referenced this issue Nov 19, 2024
#69 fixes incorrect CCN calculation for methods and cases
@michaelradionov
Copy link
Author

michaelradionov commented Dec 6, 2024

Hi. Thanks for answer, I just updated to latest release but I still getting CC less than one.
Also after release 0.20.2 Risk and Instability return 0.
Снимок экрана 2024-12-06 в 17 26 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants