Skip to content

feat: new cognitve complexity metric add #439

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

veledara
Copy link
Contributor

This pull request adds a new metric, Cognitive Complexity, to the CAM project. The metric computes the total cognitive complexity for all methods in a class by analyzing control flow constructs and binary operations

@veledara
Copy link
Contributor Author

@yegor256 could you check, please?

@yegor256
Copy link
Owner

@veledara what's the motivation for this one? We already calculate CoCo, via PMD. Why do we need to duplicate it?

@veledara
Copy link
Contributor Author

@veledara what's the motivation for this one? We already calculate CoCo, via PMD. Why do we need to duplicate it?

@yegor256 i suggest that having our own implementation would offer us flexibility and transparency. moreover - no dependency on external tools like pmd, ensuring consistency and adaptability
what do you think?

@yegor256
Copy link
Owner

@veledara this may be a reasonable objective, but in order to do this we need to write much more tests that you suggest in this ticket. You simply test a very simple Java snippet, while the metric is not that simple. We need dozens of tests, probably referenced by a baseline (PMD).

@veledara
Copy link
Contributor Author

veledara commented Mar 30, 2025

@veledara this may be a reasonable objective, but in order to do this we need to write much more tests that you suggest in this ticket. You simply test a very simple Java snippet, while the metric is not that simple. We need dozens of tests, probably referenced by a baseline (PMD).

@yegor256 Your point about comprehensive testing is absolutely valid, but i think this implementation provides a basis so that others can connect and gradually add tests. This way we will start using the metric right away, rather than waiting for the ideal. Also, while the community will make improvements in this metric and add tests, we will have a full-fledged version in the form of pmd, so that is not a problem. We can abandon pmd at the moment when we realize that our implementation is completely sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants