Consider simplifying this complex logical expression. Open
if (
isinstance(node, ast.Constant)
and isinstance(node.value, str)
and node.end_lineno is not None
and node.end_lineno > node.lineno
- Create a ticketCreate a ticket
Function format_line
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def format_line(self, line: Line) -> List[Line]:
"""
Format each jinja tag in a line, in turn. If a node was made multiline,
split before the node (unless it is already the first node on that line)
"""
- 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 format_string
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def format_string(self, source_string: str, max_length: int) -> Tuple[str, bool]:
"""
Attempt to use black to format source_string to a line_length of max_length.
Return source_string if black isn't installed or it can't parse source_string.
- 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 _replace_tildes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _replace_tildes(cls, source_string: str) -> Tuple[str, Dict[str, int]]:
"""
Jinja uses ~ as the string concatenation operator, but black cannot parse the
tilde. This method finds another operator to safely replace the tilde with,
and returns a string with the tilde replaced and a dict with the symbol it
- 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 _multiline_str
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _multiline_str(self) -> str:
"""
if the formatted code is on multiple lines, we want the code indented
four spaces past the opening and closing markers. The opening marker
will already be indented to the proper depth (because of the Line).
- 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 _find_multiline_python_str_lines
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _find_multiline_python_str_lines(self) -> MutableSet[int]:
"""
Return a set line numbers that correspond with the lines
of a triple-quoted multiline string (except for the first line
of each string). These are lines that should never have
- 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 from_string
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def from_string(cls, source_string: str, depth: Tuple[int, int]) -> "JinjaTag":
"""
Takes a jinja statement or expression as a string and returns
a JinjaTag object (basically a tuple of its parts).
"""
- 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
Avoid too many return
statements within this function. Wontfix
return postprocessed_string, BLACKENED
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Wontfix
return source_string, NOT_BLACKENED
- Create a ticketCreate a ticket