systori/bericht

View on GitHub
bericht/html/box.py

Summary

Maintainability
D
2 days
Test Coverage

Function draw has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    def draw(self, page, x, y):
        final_x, final_y = x, y - self.box.height
        style = self.box.style
        width = self.box.width - self.frame_width
        txt = page.begin_text(x, y)
Severity: Minor
Found in bericht/html/box.py - About 5 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

File box.py has 356 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from copy import copy
from string import whitespace
from reportlab.pdfbase.pdfmetrics import stringWidth, getFont, getAscentDescent
from .style import TextAlign, default as default_style, VerticalAlign

Severity: Minor
Found in bericht/html/box.py - About 4 hrs to fix

    Function boxes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def boxes(self):
            words = []
            word_open = False
            for box, parent in self.traverse():
                if isinstance(box, str):
    Severity: Minor
    Found in bericht/html/box.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 split has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def split(self, top_parent, bottom_parent, available_height, css):
    
            if not self.box.lines:
                return (
                    self.clone(top_parent, [], css),
    Severity: Minor
    Found in bericht/html/box.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

    Function wrap has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def wrap(self, page, available_width):
            self.box.width = available_width
            available_width -= self.frame_width
            self.box.height = 0
    
    
    Severity: Minor
    Found in bericht/html/box.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 deeply nested control flow statements.
    Open

                            for part in word.parts:
                                if style != part.style:
                                    if fragments:
                                        txt.draw(''.join(fragments))
                                        fragments = []
    Severity: Major
    Found in bericht/html/box.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

              return (
      Severity: Major
      Found in bericht/html/box.py - About 30 mins to fix

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

            def clone(self, parent, lines, css):
                box = Box(parent or self.box.parent, self.box.tag, self.box.attrs)
                box.behavior = copy(self)
                box.behavior.box = box
                box.position = self.box.position
        Severity: Minor
        Found in bericht/html/box.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