CiscoUcs/imcsdk

View on GitHub
imcsdk/imcmo.py

Summary

Maintainability
F
6 days
Test Coverage

File imcmo.py has 585 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2015 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License prop
Severity: Major
Found in imcsdk/imcmo.py - About 1 day to fix

    Function to_xml has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_xml(self, xml_doc=None, option=None, elem_name=None, cookie=None):
            """
            Method writes the xml representation of the managed object.
            """
    
    
    Severity: Minor
    Found in imcsdk/imcmo.py - About 7 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 from_xml has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_xml(self, elem, handle=None):
            """
            Method updates the object from the xml representation of the managed
            object.
            """
    Severity: Minor
    Found in imcsdk/imcmo.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

    Function from_xml has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_xml(self, elem, handle=None):
            """
            This method is form objects out of xml element.
            This is called internally from imcxmlcode.from_xml_str
            method.
    Severity: Minor
    Found in imcsdk/imcmo.py - About 2 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 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, class_id, parent_mo_or_dn=None, **kwargs):
    
            self.__properties = {}
    
            if isinstance(parent_mo_or_dn, GenericMo):
    Severity: Minor
    Found in imcsdk/imcmo.py - About 2 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 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(
                self,
                class_id,
                parent_mo_or_dn=None,
                from_xml_response=False,
    Severity: Minor
    Found in imcsdk/imcmo.py - About 2 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 __setattr__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def __setattr__(self, name, value):
            """
            overridden setattr method
            """
    
    
    Severity: Minor
    Found in imcsdk/imcmo.py - About 2 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 __get_mo_obj has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def __get_mo_obj(self, class_id):
            """
            Internal methods to create managed object from class_id
            """
    
    
    Severity: Minor
    Found in imcsdk/imcmo.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 __set_prop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __set_prop(self, name, value, mark_dirty=True, forced=False):
            """
            Internal method to set the properties after validation
    
            Args:
    Severity: Minor
    Found in imcsdk/imcmo.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 make_rn has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_rn(self):
            """
            This method returns the Rn for a managed object.
            """
    
    
    Severity: Minor
    Found in imcsdk/imcmo.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 to_mo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_mo(self):
            """
            Converts GenericMo to ManagedObject
            """
    
    
    Severity: Minor
    Found in imcsdk/imcmo.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

    Avoid deeply nested control flow statements.
    Open

                            if handle and not (mo_meta.name.startswith("BiosVf") and prop.name.startswith("vp")):
                                if prop.version <= handle.version:
                                    xml_obj.set(prop.xml_attribute, value)
                                else:
                                    log.debug('## Not sending property: %s' % prop.name)
    Severity: Major
    Found in imcsdk/imcmo.py - About 45 mins to fix

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

          def check_prop_match(self, **kwargs):
              for prop_name in kwargs:
                  if kwargs[prop_name] is None:
                      continue
                  if not imccoreutils.prop_exists(self, prop_name):
      Severity: Minor
      Found in imcsdk/imcmo.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 validate_inputs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_inputs(self, **kwargs):
              validation_errors = []
              for prop in kwargs:
                  if not imccoreutils.prop_exists(self, prop):
                      continue
      Severity: Minor
      Found in imcsdk/imcmo.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 __str__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __str__(self):
              ts = 8
              if isinstance(self, GenericMo):
                  out_str = "\n"
                  out_str += 'GenericMo'.ljust(ts * 4) + ':' + str(
      Severity: Minor
      Found in imcsdk/imcmo.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 __str__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __str__(self):
              """
              Method to return string representation of a managed object.
              """
      
      
      Severity: Minor
      Found in imcsdk/imcmo.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 sync_mo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def sync_mo(self, mo):
              """
              Method to return string representation of a managed object.
              """
      
      
      Severity: Minor
      Found in imcsdk/imcmo.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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              elif self.rn and not self.dn:
                  if self.__parent_dn and self.__parent_dn != "":
                      self.dn = self.__parent_dn + '/' + self.rn
                      self.__properties['dn'] = self.dn
                  else:
      Severity: Major
      Found in imcsdk/imcmo.py and 1 other location - About 4 hrs to fix
      imcsdk/imcmo.py on lines 541..547

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              elif 'rn' in dir(self) and 'dn' not in dir(self):
                  if self.__parent_dn and self.__parent_dn != "":
                      self.dn = self.__parent_dn + '/' + self.rn
                      self.__properties['dn'] = self.dn
                  else:
      Severity: Major
      Found in imcsdk/imcmo.py and 1 other location - About 4 hrs to fix
      imcsdk/imcmo.py on lines 629..635

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

      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

                  out_str += str(prop).ljust(ts * 4) + ':' + str(
                      prop_value) + "\n"
      Severity: Major
      Found in imcsdk/imcmo.py and 2 other locations - About 1 hr to fix
      imcsdk/imcmethod.py on lines 174..175
      imcsdk/imcmo.py on lines 732..732

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

      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

                      out_str += str(prop).ljust(ts * 4) + ':' + str(prop_val) + "\n"
      Severity: Major
      Found in imcsdk/imcmo.py and 2 other locations - About 1 hr to fix
      imcsdk/imcmethod.py on lines 174..175
      imcsdk/imcmo.py on lines 255..256

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              elif not self.rn and self.dn:
                  self.rn = os.path.basename(self.dn)
                  self.__properties['rn'] = self.rn
      Severity: Minor
      Found in imcsdk/imcmo.py and 1 other location - About 35 mins to fix
      imcsdk/imcmo.py on lines 548..550

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              elif 'rn' not in dir(self) and 'dn' in dir(self):
                  self.rn = os.path.basename(self.dn)
                  self.__properties['rn'] = self.rn
      Severity: Minor
      Found in imcsdk/imcmo.py and 1 other location - About 35 mins to fix
      imcsdk/imcmo.py on lines 636..638

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

      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