src/sqlfmt/formatter.py
Function _remove_extra_blank_lines
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def _remove_extra_blank_lines(self, lines: List[Line]) -> List[Line]:
"""
A query can have at most 2 consecutive blank lines at depth (0,0)
and 1 consecutive blank line at any other depth. See issue #249
for motivation and details.
- Read upRead up
- Create a ticketCreate a ticket
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
Function _dedent_jinja_blocks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def _dedent_jinja_blocks(self, lines: List[Line]) -> List[Line]:
"""
Jinja block tags, like {% if foo %} and {% endif %}, shouldn't
be printed at their depth, since their contents may be dedented
farther. This dedents the tags as necessary, in a single pass
- Read upRead up
- Create a ticketCreate a ticket
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"