c0fec0de/anytree

View on GitHub

Showing 6 of 17 total issues

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

    def by_attr(self, attrname="name"):
        """Return rendered tree with node attribute `attrname`."""
        def get():
            for pre, fill, node in self:
                attr = attrname(node) if callable(attrname) else getattr(node, attrname, "")
Severity: Minor
Found in anytree/render.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 findall_by_attr has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def findall_by_attr(node, value, name="name", maxlevel=None, mincount=None, maxcount=None):
Severity: Minor
Found in anytree/search.py - About 45 mins to fix

    Function findall has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def findall(node, filter_=None, stop=None, maxlevel=None, mincount=None, maxcount=None):
    Severity: Minor
    Found in anytree/search.py - About 45 mins to fix

      Function _findall has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _findall(node, filter_, stop=None, maxlevel=None, mincount=None, maxcount=None):
      Severity: Minor
      Found in anytree/search.py - About 45 mins to fix

        Function __iter has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __iter(self, indent, nodenamefunc, nodeattrfunc, edgeattrfunc, edgetypefunc):
        Severity: Minor
        Found in anytree/exporter/dotexporter.py - About 35 mins to fix

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

              def __item(node, continues, style):
                  if not continues:
                      return Row(u'', u'', node)
                  else:
                      items = [style.vertical if cont else style.empty for cont in continues]
          Severity: Minor
          Found in anytree/render.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