tconbeer/sqlfmt

View on GitHub
src/sqlfmt/line.py

Summary

Maintainability
B
5 hrs
Test Coverage
A
100%

Line has 29 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.
    """
Severity: Minor
Found in src/sqlfmt/line.py - About 3 hrs 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 starts_new_segment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Wontfix

    def starts_new_segment(self, prev_segment_depth: Tuple[int, int]) -> bool:
        if self.depth <= prev_segment_depth or self.depth[1] < prev_segment_depth[1]:
            # if this line starts with a closing bracket,
            # we want to include that closing bracket
            # in the same segment as the first line.
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 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 opens_new_bracket has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def opens_new_bracket(self) -> bool:
        """
        Returns True iff the Nodes in this Line open a new explicit bracket and do
        not also close that bracket
        """
Severity: Minor
Found in src/sqlfmt/line.py - About 25 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

There are no issues that match your filters.

Category
Status