Find methods that are too hard to understand
ProprietaryMarks methods and constructors whose cognitive complexity is greater than 15. Cognitive complexity charges one for each break in linear control flow and one more for each level of nesting the break sits at, so deeply nested code scores far higher than a flat chain of conditions. An else if costs one and does not deepen nesting, a run of the same logical operator costs one however long it is, and a lambda or a nested class deepens nesting without costing anything itself. A method in an anonymous class, or in a class declared inside a method body, is not marked on its own, as Sonar does not measure it separately. equals and hashCode overrides are never marked. Test sources are not searched.
io. moderne. staticanalysis. FindMethodCognitiveComplexitymod run . --recipe= io. moderne. staticanalysis. FindMethodCognitiveComplexityInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.