gitinspector
gitinspector copied to clipboard
Add: The following files have an elevated cognitive complexity (in order of severity)
I like to analyze code by the cognitive complexity standard. It would be cool to have this section in addition to cyclomatic complexity.
https://docs.codeclimate.com/docs/cognitive-complexity
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Example:
Complex
function count(a, b, c) {
var total = 0;
var nums = [a, b, c];
for (var i = 0; i < nums.length; i++) {
total += nums[i];
}
return total;
}
Not Complex
function count(a, b, c) {
var total = 0;
total += a;
total += b;
total += c;
return total;
}
Hi @christo8989. For what we are targeting with gitinspector this may indeed be a very useful metric... Found this article comparing cyclomatic and cognitive complexity,
https://tomasvotruba.com/blog/2018/05/21/is-your-code-readable-by-humans-cognitive-complexity-tells-you/