CiscoUcs/ucsmsdk

View on GitHub
ucsmsdk/ucshandle.py

Summary

Maintainability
F
1 wk
Test Coverage

Function _get_transaction_impact has a Cognitive Complexity of 120 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_transaction_impact(self, rsp):
        """
        Outputs a json object, that can have the following keys,
            "failure", "warning", "reboot_user_ack", "reboot_immediate",
            "reboot_maintenance", "misc"
Severity: Minor
Found in ucsmsdk/ucshandle.py - About 2 days 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

File ucshandle.py has 812 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 at
Severity: Major
Found in ucsmsdk/ucshandle.py - About 1 day to fix

    Cyclomatic complexity is too high in method _get_transaction_impact. (45)
    Open

        def _get_transaction_impact(self, rsp):
            """
            Outputs a json object, that can have the following keys,
                "failure", "warning", "reboot_user_ack", "reboot_immediate",
                "reboot_maintenance", "misc"
    Severity: Minor
    Found in ucsmsdk/ucshandle.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    UcsHandle has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class UcsHandle(UcsSession):
        """
        UcsHandle class is the user interface point for any Ucs related communication.
    
        Args:
    Severity: Minor
    Found in ucsmsdk/ucshandle.py - About 4 hrs to fix

      Function commit has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def commit(self, tag=None, timeout=None):
              """
              Commit the buffer to the server. Pushes all the configuration changes
              so far to the server.
              Configuration could be added to the commit buffer using add_mo(),
      Severity: Minor
      Found in ucsmsdk/ucshandle.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

      Cyclomatic complexity is too high in method commit. (13)
      Open

          def commit(self, tag=None, timeout=None):
              """
              Commit the buffer to the server. Pushes all the configuration changes
              so far to the server.
              Configuration could be added to the commit buffer using add_mo(),
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method query_dns. (10)
      Open

          def query_dns(self, *dns):
              """
              Queries multiple obects from the server based of a comma separated list
              of their distinguised names.
      
      
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method query_classids. (10)
      Open

          def query_classids(self, *class_ids):
              """
              Queries multiple obects from the server based of a comma separated list
              of their class Ids.
      
      
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method process_xml_elem. (9)
      Open

          def process_xml_elem(self, elem, timeout=None):
              """
              process_xml_elem is a helper method which posts xml elements to the
              server and returns parsed response. It's role is to operate on the
              output of methods from ucsmethodfactory, which return xml element
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method query_children. (9)
      Open

          def query_children(self, in_mo=None, in_dn=None, class_id=None,
                             filter_str=None, hierarchy=False, timeout=None):
              """
              Finds children of a given managed object or distinguished name.
              Arguments can be specified to query only a specific type(class_id)
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method estimate_impact. (6)
      Open

          def estimate_impact(self, tag=None, timeout=None):
              from .ucsbasetype import ConfigMap, Pair
              from .ucsmethodfactory import config_estimate_impact
      
              tag = self._auto_set_tag_context(tag)
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method query_classid. (6)
      Open

          def query_classid(self, class_id=None, filter_str=None, hierarchy=False,
                            need_response=False, timeout=None):
              """
              Finds an object using it's class id.
      
      
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method query_dn. (6)
      Open

          def query_dn(self, dn, hierarchy=False, need_response=False, timeout=None):
              """
              Finds an object using it's distinguished name.
      
              Args:
      Severity: Minor
      Found in ucsmsdk/ucshandle.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function query_classids has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def query_classids(self, *class_ids):
              """
              Queries multiple obects from the server based of a comma separated list
              of their class Ids.
      
      
      Severity: Minor
      Found in ucsmsdk/ucshandle.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 process_xml_elem has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_xml_elem(self, elem, timeout=None):
              """
              process_xml_elem is a helper method which posts xml elements to the
              server and returns parsed response. It's role is to operate on the
              output of methods from ucsmethodfactory, which return xml element
      Severity: Minor
      Found in ucsmsdk/ucshandle.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 query_children has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def query_children(self, in_mo=None, in_dn=None, class_id=None,
                             filter_str=None, hierarchy=False, timeout=None):
              """
              Finds children of a given managed object or distinguished name.
              Arguments can be specified to query only a specific type(class_id)
      Severity: Minor
      Found in ucsmsdk/ucshandle.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 query_dns has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def query_dns(self, *dns):
              """
              Queries multiple obects from the server based of a comma separated list
              of their distinguised names.
      
      
      Severity: Minor
      Found in ucsmsdk/ucshandle.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, ip, username, password, port=None, secure=None,
      Severity: Major
      Found in ucsmsdk/ucshandle.py - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if l_type not in msg_buf:
                                    msg_buf[l_type] = []
        
        
        Severity: Major
        Found in ucsmsdk/ucshandle.py - About 45 mins to fix

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

              def estimate_impact(self, tag=None, timeout=None):
                  from .ucsbasetype import ConfigMap, Pair
                  from .ucsmethodfactory import config_estimate_impact
          
                  tag = self._auto_set_tag_context(tag)
          Severity: Minor
          Found in ucsmsdk/ucshandle.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 orig_server_mo.config_qualifier:
                                      params["pending"] = {
                                          "conf_qual": orig_server_mo.config_qualifier,
                                          "message": "Warning: Due to the presence of pre-existing configuration issues the impact of the current changes cannot be properly evaluated"
                                      }
          Severity: Major
          Found in ucsmsdk/ucshandle.py - About 45 mins to fix

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

                def wait_for_event(self, mo, prop, value, cb, timeout=None, poll_sec=None):
            Severity: Minor
            Found in ucsmsdk/ucshandle.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if each.dn == parent_dn:
                                          server_mo = each
                                          break
              
              
              Severity: Major
              Found in ucsmsdk/ucshandle.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (server_mo.config_state == "applied" and ack.config_issues !=
                                                "incompatible-bios-image" and ack.config_issues != "invalid-wwn"):
                                            l_type = "warning"
                                        else:
                                            l_type = "failure"
                Severity: Major
                Found in ucsmsdk/ucshandle.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if each.dn == parent_dn:
                                              orig_server_mo = each
                                              break
                  
                  
                  Severity: Major
                  Found in ucsmsdk/ucshandle.py - About 45 mins to fix

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

                        def query_children(self, in_mo=None, in_dn=None, class_id=None,
                    Severity: Minor
                    Found in ucsmsdk/ucshandle.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if l_type not in msg_buf:
                                                  msg_buf[l_type] = []
                      
                      
                      Severity: Major
                      Found in ucsmsdk/ucshandle.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if pending_ack and pending_ack.disr:
                                                    params["pending"] = {
                                                        "old_pn_dn": pending_ack.old_pn_dn,
                                                        "change_details": pending_ack.change_details,
                                                        "changed_by": pending_ack.change_by,
                        Severity: Major
                        Found in ucsmsdk/ucshandle.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if each.dn == parent_dn:
                                                      server_mo = each
                                                      break
                          
                          
                          Severity: Major
                          Found in ucsmsdk/ucshandle.py - About 45 mins to fix

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

                                def query_classid(self, class_id=None, filter_str=None, hierarchy=False,
                            Severity: Minor
                            Found in ucsmsdk/ucshandle.py - About 35 mins to fix

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

                                  def query_classid(self, class_id=None, filter_str=None, hierarchy=False,
                                                    need_response=False, timeout=None):
                                      """
                                      Finds an object using it's class id.
                              
                              
                              Severity: Minor
                              Found in ucsmsdk/ucshandle.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

                              Method "__init__" has 8 parameters, which is greater than the 7 authorized.
                              Open

                                  def __init__(self, ip, username, password, port=None, secure=None,
                                               proxy=None, timeout=None):
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py by sonar-python

                              A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

                              Noncompliant Code Example

                              With a maximum number of 4 parameters:

                              def do_something(param1, param2, param3, param4, param5):
                                  ...
                              

                              Compliant Solution

                              def do_something(param1, param2, param3, param4):
                                  ...
                              

                              Refactor this function to reduce its Cognitive Complexity from 122 to the 15 allowed.
                              Open

                                  def _get_transaction_impact(self, rsp):
                              Severity: Critical
                              Found in ucsmsdk/ucshandle.py by sonar-python

                              Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                              See

                              Refactor this function to reduce its Cognitive Complexity from 22 to the 15 allowed.
                              Open

                                  def commit(self, tag=None, timeout=None):
                              Severity: Critical
                              Found in ucsmsdk/ucshandle.py by sonar-python

                              Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                              See

                              Remove this commented out code.
                              Open

                                          # cat = self.AaaGetNComputeAuthTokenByDn(mo[0].Dn, 1, None)
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py by sonar-python

                              Programmers should not comment out code as it bloats programs and reduces readability.

                              Unused code should be deleted and can be retrieved from source control history if required.

                              See

                              • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
                              • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
                              • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
                              • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

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

                                      for dn in dns:
                                          if isinstance(dn, list):
                                              for each in dn:
                                                  dn_list.append(each.strip())
                                          elif isinstance(dn, str):
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py and 1 other location - About 2 hrs to fix
                              ucsmsdk/ucshandle.py on lines 312..317

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

                              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

                                      for class_id in class_ids:
                                          if isinstance(class_id, list):
                                              for each in class_id:
                                                  class_id_list.append(each.strip())
                                          elif isinstance(class_id, str):
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py and 1 other location - About 2 hrs to fix
                              ucsmsdk/ucshandle.py on lines 258..263

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

                              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 4 locations. Consider refactoring.
                              Open

                                      for pair in rsp.out_old_affected.child:
                                          for mo in pair.child:
                                              if not isinstance(mo, ManagedObject):
                                                  continue
                                              old_affected.append(mo)
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py and 3 other locations - About 1 hr to fix
                              ucsmsdk/ucshandle.py on lines 769..773
                              ucsmsdk/ucshandle.py on lines 775..779
                              ucsmsdk/ucshandle.py on lines 781..785

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

                              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 4 locations. Consider refactoring.
                              Open

                                      for pair in rsp.out_old_ackables.child:
                                          for mo in pair.child:
                                              if not isinstance(mo, ManagedObject):
                                                  continue
                                              old_ackables.append(mo)
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py and 3 other locations - About 1 hr to fix
                              ucsmsdk/ucshandle.py on lines 769..773
                              ucsmsdk/ucshandle.py on lines 775..779
                              ucsmsdk/ucshandle.py on lines 787..791

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

                              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 4 locations. Consider refactoring.
                              Open

                                      for pair in rsp.out_affected.child:
                                          for mo in pair.child:
                                              if not isinstance(mo, ManagedObject):
                                                  continue
                                              affected.append(mo)
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py and 3 other locations - About 1 hr to fix
                              ucsmsdk/ucshandle.py on lines 769..773
                              ucsmsdk/ucshandle.py on lines 781..785
                              ucsmsdk/ucshandle.py on lines 787..791

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

                              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 4 locations. Consider refactoring.
                              Open

                                      for pair in rsp.out_ackables.child:
                                          for mo in pair.child:
                                              if not isinstance(mo, ManagedObject):
                                                  continue
                                              ackables.append(mo)
                              Severity: Major
                              Found in ucsmsdk/ucshandle.py and 3 other locations - About 1 hr to fix
                              ucsmsdk/ucshandle.py on lines 775..779
                              ucsmsdk/ucshandle.py on lines 781..785
                              ucsmsdk/ucshandle.py on lines 787..791

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

                              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