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

Fix "method_complexity" issue in kyu_4/range_extraction/solution.py #521

Open
ikostan opened this issue Nov 7, 2024 · 1 comment
Open

Comments

@ikostan
Copy link
Member

ikostan commented Nov 7, 2024

Function case_2 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

https://codeclimate.com/github/iKostanOrg/codewars/kyu_4/range_extraction/solution.py#issue_672c4019c11fdc00010003cb

@ikostan
Copy link
Member Author

ikostan commented Nov 7, 2024

Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

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"
Further reading
Cognitive Complexity docs
Cognitive Complexity: A new way of measuring understandability

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

No branches or pull requests

1 participant