systori/bericht

View on GitHub

Showing 55 of 55 total issues

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

def parse_selectors(prelude):
    selectors = []
    combinator = None
    combinators = []
    prefix = None
Severity: Minor
Found in bericht/html/css.py - About 6 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 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 draw has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def draw(self, txt, new_line=False):
            doc = self.page.document
            font = getFont(self.font_name)
            if font._dynamicFont:
                for subset, t in font.splitString(txt, doc):
    Severity: Minor
    Found in bericht/pdf/text.py - About 6 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 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

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        elif len(values) == 2:
            attrs[attr.format('top')] = values[0]
            attrs[attr.format('right')] = values[1]
            attrs[attr.format('bottom')] = values[0]
            attrs[attr.format('left')] = values[1]
    Severity: Major
    Found in bericht/html/css.py and 2 other locations - About 5 hrs to fix
    bericht/html/css.py on lines 180..184
    bericht/html/css.py on lines 190..194

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        if len(values) == 1:
            attrs[attr.format('top')] = values[0]
            attrs[attr.format('right')] = values[0]
            attrs[attr.format('bottom')] = values[0]
            attrs[attr.format('left')] = values[0]
    Severity: Major
    Found in bericht/html/css.py and 2 other locations - About 5 hrs to fix
    bericht/html/css.py on lines 185..189
    bericht/html/css.py on lines 190..194

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        elif len(values) == 3:
            attrs[attr.format('top')] = values[0]
            attrs[attr.format('right')] = values[1]
            attrs[attr.format('bottom')] = values[2]
            attrs[attr.format('left')] = values[1]
    Severity: Major
    Found in bericht/html/css.py and 2 other locations - About 5 hrs to fix
    bericht/html/css.py on lines 180..184
    bericht/html/css.py on lines 185..189

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function __init__ has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, content):
            self.content = content
            self.attrs = {}
            for declaration in parse_declaration_list(content, skip_comments=True, skip_whitespace=True):
                if isinstance(declaration, ast.AtRule):
    Severity: Minor
    Found in bericht/html/css.py - About 4 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 __iter__ has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def __iter__(self):
              yield from self.pdf.header()
              page = None
              for block in self.generator:
                  while block:
      Severity: Minor
      Found in bericht/pdf/stream.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 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      Severity: Major
      Found in example/tables.py and 1 other location - About 2 hrs to fix
      example/sans_close_tags.py on lines 0..88

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 61.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      Severity: Major
      Found in example/sans_close_tags.py and 1 other location - About 2 hrs to fix
      example/tables.py on lines 0..68

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 61.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

      File css.py has 280 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from os.path import dirname, join
      from tinycss2 import (
          parse_stylesheet, parse_declaration_list,
          ast, nth, color3
      )
      Severity: Minor
      Found in bericht/html/css.py - About 2 hrs to fix

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

        def serialize(meta):
            if isinstance(meta, dict):
                yield b'<<'
                for key, value in meta.items():
                    if not key.startswith('/'):
        Severity: Minor
        Found in bericht/pdf/reference.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                            if name is None:
                                name = doc.fontMapping[f.fontName] = '/F{}'.format(len(doc.fontMapping)+1)
                                doc.delayedFonts.append(f)
        Severity: Major
        Found in bericht/pdf/text.py and 1 other location - About 2 hrs to fix
        bericht/pdf/text.py on lines 49..51

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 55.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language