QualiSystems/vCenterShell

View on GitHub

Showing 133 of 222 total issues

File vmomi_service.py has 613 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import time

import requests
from pyVmomi import vim

Severity: Major
Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py - About 1 day to fix

    File command_orchestrator.py has 469 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import time
    from datetime import datetime
    import jsonpickle
    
    from cloudshell.cp.vcenter.commands.vm_details import VmDetailsCommand
    Severity: Minor
    Found in package/cloudshell/cp/vcenter/commands/command_orchestrator.py - About 7 hrs to fix

      pyVmomiService has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class pyVmomiService:
          # region consts
          ChildEntity = 'childEntity'
          VM = 'vmFolder'
          Network = 'networkFolder'
      Severity: Minor
      Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py - About 5 hrs to fix

        File connect_orchestrator.py has 363 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import traceback
        from multiprocessing.pool import ThreadPool
        
        import jsonpickle
        
        
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/commands/connect_orchestrator.py - About 4 hrs to fix

          ConnectionCommandOrchestrator has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ConnectionCommandOrchestrator(object):
              def __init__(self, connector, disconnector, resource_model_parser):
                  """
          
                  :param connector:
          Severity: Minor
          Found in package/cloudshell/cp/vcenter/commands/connect_orchestrator.py - About 3 hrs to fix

            Function get_folder has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_folder(self, si, path, root=None):
                    """
                    Finds folder in the vCenter or returns "None"
            
                    :param si:         pyvmomi 'ServiceInstance'
            Severity: Minor
            Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.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

            VCenterAutoModelDiscovery has 27 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class VCenterAutoModelDiscovery(object):
                def __init__(self):
                    self.dc = None
                    self.parser = ResourceModelParser()
                    self.pv_service = pyVmomiService(SmartConnect, Disconnect, SynchronousTaskWaiter())
            Severity: Minor
            Found in package/cloudshell/cp/vcenter/common/vcenter/model_auto_discovery.py - About 3 hrs to fix

              File model_auto_discovery.py has 297 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import collections
              
              from pyVim.connect import SmartConnect, Disconnect
              from pyVmomi import vim
              
              
              Severity: Minor
              Found in package/cloudshell/cp/vcenter/common/vcenter/model_auto_discovery.py - About 3 hrs to fix

                CommandOrchestrator has 26 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class CommandOrchestrator(object):
                    def __init__(self):
                        """
                        Initialize the driver session, this function is called everytime a new instance of the driver is created
                        in here the driver is going to be bootstrapped
                Severity: Minor
                Found in package/cloudshell/cp/vcenter/commands/command_orchestrator.py - About 3 hrs to fix

                  VCenterShellDriver has 26 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class VCenterShellDriver(ResourceDriverInterface):
                      def cleanup(self):
                          pass
                  
                      def __init__(self):
                  Severity: Minor
                  Found in vcentershell_driver/driver.py - About 3 hrs to fix

                    Function is_vnic_attached_to_one_of_these_networks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def is_vnic_attached_to_one_of_these_networks(device, networks):
                            for network in networks:
                                if hasattr(device, 'backing'):
                                    found = False
                                    if hasattr(device.backing, 'port') and hasattr(device.backing.port, 'portgroupKey'):
                    Severity: Minor
                    Found in package/cloudshell/cp/vcenter/network/vnic/vnic_service.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

                    LinkedCloneArtifactHandler has 24 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class LinkedCloneArtifactHandler(object):
                        def __init__(self, pv_service, vcenter_data_model, si, logger, deployer, reservation_id,
                                     resource_model_parser, snapshot_saver, task_waiter, folder_manager, port_configurer,
                                     cancellation_service):
                            self.SNAPSHOT_NAME = 'artifact'

                      File vnic_service.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      # -*- coding: utf-8 -*-
                      
                      from pyVmomi import vim
                      from cloudshell.cp.vcenter.common.vcenter.vmomi_service import pyVmomiService
                      from cloudshell.cp.vcenter.network.network_specifications import network_is_standard, network_is_portgroup
                      Severity: Minor
                      Found in package/cloudshell/cp/vcenter/network/vnic/vnic_service.py - About 2 hrs to fix

                        Function erase_network_by_mapping has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def erase_network_by_mapping(self, networks, reserved_networks, logger):
                                nets = dict()
                                self._lock.acquire()
                                try:
                                    for net in networks:
                        Severity: Minor
                        Found in package/cloudshell/cp/vcenter/vm/portgroup_configurer.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

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

                        class VNicService(object):
                            def __init__(self):
                                super(VNicService, self).__init__()
                        
                            @staticmethod
                        Severity: Minor
                        Found in package/cloudshell/cp/vcenter/network/vnic/vnic_service.py - About 2 hrs to fix

                          Function _find_resource_pool has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def _find_resource_pool(self, name, root):
                                  if hasattr(root, 'resourcePool'):
                                      resource_pool = root.resourcePool
                                      if hasattr(resource_pool, 'name') and resource_pool.name == name:
                                          return resource_pool

                          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 wait_for_task has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def wait_for_task(task, raiseOnError=True, si=None, pc=None):
                              if si is None:
                                  si = GetSi()
                          
                              if pc is None:
                          Severity: Minor
                          Found in package/cloudshell/cp/vcenter/common/vcenter/test_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 get_ip has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def get_ip(self, vm, default_network, match_function, cancellation_context, timeout, logger):
                                  self._validate_vmware_tools_installed(logger, vm)
                                  ip = None
                                  reason = IpReason.Success
                                  if not timeout:
                          Severity: Minor
                          Found in package/cloudshell/cp/vcenter/vm/ip_manager.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 _get_snapshot has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def _get_snapshot(clone_params, template):
                                  snapshot_name = getattr(clone_params, 'snapshot', None)
                                  if not snapshot_name:
                                      return None
                          
                          
                          Severity: Minor
                          Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.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 _remove_vlan has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def _remove_vlan(self, action_mappings, si, vm_uuid, logger):
                                  final_res = []
                                  mode_to_actions = action_mappings.action_tree[ACTION_TYPE_REMOVE_VLAN]
                                  try:
                                      self.logger.info('disconnecting vm({0})'.format(vm_uuid))
                          Severity: Minor
                          Found in package/cloudshell/cp/vcenter/commands/connect_orchestrator.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

                          Severity
                          Category
                          Status
                          Source
                          Language