saltstack/salt

View on GitHub
salt/utils/azurearm.py

Summary

Maintainability
D
1 day
Test Coverage

Function create_object_model has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

def create_object_model(module_name, object_name, **kwargs):
    '''
    Assemble an object from incoming parameters.
    '''
    object_kwargs = {}
Severity: Minor
Found in salt/utils/azurearm.py - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function compare_list_of_dicts has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def compare_list_of_dicts(old, new, convert_id_to_name=None):
    '''
    Compare lists of dictionaries representing Azure objects. Only keys found in the "new" dictionaries are compared to
    the "old" dictionaries, since getting Azure objects from the API returns some read-only data which should not be
    used in the comparison. A list of parameter names can be passed in order to compare a bare object name to a full
Severity: Minor
Found in salt/utils/azurearm.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

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

def _determine_auth(**kwargs):
    '''
    Acquire Azure ARM Credentials
    '''
    if 'profile' in kwargs:
Severity: Minor
Found in salt/utils/azurearm.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

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

# -*- coding: utf-8 -*-
'''
Azure (ARM) Utilities

.. versionadded:: 2019.2.0
Severity: Minor
Found in salt/utils/azurearm.py - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                        for list_item in param:
                            if items['type'][1].isupper() and isinstance(list_item, dict):
                                obj_list.append(
                                    create_object_model(
                                        module_name,
    Severity: Major
    Found in salt/utils/azurearm.py - About 45 mins to fix

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

      def get_client(client_type, **kwargs):
          '''
          Dynamically load the selected client and return a management client object
          '''
          client_map = {'compute': 'ComputeManagement',
      Severity: Minor
      Found in salt/utils/azurearm.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 ret
      Severity: Major
      Found in salt/utils/azurearm.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return ret
        Severity: Major
        Found in salt/utils/azurearm.py - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status