Stibbons/dopplerr

View on GitHub
cfgtree/dictxpath.py

Summary

Maintainability
D
1 day
Test Coverage

Function get_node_by_xpath has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

def get_node_by_xpath(mapping, xpath, default=None, ignore_errors=False,
                      handle_list_selector=False):
    '''Return the node pointed to by xpath from mapping.

    Args:
Severity: Minor
Found in cfgtree/dictxpath.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

Avoid deeply nested control flow statements.
Open

                    if key not in mapping:
                        if not ignore_errors:
                            raise KeyError("Invalid '{}' index selector: '{}' does not match "
                                           "anything. Available keys: {!r}".format(
                                               xpath, key, list(mapping.keys())))
Severity: Major
Found in cfgtree/dictxpath.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if len(items) <= index:
                            if not ignore_errors:
                                raise KeyError("Invalid '{}' selector: item index '{}' of '{}' is "
                                               "outside of the list boundaries. Length is: {}".format(
                                                   xpath, index, key, len(items)))
    Severity: Major
    Found in cfgtree/dictxpath.py - About 45 mins to fix

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

      def set_node_by_xpath(mapping, xpath, value, extend=False, setter_attr=None):
          '''Set the node pointed to by xpath from mapping.
      
          Args:
              mapping: nested dictionary.
      Severity: Minor
      Found in cfgtree/dictxpath.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 not isinstance(items, list):
                              if not ignore_errors:
                                  raise KeyError("Invalid '{}' selector: '{}' is not a list, is: {}"
                                                 .format(xpath, key, type(items)))
                              return default
      Severity: Major
      Found in cfgtree/dictxpath.py - About 45 mins to fix

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

        def set_node_by_xpath(mapping, xpath, value, extend=False, setter_attr=None):
        Severity: Minor
        Found in cfgtree/dictxpath.py - About 35 mins to fix

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

          def get_node_by_xpath(mapping, xpath, default=None, ignore_errors=False,
          Severity: Minor
          Found in cfgtree/dictxpath.py - About 35 mins to fix

            Avoid too many return statements within this function.
            Open

                                    return default
            Severity: Major
            Found in cfgtree/dictxpath.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return default
              Severity: Major
              Found in cfgtree/dictxpath.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return mapping
                Severity: Major
                Found in cfgtree/dictxpath.py - About 30 mins to fix

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

                  def delete_node_by_xpath(mapping, xpath, ignore_errors=False):
                      '''Delete the node pointed to by xpath from mapping.
                  
                      Args:
                          mapping: nested dictionary.
                  Severity: Minor
                  Found in cfgtree/dictxpath.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

                  There are no issues that match your filters.

                  Category
                  Status