saltstack/salt

View on GitHub
salt/utils/powershell.py

Summary

Maintainability
A
3 hrs
Test Coverage

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

def get_modules():
    '''
    Get a list of the PowerShell modules which are potentially available to be
    imported. The intent is to mimic the functionality of ``Get-Module
    -ListAvailable | Select-Object -Expand Name``, without the delay of loading
Severity: Minor
Found in salt/utils/powershell.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

Avoid deeply nested control flow statements.
Open

                    if dir_name not in ret and \
                            base_name.lower() == dir_name.lower():
                        del sub_dirs[:]
                        ret.append(dir_name)

Severity: Major
Found in salt/utils/powershell.py - About 45 mins to fix

    There are no issues that match your filters.

    Category
    Status