Low Code Quality¶
Sourcery comment id:
Low code quality found in function.
This appears when the quality score for your function dips below the configured quality threshold (the default is 25%).
This score is a combination of the method length, cognitive complexity and working memory of the function.
How can you solve this?
- Reduce the function length by extracting pieces of functionality out into their own functions. This is the most important thing you can do - ideally a function should be less than 10 lines.
- Reduce nesting, perhaps by introducing guard clauses to return early
- Ensure that variables are tightly scoped, so that code using related concepts sits together within the function rather than being scattered.