You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cognitive complexity seems to have some advantages over cyclomatic complexity, for the understandability of code.
For example, a long but simple switch/case block has a very high cyclomatic complexity but a low cognitive complexity.
Here is a good description of the differences: https://docs.codeclimate.com/docs/cognitive-complexity
Although this tool seem to be quite extendable, I failed miserably to switch it over to cognitive complexity algorithm. Twice. I don't know how to adopt 3rd party libraries and code to be used in this tool - it's probably due to the way it's made to run in parallel to speed up analysis - but it simply misses any custom-provided classes.
I would really appreciate if @villfa@bmitch would try himself and made it available.
Hi @eduard-sukharev,
This is not currently possible to extend Churn in order to replace the algorithm that calculates the complexity.
The available hooks allow users to process the results as they wish (to save them in a database for instance).
I like the idea that Churn can calculate cognitive complexity, whether by default or as an extension.
That said, I don't have much free time to work on that, so I can't promise anything.
Cognitive complexity seems to have some advantages over cyclomatic complexity, for the understandability of code.
For example, a long but simple switch/case block has a very high cyclomatic complexity but a low cognitive complexity.
Here is a good description of the differences: https://docs.codeclimate.com/docs/cognitive-complexity
Maybe the analyzer from https://github.com/Rarst/phpcs-cognitive-complexity can be used to add this alternative metric?
The text was updated successfully, but these errors were encountered: