Hrabal/TemPy

View on GitHub

Showing 35 of 205 total issues

Function to_code has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def to_code(self, pretty=False):
        ret = []
        prettying = "\n" + ("\t" * self._depth) if pretty else ""
        childs_to_code = []
        for child in self.childs:
Severity: Minor
Found in tempy/renderer.py - About 55 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

Function _make_tempy_tag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _make_tempy_tag(self, tag, attrs, void):
        """Searches in tempy.tags for the correct tag to use, if does not exists uses the TempyFactory to
        create a custom tag."""
        tempy_tag_cls = getattr(self.tempy_tags, tag.title(), None)
        if not tempy_tag_cls:
Severity: Minor
Found in tempy/t.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

Function _render_parents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _render_parents(self, parents, result):
        gen = [parent for parent in parents] if parents else []
        for parent in gen:
            if isinstance(parent, tuple):
                result.append(", ".join(parent))
Severity: Minor
Found in tempy/css.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

Function render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def render(self, *args, **kwargs):
        pretty = kwargs.pop("pretty", False)
        ret = []
        for content in self.content:
            if content is None:
Severity: Minor
Found in tempy/content.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

Function _filter_classes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _filter_classes(cls_list, cls_type):
        """Filters a list of classes and yields TempyREPR subclasses"""
        for cls in cls_list:
            if isinstance(cls, type) and issubclass(cls, cls_type):
                if cls_type == TempyPlace and cls._base_place:
Severity: Minor
Found in tempy/renderer.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

Function apply_function has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def apply_function(self, format_function):
        for (index, child) in enumerate(self.childs):
            if child is not None:
                if isinstance(child, TempyClass):
                    child.apply_function(format_function)
Severity: Minor
Found in tempy/elements.py - About 35 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

Function populate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def populate(self, struct):
        """Generates the list tree.
        struct: if a list/set/tuple is given, a flat list is generated
        <*l><li>v1</li><li>v2</li>...</*l>
        If the list type is 'Dl' a flat list without definitions is generated
Severity: Minor
Found in tempy/widgets/tempylist.py - About 35 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

Function dfs_inorder has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def dfs_inorder(self, reverse=False):
        """Generator that returns each element of the tree in Inorder order.
        Keyword arguments:
        reverse -- if true, the search is done from right to left."""
        stack = deque()
Severity: Minor
Found in tempy/navigator.py - About 35 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

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

    def __init__(self, rows=0, cols=0, data=None, **kwargs):
        caption = kwargs.pop("caption", None)
        head = kwargs.pop("head", False)
        foot = kwargs.pop("foot", False)
        super().__init__(**kwargs)
Severity: Minor
Found in tempy/widgets/tempytable.py - About 35 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

Function to_code_attrs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def to_code_attrs(self):
        def formatter(k, v):
            k_norm = twist_specials.get(k, k)
            if k in self._SET_VALUES_ATTRS:
                return '%s="%s"' % (k_norm, ", ".join(map(str, v)))
Severity: Minor
Found in tempy/renderer.py - About 35 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

Function css has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def css(self, *props, **kwprops):
        """Adds css properties to this element."""
        if props:
            if len(props) == 1 and isinstance(props[0], Mapping):
                styles = props[0]
Severity: Minor
Found in tempy/elements.py - About 35 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

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

    def _parse__args(self, *args, **kwargs):
        css_styles = {}

        if len(args) > 1:
            raise WrongContentError(self, args, "Css accepts max one positional argument.")
Severity: Minor
Found in tempy/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

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

    def _match_selector(el, selector):
        if not selector:
            return True
        if inspect.isclass(selector) and isinstance(el, selector):
            return True
Severity: Minor
Found in tempy/navigator.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

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

    def render(self, *args, **kwargs):
        pretty = kwargs.pop("pretty", False)
        result = []
        nodes_to_parse = [([], self.attrs["css_attrs"])]

Severity: Minor
Found in tempy/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

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

    def map_col(self, col_function, col_index=None, ignore_errors=True):
        # applies function to every cell
        if col_index is None:
            self.map_table(col_function)
            return self
Severity: Minor
Found in tempy/widgets/tempytable.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

Severity
Category
Status
Source
Language