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_7/valid_parentheses/solution.py #545

Open
ikostan opened this issue Dec 1, 2024 · 1 comment
Open

Comments

@ikostan
Copy link
Member

ikostan commented Dec 1, 2024

Function valid_parentheses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

https://codeclimate.com/github/iKostanOrg/codewars/kyu_7/valid_parentheses/solution.py#issue_674bf1c4dee4be0001000a20

@ikostan
Copy link
Member Author

ikostan commented Dec 1, 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"

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