Arubacloud/pyArubaCloud

View on GitHub

Showing 30 of 94 total issues

File PyArubaAPI.py has 442 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import sys
from pprint import pprint

from ArubaCloud.base import Auth, JsonInterfaceBase
Severity: Minor
Found in ArubaCloud/PyArubaAPI.py - About 6 hrs to fix

    Function get_hypervisors has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_hypervisors(self):
            """
            Initialize the internal list containing each template available for each
            hypervisor.
    
    
    Severity: Minor
    Found in ArubaCloud/PyArubaAPI.py - About 6 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

    CloudInterface has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CloudInterface(JsonInterface):
        templates = []
        vmlist = VMList()
        iplist = IpList()
        json_templates = None
    Severity: Minor
    Found in ArubaCloud/PyArubaAPI.py - About 3 hrs to fix

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

          def get_servers(self):
              """
              Create the list of Server object inside the Datacenter objects.
              Build an internal list of VM Objects (pro or smart) as iterator.
              :return: bool
      Severity: Minor
      Found in ArubaCloud/PyArubaAPI.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 find_ip has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_ip(self, ip):
              f = None
              if ip.__class__ is 'base.Ip.Ip':
                  # logger.debug('DEBUG: matched IP Object: %s' % ip.__class__)
                  pattern = ip.ip_addr
      Severity: Minor
      Found in ArubaCloud/base/vm.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 create has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create(self, healthCheckNotification, instance, ipAddressResourceId, name, notificationContacts, rules,
      Severity: Major
      Found in ArubaCloud/Compute/LoadBalancer/LoadBalancer.py - About 1 hr to fix

        Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, healthCheckNotification, instance, ipAddressResourceId, loadBalancerClassOfServiceID, name,

          Function find_job has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def find_job(self, vm_name):
                  jobs_list = self.get_jobs()
                  if jobs_list['Value'] is None:
                      _i = 0
                      while jobs_list['Value'] is not None:
          Severity: Minor
          Found in ArubaCloud/PyArubaAPI.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 find has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def find(self, vm_name=None, ip_addr=None, resid=None):
                  # more defensive checks, just to have fun...
                  params = locals()
                  pattern = {}
                  ip = None
          Severity: Minor
          Found in ArubaCloud/objects/__init__.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, name, serverid, operationtype, start, end, DC, auth_obj):
          Severity: Major
          Found in ArubaCloud/objects/Scheduled.py - About 50 mins to fix

            Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, logger=None, Username=str(), Password=str(), SessionId=None, ApplicationId=None, RequestId=None,
            Severity: Major
            Found in ArubaCloud/base/__init__.py - About 50 mins to fix

              Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, balancerType, certificate, creationDate, id, instancePort, loadBalancerPort, protocol):
              Severity: Major
              Found in ArubaCloud/Compute/LoadBalancer/Models/NewLoadBalancerRule.py - About 50 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if resource_type == 1:
                                            o.resource_bounds.max_cpu = rb['Max']
                                        if resource_type == 2:
                Severity: Major
                Found in ArubaCloud/PyArubaAPI.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if resource_type == 8:
                                              o.resource_bounds.hdd2 = rb['Max']
                                          if resource_type == 9:
                  Severity: Major
                  Found in ArubaCloud/PyArubaAPI.py - About 45 mins to fix

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

                        def __init__(self, startDate, endDate, loadBalancerID, loadBalancerRuleID, *args, **kwargs):
                    Severity: Minor
                    Found in ArubaCloud/Compute/LoadBalancer/Requests/GetLoadBalancerNotifications.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if resource_type == 3:
                                                  o.resource_bounds.hdd0 = rb['Max']
                                              if resource_type == 7:
                      Severity: Major
                      Found in ArubaCloud/PyArubaAPI.py - About 45 mins to fix

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

                            def find_template(self, name=None, hv=None):
                                """
                                Return a list of templates that could have one or more elements.
                                Args:
                                    name: name of the template to find.
                        Severity: Minor
                        Found in ArubaCloud/PyArubaAPI.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 server_detail['ServerStatus'] == 3:
                                            break
                                        else:
                                            print('Waiting power on for other %s seconds' % sleep_for)
                                            time.sleep(sleep_for)
                        Severity: Major
                        Found in examples/forced_restart_vm.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if resource_type == 2:
                                                      o.resource_bounds.max_memory = rb['Max']
                                                  if resource_type == 3:
                          Severity: Major
                          Found in ArubaCloud/PyArubaAPI.py - About 45 mins to fix

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

                                def _log_request(logger, data=None, headers=None):
                                    if logger is not None:
                                        if headers is not None:
                                            for header in headers:
                                                logger.debug('request header: %s: %s', header, headers[header])
                            Severity: Minor
                            Found in ArubaCloud/helper/__init__.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

                            Severity
                            Category
                            Status
                            Source
                            Language