saltstack/salt

View on GitHub
salt/grains/core.py

Summary

Maintainability
F
1 mo
Test Coverage

Function os_data has a Cognitive Complexity of 317 (exceeds 5 allowed). Consider refactoring.
Open

def os_data():
    '''
    Return grains pertaining to the operating system
    '''
    grains = {
Severity: Minor
Found in salt/grains/core.py - About 6 days 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 core.py has 2280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
The static grains, these are the core, or built in grains.

When grains are loaded they are not loaded in the same way that modules are
Severity: Major
Found in salt/grains/core.py - About 6 days to fix

    Function _virtual has a Cognitive Complexity of 293 (exceeds 5 allowed). Consider refactoring.
    Open

    def _virtual(osdata):
        '''
        Returns what type of virtual hardware is under the hood, kvm or physical
        '''
        # This is going to be a monster, if you are running a vm you can test this
    Severity: Minor
    Found in salt/grains/core.py - About 6 days 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 _hw_data has a Cognitive Complexity of 149 (exceeds 5 allowed). Consider refactoring.
    Open

    def _hw_data(osdata):
        '''
        Get system specific hardware data from dmidecode
    
        Provides
    Severity: Minor
    Found in salt/grains/core.py - About 3 days 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

    Cyclomatic complexity is too high in function _virtual. (152)
    Open

    def _virtual(osdata):
        '''
        Returns what type of virtual hardware is under the hood, kvm or physical
        '''
        # This is going to be a monster, if you are running a vm you can test this
    Severity: Minor
    Found in salt/grains/core.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in function os_data. (124)
    Open

    def os_data():
        '''
        Return grains pertaining to the operating system
        '''
        grains = {
    Severity: Minor
    Found in salt/grains/core.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in function _hw_data. (88)
    Open

    def _hw_data(osdata):
        '''
        Get system specific hardware data from dmidecode
    
        Provides
    Severity: Minor
    Found in salt/grains/core.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function _bsd_cpudata has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    def _bsd_cpudata(osdata):
        '''
        Return CPU information for BSD-like systems
        '''
        # Provides:
    Severity: Minor
    Found in salt/grains/core.py - About 5 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 _linux_gpu_data has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def _linux_gpu_data():
        '''
        num_gpus: int
        gpus:
          - vendor: nvidia|amd|ati|...
    Severity: Minor
    Found in salt/grains/core.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 _clean_value has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _clean_value(key, val):
        '''
        Clean out well-known bogus values.
        If it isn't clean (for example has value 'None'), return None.
        Otherwise, return the original value.
    Severity: Minor
    Found in salt/grains/core.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 _windows_os_release_grain has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _windows_os_release_grain(caption, product_type):
        '''
        helper function for getting the osrelease grain
        :return:
        '''
    Severity: Minor
    Found in salt/grains/core.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 default_gateway has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def default_gateway():
        '''
        Populates grains which describe whether a server has a default gateway
        configured or not. Uses `ip -4 route show` and `ip -6 route show` and greps
        for a `default` at the beginning of any line. Assuming the standard
    Severity: Minor
    Found in salt/grains/core.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 ip_interfaces has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def ip_interfaces():
        '''
        Provide a dict of the connected interfaces and their ip addresses
        The addresses will be passed as a list for each interface
        '''
    Severity: Minor
    Found in salt/grains/core.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 _linux_cpudata has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _linux_cpudata():
        '''
        Return some CPU information for Linux minions
        '''
        # Provides:
    Severity: Minor
    Found in salt/grains/core.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 _parse_cpe_name has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_cpe_name(cpe):
        '''
        Parse CPE_NAME data from the os-release
    
        Info: https://csrc.nist.gov/projects/security-content-automation-protocol/scap-specifications/cpe
    Severity: Minor
    Found in salt/grains/core.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

    Cyclomatic complexity is too high in function _bsd_cpudata. (22)
    Open

    def _bsd_cpudata(osdata):
        '''
        Return CPU information for BSD-like systems
        '''
        # Provides:
    Severity: Minor
    Found in salt/grains/core.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function _linux_memdata has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _linux_memdata():
        '''
        Return the memory information for Linux-like systems
        '''
        grains = {'mem_total': 0, 'swap_total': 0}
    Severity: Minor
    Found in salt/grains/core.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 _windows_platform_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _windows_platform_data():
        '''
        Use the platform module for as much as we can.
        '''
        # Provides:
    Severity: Minor
    Found in salt/grains/core.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 _aix_memdata has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _aix_memdata():
        '''
        Return the memory information for AIX systems
        '''
        grains = {'mem_total': 0, 'swap_total': 0}
    Severity: Minor
    Found in salt/grains/core.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 _windows_virtual has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _windows_virtual(osdata):
        '''
        Returns what type of virtual hardware is under the hood, kvm or physical
        '''
        # Provides:
    Severity: Minor
    Found in salt/grains/core.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 ip4_interfaces has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def ip4_interfaces():
        '''
        Provide a dict of the connected interfaces and their ip4 addresses
        The addresses will be passed as a list for each interface
        '''
    Severity: Minor
    Found in salt/grains/core.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 ip6_interfaces has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def ip6_interfaces():
        '''
        Provide a dict of the connected interfaces and their ip6 addresses
        The addresses will be passed as a list for each interface
        '''
    Severity: Minor
    Found in salt/grains/core.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 ip_fqdn has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def ip_fqdn():
        '''
        Return ip address and FQDN grains
        '''
        if salt.utils.platform.is_proxy():
    Severity: Minor
    Found in salt/grains/core.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 _aix_cpudata has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _aix_cpudata():
        '''
        Return CPU information for AIX systems
        '''
        # Provides:
    Severity: Minor
    Found in salt/grains/core.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 fqdns has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def fqdns():
        '''
        Return all known FQDNs for the system by enumerating all interfaces and
        then trying to reverse resolve them (excluding 'lo' interface).
        '''
    Severity: Minor
    Found in salt/grains/core.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 _bsd_memdata has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _bsd_memdata(osdata):
        '''
        Return the memory information for BSD-like systems
        '''
        grains = {'mem_total': 0, 'swap_total': 0}
    Severity: Minor
    Found in salt/grains/core.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 _osx_platform_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _osx_platform_data():
        '''
        Additional data for macOS systems
        Returns: A dictionary containing values for the following:
            - model_name
    Severity: Minor
    Found in salt/grains/core.py - About 55 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 kernelparams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def kernelparams():
        '''
        Return the kernel boot parameters
        '''
        if salt.utils.platform.is_windows():
    Severity: Minor
    Found in salt/grains/core.py - About 55 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 _virtual_hv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _virtual_hv(osdata):
        '''
        Returns detailed hypervisor information from sysfs
        Currently this seems to be used only by Xen
        '''
    Severity: Minor
    Found in salt/grains/core.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 _parse_os_release has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_os_release(*os_release_files):
        '''
        Parse os-release and return a parameter dictionary
    
        See http://www.freedesktop.org/software/systemd/man/os-release.html
    Severity: Minor
    Found in salt/grains/core.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

    Avoid deeply nested control flow statements.
    Open

                            for line in fhr:
                                if 'enterprise' in line.lower():
                                    grains['lsb_distrib_id'] = 'SLES'
                                    grains['lsb_distrib_codename'] = re.sub(r'\(.+\)', '', line).strip()
                                elif 'version' in line.lower():
    Severity: Major
    Found in salt/grains/core.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if os_release['ID'] == 'debian':
                                  codename_match = re.search(r'\((\w+)\)$', codename)
                                  if codename_match:
                                      codename = codename_match.group(1)
                              grains['lsb_distrib_codename'] = codename
      Severity: Major
      Found in salt/grains/core.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if 'Features' in line:
                                start = line.find('<')
                                end = line.find('>')
                                if start > 0 and end > 0:
                                    flag = line[start + 1:end].split(',')
        Severity: Major
        Found in salt/grains/core.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if grains['lsb_distrib_codename'] and patchstr not in grains['lsb_distrib_codename']:
                                      grains['lsb_distrib_codename'] += ' ' + patchstr
                              if not grains.get('lsb_distrib_codename'):
          Severity: Major
          Found in salt/grains/core.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    for line in ifile:
                                        # ALT Linux Sisyphus (unstable)
                                        comps = line.split()
                                        if comps[0] == 'ALT':
                                            grains['lsb_distrib_release'] = comps[2]
            Severity: Major
            Found in salt/grains/core.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if res and len(res.groups()) >= 1:
                                      grains[dest] = res.group(1).strip().replace("'", '')
              
              
              Severity: Major
              Found in salt/grains/core.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not line.startswith(' '):
                                        break  # game over
                                    if 'Features' in line:
                Severity: Major
                Found in salt/grains/core.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      with salt.utils.files.fopen('/proc/xen/capabilities') as fhr:
                                          if 'control_d' not in fhr.read():
                                              # Tested on CentOS 5.5 / 2.6.18-194.3.1.el5xen
                                              grains['virtual_subtype'] = 'Xen PV DomU'
                                          else:
                  Severity: Major
                  Found in salt/grains/core.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if key == 'uuid':
                                                grains['uuid'] = grains['uuid'].lower()
                                    except (IOError, OSError) as err:
                    Severity: Major
                    Found in salt/grains/core.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if not cpe:
                                                  log.error('Broken CPE_NAME format in /etc/os-release!')
                                              elif cpe.get('vendor', '').lower() in ['suse', 'opensuse']:
                                                  grains['os'] = "SUSE"
                                                  # openSUSE `osfullname` grain normalization
                      Severity: Major
                      Found in salt/grains/core.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                with salt.utils.files.fopen('/etc/redhat-release') as ifile:
                                                    for line in ifile:
                                                        if "red hat enterprise linux server" in line.lower():
                                                            # This is a SUSE Expanded Support Rhel installation
                                                            grains['lsb_distrib_id'] = 'RedHat'
                        Severity: Major
                        Found in salt/grains/core.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if len(synoinfo) != 3:
                                                      log.warning(
                                                          'Unable to determine Synology version info. '
                                                          'Please report this, as it is likely a bug.'
                                                      )
                          Severity: Major
                          Found in salt/grains/core.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if res and len(res.groups()) >= 1:
                                                    grains[dest] = res.group(1).strip().replace("'", '')
                            
                            
                            Severity: Major
                            Found in salt/grains/core.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if vz_match and int(vz_match.groups()[0]) != 0:
                                                      grains['virtual'] = 'openvzve'
                                                  elif vz_match and int(vz_match.groups()[0]) == 0:
                                                      grains['virtual'] = 'openvzhn'
                                      if isdir('/proc/sys/xen') or \
                              Severity: Major
                              Found in salt/grains/core.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        for line in fp_:
                                                            try:
                                                                key, val = line.rstrip('\n').split('=')
                                                            except ValueError:
                                                                continue
                                Severity: Major
                                Found in salt/grains/core.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                                  for item in supported_inits:
                                                                      if item in buf:
                                                                          if six.PY3:
                                                                              item = item.decode('utf-8')
                                                                          grains['init'] = item
                                  Severity: Major
                                  Found in salt/grains/core.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            for line in ifile:
                                                                # Need to pull out the version and codename
                                                                # in the case of custom content in /etc/centos-release
                                                                find_release = re.compile(r'\d+\.\d+')
                                                                find_codename = re.compile(r'(?<=\()(.*?)(?=\))')
                                    Severity: Major
                                    Found in salt/grains/core.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          if 'xen:' in __salt__['cmd.run']('dmesg').lower():
                                                              grains['virtual_subtype'] = 'Xen PV DomU'
                                                          elif os.path.isfile('/sys/bus/xen/drivers/xenconsole'):
                                                              # An actual DomU will have the xenconsole driver
                                                              grains['virtual_subtype'] = 'Xen PV DomU'
                                      Severity: Major
                                      Found in salt/grains/core.py - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                                if osminorrelease:
                                                                    osrelease.append(osminorrelease)
                                                                grains['osrelease'] = ".".join(osrelease)
                                        Severity: Major
                                        Found in salt/grains/core.py - About 45 mins to fix

                                          Consider simplifying this complex logical expression.
                                          Open

                                              if osdata['kernel'] == 'Linux' and os.path.exists('/sys/class/dmi/id'):
                                                  # On many Linux distributions basic firmware information is available via sysfs
                                                  # requires CONFIG_DMIID to be enabled in the Linux kernel configuration
                                                  sysfs_firmware_info = {
                                                      'biosversion': 'bios_version',
                                          Severity: Major
                                          Found in salt/grains/core.py - About 40 mins to fix

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

                                            def _netbsd_gpu_data():
                                                '''
                                                num_gpus: int
                                                gpus:
                                                  - vendor: nvidia|amd|ati|...
                                            Severity: Minor
                                            Found in salt/grains/core.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

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

                                            def _ps(osdata):
                                                '''
                                                Return the ps grain
                                                '''
                                                grains = {}
                                            Severity: Minor
                                            Found in salt/grains/core.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

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

                                            def _aix_get_machine_id():
                                                '''
                                                Parse the output of lsattr -El sys0 for os_uuid
                                                '''
                                                grains = {}
                                            Severity: Minor
                                            Found in salt/grains/core.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

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

                                            def _memdata(osdata):
                                                '''
                                                Gather information about the system memory
                                                '''
                                                # Provides:
                                            Severity: Minor
                                            Found in salt/grains/core.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 val
                                            Severity: Major
                                            Found in salt/grains/core.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return None
                                              Severity: Major
                                              Found in salt/grains/core.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                            return None
                                                Severity: Major
                                                Found in salt/grains/core.py - About 30 mins to fix

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

                                                  def _sunos_cpudata():
                                                      '''
                                                      Return the CPU information for Solaris-like systems
                                                      '''
                                                      # Provides:
                                                  Severity: Minor
                                                  Found in salt/grains/core.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 dns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                  def dns():
                                                      '''
                                                      Parse the resolver configuration file
                                                  
                                                       .. versionadded:: 2016.3.0
                                                  Severity: Minor
                                                  Found in salt/grains/core.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

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                      elif osdata['kernel'] == 'AIX':
                                                          cmd = salt.utils.path.which('prtconf')
                                                          if data:
                                                              data = __salt__['cmd.run']('{0}'.format(cmd)) + os.linesep
                                                              for dest, regstring in (('serialnumber', r'(?im)^\s*Machine\s+Serial\s+Number:\s+(\S+)'),
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 2 days to fix
                                                  salt/grains/core.py on lines 2751..2769

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 258.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                      elif osdata['kernel'] == 'AIX':
                                                          cmd = salt.utils.path.which('prtconf')
                                                          if cmd:
                                                              data = __salt__['cmd.run']('{0}'.format(cmd)) + os.linesep
                                                              for dest, regstring in (('serialnumber', r'(?im)^\s*Machine\s+Serial\s+Number:\s+(\S+)'),
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 2 days to fix
                                                  salt/grains/core.py on lines 2771..2789

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 258.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                  def ip6_interfaces():
                                                      '''
                                                      Provide a dict of the connected interfaces and their ip6 addresses
                                                      The addresses will be passed as a list for each interface
                                                      '''
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 day to fix
                                                  salt/grains/core.py on lines 2311..2333

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 151.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                  def ip4_interfaces():
                                                      '''
                                                      Provide a dict of the connected interfaces and their ip4 addresses
                                                      The addresses will be passed as a list for each interface
                                                      '''
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 day to fix
                                                  salt/grains/core.py on lines 2336..2358

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 151.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                      if 'Server' in caption:
                                                          for item in caption.split(' '):
                                                              # If it's all digits, then it's version
                                                              if re.match(r'\d+', item):
                                                                  version = item
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 5 hrs to fix
                                                  salt/version.py on lines 669..685

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 100.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                              if 'vmware' in model:
                                                                  grains['virtual'] = 'VMware'
                                                              # 00:04.0 System peripheral: InnoTek Systemberatung GmbH
                                                              #         VirtualBox Guest Service
                                                              elif 'virtualbox' in model:
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 4 hrs to fix
                                                  salt/grains/core.py on lines 873..880

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 87.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                              if 'vmware' in model:
                                                                  grains['virtual'] = 'VMware'
                                                              elif 'virtualbox' in model:
                                                                  grains['virtual'] = 'VirtualBox'
                                                              elif 'qemu' in model:
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 4 hrs to fix
                                                  salt/grains/core.py on lines 859..868

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 87.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                          for regex in uuid_regexes:
                                                              res = regex.search(data)
                                                              if res and len(res.groups()) >= 1:
                                                                  grains['uuid'] = res.group(1).strip().replace("'", "")
                                                                  break
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 2 other locations - About 2 hrs to fix
                                                  salt/grains/core.py on lines 2710..2714
                                                  salt/grains/core.py on lines 2737..2741

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 69.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                          for regex in sn_regexes:
                                                              res = regex.search(data)
                                                              if res and len(res.groups()) >= 1:
                                                                  grains['serialnumber'] = res.group(1).strip().replace("'", "")
                                                                  break
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 2 other locations - About 2 hrs to fix
                                                  salt/grains/core.py on lines 2731..2735
                                                  salt/grains/core.py on lines 2737..2741

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 69.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                          for regex in manufacture_regexes:
                                                              res = regex.search(data)
                                                              if res and len(res.groups()) >= 1:
                                                                  grains['manufacture'] = res.group(1).strip().replace("'", "")
                                                                  break
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 2 other locations - About 2 hrs to fix
                                                  salt/grains/core.py on lines 2710..2714
                                                  salt/grains/core.py on lines 2731..2735

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 69.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                              if output in ('kvm', 'qemu', 'uml', 'xen', 'lxc'):
                                                                  grains['virtual'] = output
                                                                  break
                                                              elif 'vmware' in output:
                                                                  grains['virtual'] = 'VMware'
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 2 hrs to fix
                                                  salt/grains/core.py on lines 785..796

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 68.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                              elif 'vmware' in output:
                                                                  grains['virtual'] = 'VMware'
                                                                  break
                                                              elif 'microsoft' in output:
                                                                  grains['virtual'] = 'VirtualPC'
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 2 hrs to fix
                                                  salt/grains/core.py on lines 802..813

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 68.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                                  if comps[0].strip() == 'MemTotal':
                                                                      # Use floor division to force output to be an integer
                                                                      grains['mem_total'] = int(comps[1].split()[0]) // 1024
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/grains/core.py on lines 460..462

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 57.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                      elif 'uuid' in key:
                                                          # Try each version (1-5) of RFC4122 to check if it's actually a UUID
                                                          for uuidver in range(1, 5):
                                                              try:
                                                                  uuid.UUID(val, version=uuidver)
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/modules/smbios.py on lines 287..296

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 57.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                                  if comps[0].strip() == 'SwapTotal':
                                                                      # Use floor division to force output to be an integer
                                                                      grains['swap_total'] = int(comps[1].split()[0]) // 1024
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/grains/core.py on lines 457..459

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 57.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                          for key, oid in hwdata.items():
                                                              value = __salt__['cmd.run']('{0} -b {1}'.format(sysctl, oid))
                                                              if not value.endswith(' is invalid'):
                                                                  grains[key] = _clean_value(key, value)
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/grains/core.py on lines 2606..2609

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 53.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                          for key, oid in six.iteritems(hwdata):
                                                              value = __salt__['cmd.run']('{0} -n {1}'.format(sysctl, oid))
                                                              if not value.endswith(' value is not available'):
                                                                  grains[key] = _clean_value(key, value)
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/grains/core.py on lines 2628..2631

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 53.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                  try:
                                                      #pylint: disable=W1505
                                                      from platform import linux_distribution as _deprecated_linux_distribution
                                                  
                                                      def linux_distribution(**kwargs):
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/version.py on lines 14..22

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 41.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                          for idx, value in enumerate(osrelease_info):
                                                              if not value.isdigit():
                                                                  continue
                                                              osrelease_info[idx] = int(value)
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/grains/core.py on lines 2114..2117

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 41.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                          for idx, value in enumerate(osrelease_info):
                                                              if not value.isdigit():
                                                                  continue
                                                              osrelease_info[idx] = int(value)
                                                  Severity: Major
                                                  Found in salt/grains/core.py and 1 other location - About 1 hr to fix
                                                  salt/grains/core.py on lines 1679..1682

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 41.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status