saltstack/salt

View on GitHub
salt/modules/pkgng.py

Summary

Maintainability
F
1 wk
Test Coverage

File pkgng.py has 1755 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Support for ``pkgng``, the new package manager for FreeBSD

.. important::
Severity: Major
Found in salt/modules/pkgng.py - About 4 days to fix

    Function _parse_upgrade has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_upgrade(stdout):
        '''
        Parse the output from the ``pkg upgrade --dry-run`` command
    
        Returns a dictionary of the expected actions:
    Severity: Minor
    Found in salt/modules/pkgng.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 install has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def install(name=None,
                fromrepo=None,
                pkgs=None,
                sources=None,
                jail=None,
    Severity: Minor
    Found in salt/modules/pkgng.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 latest_version has a Cognitive Complexity of 23 (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/pkgng.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

    Cyclomatic complexity is too high in function install. (29)
    Open

    def install(name=None,
                fromrepo=None,
                pkgs=None,
                sources=None,
                jail=None,
    Severity: Minor
    Found in salt/modules/pkgng.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 remove has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove(name=None,
               pkgs=None,
               jail=None,
               chroot=None,
               root=None,
    Severity: Minor
    Found in salt/modules/pkgng.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 hold has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def hold(name=None, pkgs=None, **kwargs):  # pylint: disable=W0613
        '''
        Version-lock packages
    
        .. note::
    Severity: Minor
    Found in salt/modules/pkgng.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 unhold has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

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

    def search(name,
               jail=None,
               chroot=None,
               root=None,
               exact=False,
    Severity: Minor
    Found in salt/modules/pkgng.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 list_pkgs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_pkgs(versions_as_list=False,
                  jail=None,
                  chroot=None,
                  root=None,
                  with_origin=False,
    Severity: Minor
    Found in salt/modules/pkgng.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 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def install(name=None,
                fromrepo=None,
                pkgs=None,
                sources=None,
                jail=None,
    Severity: Minor
    Found in salt/modules/pkgng.py - About 1 hr to fix

      Function remove has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def remove(name=None,
                 pkgs=None,
                 jail=None,
                 chroot=None,
                 root=None,
      Severity: Minor
      Found in salt/modules/pkgng.py - About 1 hr to fix

        Function upgrade has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def upgrade(*names, **kwargs):
            '''
            Upgrade named or all packages (run a ``pkg upgrade``). If <package name> is
            omitted, the operation is executed on all packages.
        
        
        Severity: Minor
        Found in salt/modules/pkgng.py - About 1 hr to fix

          Function fetch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def fetch(name,
                    jail=None,
                    chroot=None,
                    root=None,
                    fetch_all=False,
          Severity: Minor
          Found in salt/modules/pkgng.py - About 55 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function __virtual__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def __virtual__():
              '''
              Load as 'pkg' on FreeBSD 10 and greater.
              Load as 'pkg' on DragonFly BSD.
              Load as 'pkg' on FreeBSD 9 when config option
          Severity: Minor
          Found in salt/modules/pkgng.py - About 45 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

          def upgrade(*names, **kwargs):
              '''
              Upgrade named or all packages (run a ``pkg upgrade``). If <package name> is
              omitted, the operation is executed on all packages.
          
          
          Severity: Minor
          Found in salt/modules/pkgng.py - About 45 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

          def _get_version(name, results):
              '''
              ``pkg search`` will return all packages for which the pattern is a match.
              Narrow this down and return the package version, or None if no exact match.
              '''
          Severity: Minor
          Found in salt/modules/pkgng.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 _lockcmd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def _lockcmd(subcmd, pkgname=None, **kwargs):
              '''
              Helper function for lock and unlock commands, because their syntax is identical.
          
              Run the lock/unlock command, and return a list of locked packages
          Severity: Minor
          Found in salt/modules/pkgng.py - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Avoid too many return statements within this function.
          Open

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

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

            def parse_config(file_name='/usr/local/etc/pkg.conf'):
                '''
                Return dict of uncommented global variables.
            
                CLI Example:
            Severity: Minor
            Found in salt/modules/pkgng.py - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

            def version(*names, **kwargs):
                '''
                Returns a string representing the package version or an empty string if not
                installed. If more than one package name is specified, a dict of
                name/version pairs is returned.
            Severity: Major
            Found in salt/modules/pkgng.py and 1 other location - About 1 day to fix
            salt/modules/freebsdpkg.py on lines 207..237

            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

                        if __opts__['test']:
                            ret[target].update(result=None)
                            ret[target]['comment'] = ('Package {0} is set to be unheld.'
                                                      .format(target))
                        else:
            Severity: Major
            Found in salt/modules/pkgng.py and 1 other location - About 7 hrs to fix
            salt/modules/pkgng.py on lines 1943..1955

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

            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 'test' in __opts__ and __opts__['test']:
                            ret[target].update(result=None)
                            ret[target]['comment'] = ('Package {0} is set to be held.'
                                                      .format(target))
                        else:
            Severity: Major
            Found in salt/modules/pkgng.py and 1 other location - About 7 hrs to fix
            salt/modules/pkgng.py on lines 2008..2020

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

            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 action == 'install':
                        match = install_regex.match(line)
                        if match:
                            result[action][match.group(1)] = {
                                'version': {
            Severity: Major
            Found in salt/modules/pkgng.py and 1 other location - About 3 hrs to fix
            salt/modules/pkgng.py on lines 2428..2439

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

            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 (action == 'reinstall') or (action == 'remove'):
                        match = reinstall_regex.match(line)
                        if match:
                            result[action][match.group(1)] = {
                                'version': {
            Severity: Major
            Found in salt/modules/pkgng.py and 1 other location - About 3 hrs to fix
            salt/modules/pkgng.py on lines 2415..2426

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

            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 salt.utils.data.is_true(with_origin):
                    return dict([
                        (x, {'origin': origins.get(x, ''), 'version': y})
                        for x, y in six.iteritems(ret)
            Severity: Major
            Found in salt/modules/pkgng.py and 1 other location - About 2 hrs to fix
            salt/modules/freebsdpkg.py on lines 314..317

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

            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/pkgng.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 1070..1073
            salt/modules/solarispkg.py on lines 466..469
            salt/modules/yumpkg.py on lines 2018..2021

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

                if out['retcode'] != 0 and out['stderr']:
                    errors = [out['stderr']]
                else:
                    errors = []
            Severity: Major
            Found in salt/modules/pkgng.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/solarispkg.py on lines 466..469
            salt/modules/yumpkg.py on lines 2018..2021

            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

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

                    for param, version_num in six.iteritems(pkg_params):
                        if version_num is None:
                            targets.append(param)
                        else:
                            targets.append('{0}-{1}'.format(param, version_num))
            Severity: Major
            Found in salt/modules/pkgng.py and 1 other location - About 1 hr to fix
            salt/modules/pkgutil.py on lines 296..300

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

            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 locked(target, **kwargs):
                        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/pkgng.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/yumpkg.py on lines 2144..2162
            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 8 locations. Consider refactoring.
            Open

                    if not locked(target, **kwargs):
                        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/pkgng.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 2007..2024
            salt/modules/yumpkg.py on lines 2144..2162
            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

            There are no issues that match your filters.

            Category
            Status