saltstack/salt

View on GitHub
salt/utils/path.py

Summary

Maintainability
C
1 day
Test Coverage

File path.py has 307 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Platform independent versions of some os/os.path functions. Gets around PY2's
lack of support for reading NTFS links.
'''
Severity: Minor
Found in salt/utils/path.py - About 3 hrs to fix

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

    def which(exe=None):
        '''
        Python clone of /usr/bin/which
        '''
    
    
    Severity: Minor
    Found in salt/utils/path.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 safe_path has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def safe_path(path, allow_path=None):
        r'''
        .. versionadded:: 2017.7.3
    
        Checks that the path is safe for modification by Salt. For example, you
    Severity: Minor
    Found in salt/utils/path.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 readlink has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def readlink(path):
        '''
        Equivalent to os.readlink()
        '''
        if six.PY3 or not salt.utils.platform.is_windows():
    Severity: Minor
    Found in salt/utils/path.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 join has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def join(*parts, **kwargs):
        '''
        This functions tries to solve some issues when joining multiple absolute
        paths on both *nix and windows platforms.
    
    
    Severity: Minor
    Found in salt/utils/path.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

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

    def islink(path):
        '''
        Equivalent to os.path.islink()
        '''
        if six.PY3 or not salt.utils.platform.is_windows():
    Severity: Minor
    Found in salt/utils/path.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 True
    Severity: Major
    Found in salt/utils/path.py - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status