systori/bericht

View on GitHub
bericht/html/table.py

Summary

Maintainability
D
2 days
Test Coverage

File table.py has 422 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from .box import Box, Behavior, flatten
from .style import BorderCollapse, VerticalAlign


__all__ = (
Severity: Minor
Found in bericht/html/table.py - About 6 hrs to fix

    Function table_old_split has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def table_old_split(self, available_width, available_height):
            if self.content_heights is None:
                self.wrap(available_width)
    
            assert self.content_heights, "Split called on empty table."
    Severity: Minor
    Found in bericht/html/table.py - About 2 hrs 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 _draw has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def _draw(self, page, x, y):
            original_x, original_y = x, y
            if self.collapsed:
                x += self.horizontal_spacing / 2.0
            y -= self.frame_top
    Severity: Minor
    Found in bericht/html/table.py - About 2 hrs 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 _wrap has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def _wrap(self, page, available_width):
            table = self.box.parent.parent.behavior
            children = self.box.children
            column_widths = table.get_column_widths(available_width)
            self.box.width = available_width
    Severity: Minor
    Found in bericht/html/table.py - About 2 hrs 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 measure has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def measure(self, row, data):
            maximums = data['maximums']
            if not self.box.children:
                data['span'] = max(data['span'], len(row.children))
                return
    Severity: Minor
    Found in bericht/html/table.py - About 1 hr 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

    Avoid too many return statements within this function.
    Open

            return [] if not top_rows else [
    Severity: Major
    Found in bericht/html/table.py - About 30 mins to fix

      Function calculate_widths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def calculate_widths(self, available_width):
      
              widths = self.measurements.copy()
      
              fixed = sum(widths)
      Severity: Minor
      Found in bericht/html/table.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