Showing 46 of 60 total issues
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 _load_config_from_path
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _load_config_from_path(config_path: Optional[Path]) -> Config:
"""
Loads a toml file located at config path. Returns the contents
under the [tool.sqlfmt] section as a dict.
"""
- 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 _fix_standalone_operators
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _fix_standalone_operators(self, segments: List[Segment]) -> List[Segment]:
"""
If the first line of a segment is a standalone operator,
we should try to merge the first two lines together before
doing anything else
- 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 _split_before
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _split_before(cls, text: str, max_length: int) -> Iterator[str]:
"""
When rendering very long comments, we try to split them at the desired line
length and wrap them onto multiple lines. This method takes the contents of
a comment (without the marker) and a maximum length, and splits the original
- 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 handle_potentially_nested_tokens
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def handle_potentially_nested_tokens(
- Create a ticketCreate a ticket
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 search_for_terminating_token
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def search_for_terminating_token(
- Create a ticketCreate a ticket
Function handle_jinja
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def handle_jinja(
- Create a ticketCreate a ticket
Function add_node_to_buffer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_node_to_buffer(
- Create a ticketCreate a ticket
Function sqlfmt
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sqlfmt(
ctx: click.Context, files: List[Path], **kwargs: Union[bool, int, List[str], str]
) -> None:
"""
sqlfmt formats your dbt SQL files so you don't have to.
- 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 (
self.nodes
and self.previous_node is not None
and self.previous_node.open_jinja_blocks
and (
- Create a ticketCreate a ticket
Function safe_add_node_to_buffer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def safe_add_node_to_buffer(
- Create a ticketCreate a ticket
Function handle_jinja_data_block_start
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def handle_jinja_data_block_start(
- Create a ticketCreate a ticket
Function sqlfmt_primer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def sqlfmt_primer(
- Create a ticketCreate a ticket
Function split_at_index
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def split_at_index(
- Create a ticketCreate a ticket
Function has_preceding_between_operator
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def has_preceding_between_operator(self) -> bool:
"""
True if this node has a preceding "between" operator at the same depth
"""
prev = (
- 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_included_paths
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _get_included_paths(paths: Iterable[Path], mode: Mode) -> Set[Path]:
"""
Takes a list of absolute 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)
- 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_with_comments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def render_with_comments(self, max_length: int) -> str:
"""
Returns a string that represents the properly-formatted Line,
including associated comments
"""
- 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 lex
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def lex(self, source_string: str, eof_pos: int = -1) -> None:
"""
Repeatedly match Rules to the source_string (until the source_string is
exhausted) and apply the matched action.
- 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"