QualiSystems/vCenterShell

View on GitHub

Showing 133 of 222 total issues

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

    def delete(self, delete_saved_app_actions, cancellation_context, pool):
        self.logger.info('Delete saved sandbox started')

        tasks = self._get_delete_tasks(delete_saved_app_actions)

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

    def find_portgroup(self, si, dv_switch_path, name):
        """
        Returns the portgroup on the dvSwitch
        :param name: str
        :param dv_switch_path: str
Severity: Minor
Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.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

Avoid too many return statements within this function.
Open

                return str(vlan_id)
Severity: Major
Found in package/cloudshell/cp/vcenter/vm/vm_details_provider.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return result
    Severity: Major
    Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return ''
      Severity: Major
      Found in package/cloudshell/cp/vcenter/vm/vm_details_provider.py - About 30 mins to fix

        Function _get_datastore has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_datastore(self, clone_params):
                datastore = ''
                parts = clone_params.datastore_name.split('/')
                if not parts:
                    raise ValueError('Datastore could not be empty')
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.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 _manage_power_during_save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _manage_power_during_save(self, save_action):
                # https://jeffknupp.com/blog/2016/03/07/python-with-context-managers/
        
                power_off_during_clone = self._should_vm_be_powered_off_during_clone(save_action)
        
        

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

        def get_error_message_from_exception(ex):
            error_message = ''  # traceback.format_exc()
            if hasattr(ex, 'message') and ex.message:
                error_message += ex.message
            elif hasattr(ex, 'msg') and ex.msg:
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/common/utilites/common_utils.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 _set_vlan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _set_vlan(self, action_mappings, si, vm_uuid, logger):
                results = []
                set_vlan_actions = action_mappings.action_tree[ACTION_TYPE_SET_VLAN]
                try:
                    self.logger.info('connecting vm({0})'.format(vm_uuid))
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/commands/connect_orchestrator.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 _group_vm_action_type_by_mode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _group_vm_action_type_by_mode(self, grouped_by_vm_by_requset):
                grouped_by_vm_by_requset_by_mode = dict()
                for machine, req_to_actions in grouped_by_vm_by_requset.items():
                    grouped_by_vm_by_requset_by_mode[machine] = dict()
                    for req_type, actions in req_to_actions.items():
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/commands/connect_orchestrator.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 print_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def print_attributes(obj, skip_private=True):
            for attr_name in dir(obj):
                if skip_private and attr_name.startswith("_"):
                    continue
                try:
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/common/utilites/debug.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 remove_interfaces_from_vm_task has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def remove_interfaces_from_vm_task(self, virtual_machine, filter_function=None):
                """
                Remove interface from VM
                @see https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.VirtualMachine.html#reconfigure
                :param virtual_machine: <vim.vm object>
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/commands/disconnect_dvswitch.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 _disconnect_all_my_connectors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _disconnect_all_my_connectors(session, resource_name, reservation_id, logger):
                """
                :param CloudShellAPISession session:
                :param str resource_name:
                :param str reservation_id:
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/commands/DeleteInstance.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

        Severity
        Category
        Status
        Source
        Language