saltstack/salt

View on GitHub
salt/modules/yumpkg.py

Summary

Maintainability
F
1 mo
Test Coverage

File yumpkg.py has 2501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Support for YUM/DNF

.. important::
Severity: Major
Found in salt/modules/yumpkg.py - About 1 wk to fix

    Function install has a Cognitive Complexity of 213 (exceeds 5 allowed). Consider refactoring.
    Open

    def install(name=None,
                refresh=False,
                skip_verify=False,
                pkgs=None,
                sources=None,
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 4 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 list_repo_pkgs has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_repo_pkgs(*args, **kwargs):
        '''
        .. versionadded:: 2014.1.0
        .. versionchanged:: 2014.7.0
            All available versions of each package are now returned. This required
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 1 day 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 install. (71)
    Open

    def install(name=None,
                refresh=False,
                skip_verify=False,
                pkgs=None,
                sources=None,
    Severity: Minor
    Found in salt/modules/yumpkg.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 list_repo_pkgs. (53)
    Open

    def list_repo_pkgs(*args, **kwargs):
        '''
        .. versionadded:: 2014.1.0
        .. versionchanged:: 2014.7.0
            All available versions of each package are now returned. This required
    Severity: Minor
    Found in salt/modules/yumpkg.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 mod_repo has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    def mod_repo(repo, basedir=None, **kwargs):
        '''
        Modify one or more values for a repo. If the repo does not exist, it will
        be created, so long as the following values are specified:
    
    
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 6 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 group_info has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    def group_info(name, expand=False):
        '''
        .. versionadded:: 2014.1.0
        .. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
            The return data has changed. A new key ``type`` has been added to
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 6 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 latest_version has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    def latest_version(*names, **kwargs):
        '''
        Return the latest version of the named package available for upgrade or
        installation. If more than one package name is specified, a dict of
        name/version pairs is returned.
    Severity: Minor
    Found in salt/modules/yumpkg.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 _get_options has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_options(**kwargs):
        '''
        Returns a list of options to be used in the yum/dnf command, based on the
        kwargs passed.
        '''
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 4 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Cyclomatic complexity is too high in function mod_repo. (36)
    Open

    def mod_repo(repo, basedir=None, **kwargs):
        '''
        Modify one or more values for a repo. If the repo does not exist, it will
        be created, so long as the following values are specified:
    
    
    Severity: Minor
    Found in salt/modules/yumpkg.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 _get_yum_config has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_yum_config():
        '''
        Returns a dict representing the yum config options and values.
    
        We try to pull all of the yum config options into a standard dict object.
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 4 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function unhold has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def unhold(name=None, pkgs=None, sources=None, **kwargs):  # pylint: disable=W0613
        '''
        .. versionadded:: 2014.7.0
    
        Remove version locks
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 4 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    def hold(name=None, pkgs=None, sources=None, normalize=True, **kwargs):  # pylint: disable=W0613
        '''
        .. versionadded:: 2014.7.0
    
        Version-lock packages
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 3 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function upgrade has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def upgrade(name=None,
                pkgs=None,
                refresh=True,
                skip_verify=False,
                normalize=True,
    Severity: Minor
    Found in salt/modules/yumpkg.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 _yum_pkginfo has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def _yum_pkginfo(output):
        '''
        Parse yum/dnf output (which could contain irregular line breaks if package
        names are long) retrieving the name, version, etc., and return a list of
        pkginfo namedtuples.
    Severity: Minor
    Found in salt/modules/yumpkg.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 list_pkgs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_pkgs(versions_as_list=False, **kwargs):
        '''
        List the packages currently installed as a dict. By default, the dict
        contains versions as a comma separated string::
    
    
    Severity: Minor
    Found in salt/modules/yumpkg.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 download has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def download(*packages, **kwargs):
        '''
        .. versionadded:: 2015.5.0
    
        Download packages to the local disk. Requires ``yumdownloader`` from
    Severity: Minor
    Found in salt/modules/yumpkg.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 remove has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove(name=None, pkgs=None, **kwargs):  # pylint: disable=W0613
        '''
        .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
            On minions running systemd>=205, `systemd-run(1)`_ is now used to
            isolate commands which modify installed packages from the
    Severity: Minor
    Found in salt/modules/yumpkg.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 info_installed has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def info_installed(*names, **kwargs):
        '''
        .. versionadded:: 2015.8.1
    
        Return the information of the named package(s), installed on the system.
    Severity: Minor
    Found in salt/modules/yumpkg.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 del_repo has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def del_repo(repo, basedir=None, **kwargs):  # pylint: disable=W0613
        '''
        Delete a repo from <basedir> (default basedir: all dirs in `reposdir` yum
        option).
    
    
    Severity: Minor
    Found in salt/modules/yumpkg.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 _check_versionlock has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _check_versionlock():
        '''
        Ensure that the appropriate versionlock plugin is present
        '''
        if _yum() == 'dnf':
    Severity: Minor
    Found in salt/modules/yumpkg.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_repo_file has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_repo_file(filename):
        '''
        Turn a single repo file into a dict
        '''
        parsed = configparser.ConfigParser()
    Severity: Minor
    Found in salt/modules/yumpkg.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 diff has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def diff(*paths, **kwargs):
        '''
        Return a formatted diff between current files and original in a package.
        NOTE: this function includes all files (configuration and not), but does
        not work on binary content.
    Severity: Minor
    Found in salt/modules/yumpkg.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

    Cyclomatic complexity is too high in function group_info. (21)
    Open

    def group_info(name, expand=False):
        '''
        .. versionadded:: 2014.1.0
        .. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
            The return data has changed. A new key ``type`` has been added to
    Severity: Minor
    Found in salt/modules/yumpkg.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 unhold. (21)
    Open

    def unhold(name=None, pkgs=None, sources=None, **kwargs):  # pylint: disable=W0613
        '''
        .. versionadded:: 2014.7.0
    
        Remove version locks
    Severity: Minor
    Found in salt/modules/yumpkg.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 group_list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def group_list():
        '''
        .. versionadded:: 2014.1.0
    
        Lists all groups known by yum on this system
    Severity: Minor
    Found in salt/modules/yumpkg.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 _get_hold has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_hold(line, pattern=__HOLD_PATTERN, full=True):
        '''
        Resolve a package name from a line containing the hold expression. If the
        regex is not matched, None is returned.
    
    
    Severity: Minor
    Found in salt/modules/yumpkg.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 install has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def install(name=None,
                refresh=False,
                skip_verify=False,
                pkgs=None,
                sources=None,
    Severity: Minor
    Found in salt/modules/yumpkg.py - About 1 hr to fix

      Function list_repos has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def list_repos(basedir=None, **kwargs):
          '''
          Lists all repos in <basedir> (default: all dirs in `reposdir` yum option).
      
          CLI Example:
      Severity: Minor
      Found in salt/modules/yumpkg.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 group_install has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def group_install(name,
                        skip=(),
                        include=(),
                        **kwargs):
          '''
      Severity: Minor
      Found in salt/modules/yumpkg.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 group_diff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def group_diff(name):
          '''
          .. versionadded:: 2014.1.0
          .. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
              Environment groups are now supported. The key names have been renamed,
      Severity: Minor
      Found in salt/modules/yumpkg.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

                          if ignore_epoch is True:
                              version_num = version_num.split(':', 1)[-1]
                      arch = ''
      Severity: Major
      Found in salt/modules/yumpkg.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if salt.utils.versions.compare(ver1=version_num,
                                                           oper='==',
                                                           ver2=ver,
                                                           cmp_func=version_cmp,
                                                           ignore_epoch=ignore_epoch):
        Severity: Major
        Found in salt/modules/yumpkg.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for ver in cver:
                                  if salt.utils.versions.compare(ver1=version_num,
                                                                 oper='>=',
                                                                 ver2=ver,
                                                             cmp_func=version_cmp,
          Severity: Major
          Found in salt/modules/yumpkg.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if match.group(1) == pkgtype:
                                    # We've reached the targeted section
                                    target_found = True
                                continue
            Severity: Major
            Found in salt/modules/yumpkg.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  for p_type in pkgtypes:
                                      ret[p_type].update(set(expanded[p_type]))
                              else:
              Severity: Major
              Found in salt/modules/yumpkg.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if target is None:
                                        errors.append(
                                            'No version matching \'{0}{1}\' could be found '
                                            '(available: {2})'.format(
                                                pkgname,
                Severity: Major
                Found in salt/modules/yumpkg.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if match is not None:
                                          version_num = match
                                      else:
                                          errors.append(
                                              'No version matching \'{0}\' found for package '
                  Severity: Major
                  Found in salt/modules/yumpkg.py - About 45 mins to fix

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

                    def _complete_transaction(cleanup_only, recursive, max_attempts, run_count, cmd_ret_list):
                        '''
                        .. versionadded:: Fluorine
                    
                        Called from ``complete_transaction`` to protect the arguments
                    Severity: Minor
                    Found in salt/modules/yumpkg.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 _yum has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def _yum():
                        '''
                        Determine package manager name (yum or dnf),
                        depending on the system version.
                        '''
                    Severity: Minor
                    Found in salt/modules/yumpkg.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 _get_patches has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def _get_patches(installed_only=False):
                        '''
                        List all known patches in repos.
                        '''
                        patches = {}
                    Severity: Minor
                    Found in salt/modules/yumpkg.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 3 locations. Consider refactoring.
                    Open

                        if byrepo:
                            for reponame in ret:
                                # Sort versions newest to oldest
                                for pkgname in ret[reponame]:
                                    sorted_versions = sorted(
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 2 other locations - About 1 day to fix
                    salt/modules/pacmanpkg.py on lines 1045..1066
                    salt/modules/zypperpkg.py on lines 965..986

                    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 202.

                    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

                    def normalize_name(name):
                        '''
                        Strips the architecture from the specified package name, if necessary.
                        Circumstances where this would be done include:
                    
                    
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 1 day to fix
                    salt/modules/zypperpkg.py on lines 1709..1732

                    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 138.

                    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 root, dirnames, filenames in salt.utils.path.os_walk(CACHE_DIR):
                            for filename in fnmatch.filter(filenames, '*.rpm'):
                                package_path = os.path.join(root, filename)
                                pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
                                pkg_timestamp = int(os.path.getctime(package_path))
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 1 day to fix
                    salt/modules/zypperpkg.py on lines 2558..2567

                    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 139.

                    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 out['retcode'] == 0:
                                        ret[target].update(result=True)
                                        ret[target]['comment'] = ('Package {0} is now being held.'
                                                                  .format(target))
                                        ret[target]['changes']['new'] = 'hold'
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 7 hrs to fix
                    salt/modules/yumpkg.py on lines 2256..2263

                    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 126.

                    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 out['retcode'] == 0:
                                        ret[target].update(result=True)
                                        ret[target]['comment'] = ('Package {0} is no longer held.'
                                                                  .format(target))
                                        ret[target]['changes']['new'] = ''
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 7 hrs to fix
                    salt/modules/yumpkg.py on lines 2151..2158

                    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 126.

                    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

                                if pkginfo is not None:
                                    # see rpm version string rules available at https://goo.gl/UGKPNd
                                    pkgver = pkginfo.version
                                    epoch = ''
                                    release = ''
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 7 hrs to fix
                    salt/modules/zypperpkg.py on lines 812..829

                    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 110.

                    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

                                    if pkgname in has_comparison:
                                        candidates = _available.get(pkgname, [])
                                        target = salt.utils.pkg.match_version(
                                            version_num,
                                            candidates,
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 5 hrs to fix
                    salt/modules/aptpkg.py on lines 675..694

                    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 91.

                    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 pkg_source in pkg_params:
                                if 'lowpkg.bin_pkg_info' in __salt__:
                                    rpm_info = __salt__['lowpkg.bin_pkg_info'](pkg_source)
                                else:
                                    rpm_info = None
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 5 hrs to fix
                    salt/modules/aptpkg.py on lines 615..628

                    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 94.

                    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 disablerepo and not isinstance(disablerepo, list):
                            try:
                                disablerepo = [x.strip() for x in disablerepo.split(',')
                                               if x != '*']
                            except AttributeError:
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 4 hrs to fix
                    salt/modules/yumpkg.py on lines 851..857

                    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 93.

                    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 enablerepo and not isinstance(enablerepo, list):
                            try:
                                enablerepo = [x.strip() for x in enablerepo.split(',')
                                              if x != '*']
                            except AttributeError:
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 4 hrs to fix
                    salt/modules/yumpkg.py on lines 843..849

                    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 93.

                    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

                            if not pth_pkg:
                                ret[pth] = os.path.exists(pth) and 'Not managed' or 'N/A'
                            else:
                                if pkg_to_paths.get(pth_pkg) is None:
                                    pkg_to_paths[pth_pkg] = []
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 4 hrs to fix
                    salt/modules/zypperpkg.py on lines 2594..2599

                    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 80.

                    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

                        with _temporarily_unhold(to_downgrade, targets):
                            if targets:
                                cmd = ['-y']
                                _add_common_args(cmd)
                                cmd.append('downgrade')
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 4 hrs to fix
                    salt/modules/yumpkg.py on lines 1683..1691

                    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 85.

                    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

                        with _temporarily_unhold(to_reinstall, targets):
                            if targets:
                                cmd = ['-y']
                                _add_common_args(cmd)
                                cmd.append('reinstall')
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 4 hrs to fix
                    salt/modules/yumpkg.py on lines 1672..1680

                    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 85.

                    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 pkgtype in pkgtypes:
                            for member in group_pkgs.get(pkgtype, []):
                                if member in pkgs:
                                    ret[pkgtype]['installed'].append(member)
                                else:
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 3 hrs to fix
                    salt/modules/pacmanpkg.py on lines 387..392

                    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 72.

                    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 pkg_src in ('installed', 'available'):
                                # Check installed packages first
                                out = _call_yum(cmd_prefix + [pkg_src], ignore_retcode=True)
                                if out['retcode'] == 0:
                                    _parse_output(out['stdout'], strict=True)
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 3 hrs to fix
                    salt/modules/yumpkg.py on lines 914..918

                    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 63.

                    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 pkg_src in ('installed', 'available'):
                                # Check installed packages first
                                out = _call_yum(cmd_prefix + [pkg_src], ignore_retcode=True)
                                if out['retcode'] == 0:
                                    _parse_output(out['stdout'], strict=True)
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 3 hrs to fix
                    salt/modules/yumpkg.py on lines 902..906

                    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 63.

                    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 disablerepo:
                                targets = [disablerepo] \
                                    if not isinstance(disablerepo, list) \
                                    else disablerepo
                                log.info('Disabling repo(s): %s', ', '.join(targets))
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 2 hrs to fix
                    salt/modules/yumpkg.py on lines 274..279

                    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 65.

                    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 enablerepo:
                                targets = [enablerepo] \
                                    if not isinstance(enablerepo, list) \
                                    else enablerepo
                                log.info('Enabling repo(s): %s', ', '.join(targets))
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 2 hrs to fix
                    salt/modules/yumpkg.py on lines 266..272

                    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 65.

                    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

                                try:
                                    namepart, archpart = target.rsplit('.', 1)
                                except ValueError:
                                    pass
                                else:
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 2 hrs to fix
                    salt/modules/yumpkg.py on lines 1512..1519

                    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 58.

                    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

                                    try:
                                        namepart, archpart = pkgname.rsplit('.', 1)
                                    except ValueError:
                                        pass
                                    else:
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 2 hrs to fix
                    salt/modules/yumpkg.py on lines 2005..2012

                    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 58.

                    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 17 locations. Consider refactoring.
                    Open

                        if out['retcode'] != 0 and out['stderr']:
                            errors = [out['stderr']]
                        else:
                            errors = []
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 16 other locations - About 1 hr to fix
                    salt/modules/apkpkg.py on lines 334..337
                    salt/modules/apkpkg.py on lines 410..413
                    salt/modules/aptpkg.py on lines 810..813
                    salt/modules/ebuildpkg.py on lines 1034..1037
                    salt/modules/freebsdpkg.py on lines 409..412
                    salt/modules/freebsdpkg.py on lines 472..475
                    salt/modules/mac_brew_pkg.py on lines 261..264
                    salt/modules/mac_brew_pkg.py on lines 415..418
                    salt/modules/openbsdpkg.py on lines 299..302
                    salt/modules/pacmanpkg.py on lines 614..617
                    salt/modules/pacmanpkg.py on lines 739..742
                    salt/modules/pkgin.py on lines 429..432
                    salt/modules/pkgin.py on lines 577..580
                    salt/modules/pkgng.py on lines 893..896
                    salt/modules/pkgng.py on lines 1070..1073
                    salt/modules/solarispkg.py on lines 466..469

                    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 46.

                    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 pkg, files in pkg_to_paths.items():
                                for path in files:
                                    ret[path] = __salt__['lowpkg.diff'](
                                        local_pkgs[pkg]['path'], path) or 'Unchanged'
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 1 other location - About 1 hr to fix
                    salt/modules/zypperpkg.py on lines 2603..2608

                    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 45.

                    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 11 locations. Consider refactoring.
                    Open

                        if salt.utils.systemd.has_scope(__context__) and __salt__['config.get']('systemd.scope', True):
                            cmd.extend(['systemd-run', '--scope'])
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 10 other locations - About 1 hr to fix
                    salt/modules/ebuildpkg.py on lines 740..742
                    salt/modules/ebuildpkg.py on lines 831..833
                    salt/modules/ebuildpkg.py on lines 923..925
                    salt/modules/ebuildpkg.py on lines 1019..1021
                    salt/modules/kernelpkg_linux_yum.py on lines 222..224
                    salt/modules/pacmanpkg.py on lines 539..541
                    salt/modules/pacmanpkg.py on lines 680..682
                    salt/modules/pacmanpkg.py on lines 724..726
                    salt/modules/systemd_service.py on lines 1162..1164
                    salt/modules/systemd_service.py on lines 1221..1223

                    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 42.

                    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 'mirrorlist' in todelete:
                            if 'baseurl' not in repo_opts and 'baseurl' \
                                    not in filerepos[repo]:
                                raise SaltInvocationError(
                    Severity: Minor
                    Found in salt/modules/yumpkg.py and 1 other location - About 50 mins to fix
                    salt/modules/yumpkg.py on lines 2848..2851

                    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 44.

                    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 'baseurl' in todelete:
                            if 'mirrorlist' not in repo_opts and 'mirrorlist' \
                                    not in filerepos[repo]:
                                raise SaltInvocationError(
                    Severity: Minor
                    Found in salt/modules/yumpkg.py and 1 other location - About 50 mins to fix
                    salt/modules/yumpkg.py on lines 2854..2857

                    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 44.

                    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

                        try:
                            os_grain = __grains__['os'].lower()
                            os_family = __grains__['os_family'].lower()
                        except Exception:
                            return (False, "Module yumpkg: no yum based system detected")
                    Severity: Minor
                    Found in salt/modules/yumpkg.py and 1 other location - About 45 mins to fix
                    salt/modules/rpm_lowpkg.py on lines 51..55

                    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 43.

                    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 8 locations. Consider refactoring.
                    Open

                            if search_locks:
                                if __opts__['test']:
                                    ret[target].update(result=None)
                                    ret[target]['comment'] = ('Package {0} is set to be unheld.'
                                                              .format(target))
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 7 other locations - About 35 mins to fix
                    salt/modules/aptpkg.py on lines 1125..1137
                    salt/modules/aptpkg.py on lines 1199..1211
                    salt/modules/opkg.py on lines 830..842
                    salt/modules/opkg.py on lines 902..914
                    salt/modules/pkgng.py on lines 1942..1959
                    salt/modules/pkgng.py on lines 2007..2024
                    salt/modules/yumpkg.py on lines 2144..2162

                    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

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

                            if target not in current_locks:
                                if 'test' in __opts__ and __opts__['test']:
                                    ret[target].update(result=None)
                                    ret[target]['comment'] = ('Package {0} is set to be held.'
                                                              .format(target))
                    Severity: Major
                    Found in salt/modules/yumpkg.py and 7 other locations - About 35 mins to fix
                    salt/modules/aptpkg.py on lines 1125..1137
                    salt/modules/aptpkg.py on lines 1199..1211
                    salt/modules/opkg.py on lines 830..842
                    salt/modules/opkg.py on lines 902..914
                    salt/modules/pkgng.py on lines 1942..1959
                    salt/modules/pkgng.py on lines 2007..2024
                    salt/modules/yumpkg.py on lines 2249..2267

                    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

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

                                        for ver in cver:
                                            if salt.utils.versions.compare(ver1=version_num,
                                                                           oper='>=',
                                                                           ver2=ver,
                                                                       cmp_func=version_cmp,
                    Severity: Minor
                    Found in salt/modules/yumpkg.py and 1 other location - About 35 mins to fix
                    salt/modules/yumpkg.py on lines 1550..1559

                    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

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

                                    for ver in cver:
                                        if salt.utils.versions.compare(ver1=version_num,
                                                                       oper='==',
                                                                       ver2=ver,
                                                                       cmp_func=version_cmp,
                    Severity: Minor
                    Found in salt/modules/yumpkg.py and 1 other location - About 35 mins to fix
                    salt/modules/yumpkg.py on lines 1564..1571

                    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

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

                        for purge_target in set(to_purge):
                            log.debug('Removing cached package %s', purge_target)
                            try:
                                os.unlink(purge_target)
                            except OSError as exc:
                    Severity: Minor
                    Found in salt/modules/yumpkg.py and 1 other location - About 30 mins to fix
                    salt/daemons/masterapi.py on lines 103..110

                    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 40.

                    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