Showing 46 of 51 total issues
Function _extract_components
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def _extract_components(
cls, lines: Iterable[Line]
) -> Tuple[List[Node], List[Comment]]:
"""
Given a list of lines, return 2 components:
- 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
Line
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class Line:
"""
A Line is a collection of Nodes and Comments that should be printed together, on a
single line.
"""
- Create a ticketCreate a ticket
Function split_at_index
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def split_at_index(
self,
line: Line,
head: int,
index: int,
- 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 maybe_merge_lines
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def maybe_merge_lines(self, lines: List[Line]) -> List[Line]:
"""
Tries to merge lines into a single line; if that fails,
splits lines into segments of equal depth, merges
runs of operators at that depth, and then recurses into
- 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
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 _get_common_parents
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _get_common_parents(files: List[Path]) -> List[Path]:
"""
For a list of absolute paths, returns a Set of paths for all
of the common parents of files
"""
- 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 sqlfmt_primer
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def sqlfmt_primer(
ctx: click.Context,
quiet: bool,
reset_cache: bool,
single_process: bool,
- 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 create_segments_from_lines
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_segments_from_lines(lines: Sequence[Line]) -> List["Segment"]:
"""
A segment is a list of consecutive lines that are indented from the
first 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 _maybe_stubbornly_merge
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _maybe_stubbornly_merge(self, segments: List[Segment]) -> List[Segment]:
"""
We prefer some operators, like `as`, `over()`, `exclude()`, and
array or dictionary accessing with `[]` to be
forced onto the prior line, even if the contents of their brackets
- 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 get_matching_paths
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_matching_paths(paths: Iterable[Path], mode: Mode) -> Set[Path]:
"""
Takes a list of paths (files or directories) and a mode as an input, and
yields paths to individual files that match the input paths (or are contained in
its directories) and are not excluded by the mode's exclude glob
- 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 _remove_extra_blank_lines
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. 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 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 maybe_split
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def maybe_split(self, line: Line) -> List[Line]:
"""
Evaluates a line for splitting. If line matches criteria for splitting,
returns a list of new lines; otherwise returns a list of only the original 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 render_standalone
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def render_standalone(self, max_length: int, prefix: str) -> str:
"""
For a Comment, returns the string for properly formatting this Comment
as a standalone comment (on its own 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 _dedent_jinja_blocks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. 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"
Further reading
Function raise_on_mismatched_jinja_tags
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def raise_on_mismatched_jinja_tags(self, token: Token, start_tag: Node) -> None:
"""
Compare the value of token to the start_tag to determine whether token
closes start_tag
"""
- 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 write_buffers_to_query
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def write_buffers_to_query(self, query: Query) -> None:
"""
Write the contents of self.line_buffer to query.lines,
taking care to flush node_buffer and comment_buffer first
"""
- 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
Consider simplifying this complex logical expression. Open
if (
# if there is a multiline node on this line and it isn't the
# only thing on this line, then split before the multiline node
node.is_multiline_jinja
# always split before any unterm kw
- Create a ticketCreate a ticket
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"