tconbeer/sqlfmt

View on GitHub

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
Severity: Minor
Found in src/sqlfmt/jinjafmt.py - About 55 mins to fix

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).
Severity: Minor
Found in src/sqlfmt/jinjafmt.py - About 55 mins to fix

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 9 (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
Severity: Minor
Found in src/sqlfmt/comment.py - About 55 mins to fix

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 add_node_to_buffer has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def add_node_to_buffer(
Severity: Minor
Found in src/sqlfmt/actions.py - About 45 mins to fix

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.
Severity: Minor
Found in src/sqlfmt/cli.py - About 45 mins to fix

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.
    """
Severity: Minor
Found in src/sqlfmt/config.py - About 45 mins to fix

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(
Severity: Minor
Found in src/sqlfmt/actions.py - About 45 mins to fix

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
Severity: Minor
Found in src/sqlfmt/merger.py - About 45 mins to fix

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_jinja has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def handle_jinja(
Severity: Minor
Found in src/sqlfmt/actions.py - About 45 mins to fix

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
Severity: Minor
Found in src/sqlfmt/jinjafmt.py - About 45 mins to fix

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(
Severity: Minor
Found in src/sqlfmt/analyzer.py - About 45 mins to fix

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 (
Severity: Major
Found in src/sqlfmt/line.py - About 40 mins to fix

Function handle_jinja_data_block_start has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def handle_jinja_data_block_start(
Severity: Minor
Found in src/sqlfmt/actions.py - About 35 mins to fix

Function safe_add_node_to_buffer has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def safe_add_node_to_buffer(
Severity: Minor
Found in src/sqlfmt/actions.py - About 35 mins to fix

Function sqlfmt_primer has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def sqlfmt_primer(
Severity: Minor
Found in src/sqlfmt_primer/primer.py - About 35 mins to fix

Function split_at_index has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def split_at_index(
Severity: Minor
Found in src/sqlfmt/splitter.py - About 35 mins to fix

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.

Severity: Minor
Found in src/sqlfmt/analyzer.py - About 35 mins to fix

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
        """
Severity: Minor
Found in src/sqlfmt/line.py - About 35 mins to fix

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 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 = (
Severity: Minor
Found in src/sqlfmt/node.py - About 35 mins to fix

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 _stubbornly_merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _stubbornly_merge(
        self, prev_segments: List[Segment], segment: Segment
    ) -> List[Segment]:
        """
        Attempts several different methods of merging the last segment in
Severity: Minor
Found in src/sqlfmt/merger.py - About 35 mins to fix

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

Severity
Category
Status
Source
Language