systori/bericht

View on GitHub
bericht/html/css.py

Summary

Maintainability
F
4 days
Test Coverage

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

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

        def parse(self, src):
            for rule in parse_stylesheet(src, skip_comments=True, skip_whitespace=True):
                if isinstance(rule, ast.AtRule) and rule.at_keyword == 'page':
                    selectors = parse_selectors(rule.prelude)
                    for selector in selectors:
    Severity: Minor
    Found in bericht/html/css.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 parse_content_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_content_value(value):
        parts = []
        for part in value:
            if isinstance(part, ast.StringToken):
                parts.append(part.value)
    Severity: Minor
    Found in bericht/html/css.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

                        if token.value == 'first':
                            combinator.add(combinator.select_position, (0, 1))
                        elif token.value in ('last', 'last-child'):
                            combinator.add(combinator.select_last_child, True)
                        else:
    Severity: Major
    Found in bericht/html/css.py - About 45 mins to fix

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

          def apply(self, node):
              for selectors, declarations in self.rules:
                  for selector in selectors:
                      if selector.matches(node):
                          declarations.apply(node)
      Severity: Minor
      Found in bericht/html/css.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

      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

      There are no issues that match your filters.

      Category
      Status