saltstack/salt

View on GitHub
salt/modules/pacmanpkg.py

Summary

Maintainability
F
1 wk
Test Coverage

File pacmanpkg.py has 791 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
A module to wrap pacman calls, since Arch is the best
(https://wiki.archlinux.org/index.php/Arch_is_the_best)

Severity: Major
Found in salt/modules/pacmanpkg.py - About 1 day to fix

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

    def install(name=None,
                refresh=False,
                sysupgrade=None,
                pkgs=None,
                sources=None,
    Severity: Minor
    Found in salt/modules/pacmanpkg.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

    Function list_repo_pkgs has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_repo_pkgs(*args, **kwargs):
        '''
        Returns all available packages. Optionally, package names (and name globs)
        can be passed and the results will be filtered to packages matching those
        names.
    Severity: Minor
    Found in salt/modules/pacmanpkg.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

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

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

    def list_repo_pkgs(*args, **kwargs):
        '''
        Returns all available packages. Optionally, package names (and name globs)
        can be passed and the results will be filtered to packages matching those
        names.
    Severity: Minor
    Found in salt/modules/pacmanpkg.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 18 (exceeds 5 allowed). Consider refactoring.
    Open

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

    def list_upgrades(refresh=False, root=None, **kwargs):  # pylint: disable=W0613
        '''
        List all available package upgrades on this system
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/pacmanpkg.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 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_pkgs(versions_as_list=False, **kwargs):
        '''
        List the packages currently installed as a dict::
    
            {'<package_name>': '<version>'}
    Severity: Minor
    Found in salt/modules/pacmanpkg.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 refresh_db has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def refresh_db(root=None, **kwargs):
        '''
        Just run a ``pacman -Sy``, return a dict::
    
            {'<database name>': Bool}
    Severity: Minor
    Found in salt/modules/pacmanpkg.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 latest_version has a Cognitive Complexity of 10 (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/pacmanpkg.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:: 2016.11.0
    
    
    Severity: Minor
    Found in salt/modules/pacmanpkg.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 prefix == '=':
                            wildcards.append((param, verstr))
                        else:
                            errors.append(
                                'Invalid wildcard for {0}{1}{2}'.format(
    Severity: Major
    Found in salt/modules/pacmanpkg.py - About 45 mins to fix

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

      def file_dict(*packages, **kwargs):
          '''
          List the files that belong to a package, grouped by package. Not
          specifying any packages will return a list of _every_ file on the system's
          package database (not generally recommended).
      Severity: Minor
      Found in salt/modules/pacmanpkg.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 group_info has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def group_info(name):
          '''
          .. versionadded:: 2016.11.0
      
          Lists all packages in the specified group
      Severity: Minor
      Found in salt/modules/pacmanpkg.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 _uninstall has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _uninstall(action='remove', name=None, pkgs=None, **kwargs):
          '''
          remove and purge do identical things but with different pacman commands,
          this function performs the common logic.
          '''
      Severity: Minor
      Found in salt/modules/pacmanpkg.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

      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/pacmanpkg.py and 2 other locations - About 1 day to fix
      salt/modules/yumpkg.py on lines 931..952
      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

          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/pacmanpkg.py and 1 other location - About 3 hrs to fix
      salt/modules/yumpkg.py on lines 2517..2522

      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

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

          for line in salt.utils.itertools.split(out, '\n'):
              if not line:
                  continue
              try:
                  group, pkg = line.split()[0:2]
      Severity: Major
      Found in salt/modules/pacmanpkg.py and 1 other location - About 3 hrs to fix
      salt/modules/pacmanpkg.py on lines 268..277

      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

          for line in salt.utils.itertools.split(out, '\n'):
              if not line:
                  continue
              try:
                  group, pkg = line.split()[0:2]
      Severity: Major
      Found in salt/modules/pacmanpkg.py and 1 other location - About 3 hrs to fix
      salt/modules/pacmanpkg.py on lines 284..293

      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

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

          if 'pkg.list_pkgs' in __context__:
              if versions_as_list:
                  return __context__['pkg.list_pkgs']
              else:
                  ret = copy.deepcopy(__context__['pkg.list_pkgs'])
      Severity: Major
      Found in salt/modules/pacmanpkg.py and 11 other locations - About 2 hrs to fix
      salt/modules/aixpkg.py on lines 107..114
      salt/modules/apkpkg.py on lines 139..145
      salt/modules/ebuildpkg.py on lines 424..430
      salt/modules/mac_brew_pkg.py on lines 117..123
      salt/modules/mac_portspkg.py on lines 105..111
      salt/modules/openbsdpkg.py on lines 75..81
      salt/modules/opkg.py on lines 990..996
      salt/modules/pkgin.py on lines 281..287
      salt/modules/pkgutil.py on lines 149..155
      salt/modules/solarisipspkg.py on lines 268..274
      salt/modules/solarispkg.py on lines 102..108

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 57.

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

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

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

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

      Refactorings

      Further Reading

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

          if packages and os.path.exists(packages[0]):
              packages = list(packages)
              cmd.extend(('-r', packages.pop(0)))
      Severity: Major
      Found in salt/modules/pacmanpkg.py and 1 other location - About 2 hrs to fix
      salt/modules/pacmanpkg.py on lines 864..866

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

      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 packages and os.path.exists(packages[0]):
              packages = list(packages)
              cmd.extend(('-r', packages.pop(0)))
      Severity: Major
      Found in salt/modules/pacmanpkg.py and 1 other location - About 2 hrs to fix
      salt/modules/pacmanpkg.py on lines 898..900

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

      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/pacmanpkg.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/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
      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/pacmanpkg.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 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
      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 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/pacmanpkg.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 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
      salt/modules/yumpkg.py on lines 165..166

      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

      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/pacmanpkg.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/systemd_service.py on lines 1162..1164
      salt/modules/systemd_service.py on lines 1221..1223
      salt/modules/yumpkg.py on lines 165..166

      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

      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/pacmanpkg.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 724..726
      salt/modules/systemd_service.py on lines 1162..1164
      salt/modules/systemd_service.py on lines 1221..1223
      salt/modules/yumpkg.py on lines 165..166

      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

      There are no issues that match your filters.

      Category
      Status