saltstack/salt

View on GitHub
salt/utils/odict.py

Summary

Maintainability
D
1 day
Test Coverage

Function update has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

            def update(*args, **kwds):  # pylint: disable=E0211
                '''od.update(E, **F) -> None.  Update od from dict/iterable E and F.

                If E is a dict instance, does:           for k in E: od[k] = E[k]
                If E has a .keys() method, does:         for k in E.keys(): od[k] = E[k]
Severity: Minor
Found in salt/utils/odict.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

OrderedDict has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

        class OrderedDict(dict):
            'Dictionary that remembers insertion order'
            # An inherited dict maps keys to values.
            # The inherited dict provides __getitem__, __len__, __contains__, and get.
            # The remaining methods are order-aware.
Severity: Minor
Found in salt/utils/odict.py - About 2 hrs to fix

    File odict.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    '''
        :codeauthor: Pedro Algarvio (pedro@algarvio.me)
    
    
    
    Severity: Minor
    Found in salt/utils/odict.py - About 2 hrs to fix

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

                  def popitem(self, last=True):
                      '''od.popitem() -> (k, v), return and remove a (key, value) pair.
                      Pairs are returned in LIFO order if last is true or FIFO order if false.
      
                      '''
      Severity: Minor
      Found in salt/utils/odict.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 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def __init__(self, *args, **kwds):  # pylint: disable=E1003
                      '''Initialize an ordered dictionary.  Signature is the same as for
                      regular dictionaries, but keyword arguments are not recommended
                      because their insertion order is arbitrary.
      
      
      Severity: Minor
      Found in salt/utils/odict.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 pop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def pop(self, key, default=__marker):
                      '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
                      If key is not found, d is returned if given, otherwise KeyError is raised.
      
                      '''
      Severity: Minor
      Found in salt/utils/odict.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 __repr__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def __repr__(self, _repr_running={}):  # pylint: disable=W0102
                      'od.__repr__() <==> repr(od)'
                      call_key = id(self), _get_ident()
                      if call_key in _repr_running:
                          return '...'
      Severity: Minor
      Found in salt/utils/odict.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 clear has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def clear(self):
                      'od.clear() -> None.  Remove all items from od.'
                      try:
                          for node in six.itervalues(self.__map):
                              del node[:]
      Severity: Minor
      Found in salt/utils/odict.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 __reduce__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def __reduce__(self):
                      'Return state information for pickling'
                      items = [[k, self[k]] for k in self]
                      inst_dict = vars(self).copy()
                      for k in vars(OrderedDict()):
      Severity: Minor
      Found in salt/utils/odict.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 2 locations. Consider refactoring.
      Open

                  def __iter__(self):
                      'od.__iter__() <==> iter(od)'
                      root = self.__root
                      curr = root[1]
                      while curr is not root:
      Severity: Major
      Found in salt/utils/odict.py and 1 other location - About 2 hrs to fix
      salt/utils/odict.py on lines 121..127

      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 59.

      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

                  def __reversed__(self):
                      'od.__reversed__() <==> reversed(od)'
                      root = self.__root
                      curr = root[0]
                      while curr is not root:
      Severity: Major
      Found in salt/utils/odict.py and 1 other location - About 2 hrs to fix
      salt/utils/odict.py on lines 113..119

      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 59.

      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