systori/bericht

View on GitHub
bericht/html/parser.py

Summary

Maintainability
D
2 days
Test Coverage

Function parse has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(self, parent):
        """
        https://www.w3.org/TR/html5/syntax.html
        See: 8.2.5 Tree construction
        """
Severity: Minor
Found in bericht/html/parser.py - About 1 day 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_column_widths has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def measure_column_widths(self):
        table_columns = []
        columns = None
        for box in self.boxes():
            if isinstance(box.behavior, TableRow):
Severity: Minor
Found in bericht/html/parser.py - About 3 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 get_behavior has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get_behavior(parent, node):

        display = node.style.display

        if display == 'block':
Severity: Minor
Found in bericht/html/parser.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 pumper has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def pumper(html_generator):
    """
    Pulls HTML from source generator,
    feeds it to the parser and yields
    DOM elements.
Severity: Minor
Found in bericht/html/parser.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

Avoid deeply nested control flow statements.
Open

                        if yield_root_table_rows and isinstance(child_node.behavior, TableRow):
                            self.css.apply_recursively(child_node)
                            yield child_element, child_node

Severity: Major
Found in bericht/html/parser.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            for hrow in table.thead.children:
                                columns.measure(hrow, table_columns[-1])
                        if table.tfoot:
    Severity: Major
    Found in bericht/html/parser.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if previous is not None:
                                  if node.text_allowed and previous[0].tail:
                                      # insert text between previous node and current node
                                      node.insert(len(node.children)-2, previous[0].tail)
                              position_of_type.setdefault(child_node.tag, 0)
      Severity: Major
      Found in bericht/html/parser.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for frow in table.tfoot.children:
                                    columns.measure(frow, table_columns[-1])
                        columns.measure(box, table_columns[-1])
        Severity: Major
        Found in bericht/html/parser.py - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

                          return TableRow(node)
          Severity: Major
          Found in bericht/html/parser.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return Block(node)
            Severity: Major
            Found in bericht/html/parser.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return TableColumnGroup(node)
              Severity: Major
              Found in bericht/html/parser.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return TableRowGroup(node)
                Severity: Major
                Found in bericht/html/parser.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return TableCell(node)
                  Severity: Major
                  Found in bericht/html/parser.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return TableColumn(node)
                    Severity: Major
                    Found in bericht/html/parser.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return ListItem(node)
                      Severity: Major
                      Found in bericht/html/parser.py - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status