saltstack/salt

View on GitHub
salt/modules/opkg.py

Summary

Maintainability
F
1 wk
Test Coverage

File opkg.py has 1276 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Support for Opkg

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

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

    def install(name=None,
                refresh=False,
                pkgs=None,
                sources=None,
                reinstall=False,
    Severity: Minor
    Found in salt/modules/opkg.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 mod_repo has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    def mod_repo(repo, **kwargs):
        '''
        Modify one or more values for a repo.  If the repo does not exist, it will
        be created, so long as uri is defined.
    
    
    Severity: Minor
    Found in salt/modules/opkg.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 del_repo has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def del_repo(repo, **kwargs):  # pylint: disable=unused-argument
        '''
        Delete a repo from ``/etc/opkg/*.conf``
    
        If the file does not contain any other repo configuration, the file itself
    Severity: Minor
    Found in salt/modules/opkg.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 install. (35)
    Open

    def install(name=None,
                refresh=False,
                pkgs=None,
                sources=None,
                reinstall=False,
    Severity: Minor
    Found in salt/modules/opkg.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 info_installed has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

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

    def _process_info_installed_output(out, filter_attrs):
        '''
        Helper function for info_installed()
    
        Processes stdout output from a single invocation of
    Severity: Minor
    Found in salt/modules/opkg.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 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def unhold(name=None, pkgs=None, sources=None, **kwargs):  # pylint: disable=W0613
        '''
        Set package current in 'hold' state to install state,
        meaning it will be upgraded.
    
    
    Severity: Minor
    Found in salt/modules/opkg.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 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def hold(name=None, pkgs=None, sources=None, **kwargs):  # pylint: disable=W0613
        '''
        Set package in 'hold' state, meaning it will not be upgraded.
    
        name
    Severity: Minor
    Found in salt/modules/opkg.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 _process_restartcheck_result has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def _process_restartcheck_result(rs_result, **kwargs):
        '''
        Check restartcheck output to see if system/service restarts were requested
        and take appropriate action.
        '''
    Severity: Minor
    Found in salt/modules/opkg.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 file_dict has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def file_dict(*packages, **kwargs):  # pylint: disable=unused-argument
        '''
        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/opkg.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 remove has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove(name=None, pkgs=None, **kwargs):  # pylint: disable=unused-argument
        '''
        Remove packages using ``opkg remove``.
    
        name
    Severity: Minor
    Found in salt/modules/opkg.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_repo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_repo(repo, **kwargs):  # pylint: disable=unused-argument
        '''
        Display a repo from the ``/etc/opkg/*.conf``
    
        CLI Examples:
    Severity: Minor
    Found in salt/modules/opkg.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

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

    def __virtual__():
        '''
        Confirm this module is on a nilrt based system
        '''
        if __grains__.get('os_family') == 'NILinuxRT':
    Severity: Minor
    Found in salt/modules/opkg.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 _del_repo_from_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _del_repo_from_file(repo, filepath):
        '''
        Remove a repo from filepath
        '''
        with salt.utils.files.fopen(filepath) as fhandle:
    Severity: Minor
    Found in salt/modules/opkg.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 latest_version has a Cognitive Complexity of 9 (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/opkg.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

    Avoid deeply nested control flow statements.
    Open

                        if not kwargs.get('only_upgrade', False):
                            to_downgrade.append(pkgstr)
                        else:
                            # This should cause the command to fail.
                            to_install.append(pkgstr)
    Severity: Major
    Found in salt/modules/opkg.py - About 45 mins to fix

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

      def refresh_db(failhard=False, **kwargs):  # pylint: disable=unused-argument
          '''
          Updates the opkg database to latest packages based upon repositories
      
          Returns a dict, with the keys being package databases and the values being
      Severity: Minor
      Found in salt/modules/opkg.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 version_cmp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def version_cmp(pkg1, pkg2, ignore_epoch=False, **kwargs):  # pylint: disable=unused-argument
          '''
          Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if
          pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem
          making the comparison.
      Severity: Minor
      Found in salt/modules/opkg.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 list_upgrades has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def list_upgrades(refresh=True, **kwargs):  # pylint: disable=unused-argument
          '''
          List all available package upgrades.
      
          CLI Example:
      Severity: Minor
      Found in salt/modules/opkg.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 owner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def owner(*paths, **kwargs):  # pylint: disable=unused-argument
          '''
          Return the name of the package that owns the file. Multiple file paths can
          be passed. Like :mod:`pkg.version <salt.modules.opkg.version`, if a single
          path is passed, a string will be returned, and if multiple paths are passed,
      Severity: Minor
      Found in salt/modules/opkg.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

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

          if call['retcode'] != 0:
              comment = ''
              if 'stderr' in call:
                  comment += call['stderr']
              if 'stdout' in call:
      Severity: Major
      Found in salt/modules/opkg.py and 1 other location - About 5 hrs to fix
      salt/modules/apkpkg.py on lines 507..515

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

      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 call['retcode'] != 0:
                  comment = ''
                  if call['stderr']:
                      comment += call['stderr']
                  else:
      Severity: Major
      Found in salt/modules/opkg.py and 1 other location - About 3 hrs to fix
      salt/modules/opkg.py on lines 1157..1164

      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

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

                  if call['retcode'] != 0:
                      comment = ''
                      if call['stderr']:
                          comment += call['stderr']
                      else:
      Severity: Major
      Found in salt/modules/opkg.py and 1 other location - About 3 hrs to fix
      salt/modules/opkg.py on lines 1172..1179

      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

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

          for pkgname in to_reinstall:
              if pkgname not in ret or pkgname in old:
                  ret.update({pkgname: {'old': old.get(pkgname, ''),
                                        'new': new.get(pkgname, '')}})
      Severity: Major
      Found in salt/modules/opkg.py and 1 other location - About 2 hrs to fix
      salt/modules/aptpkg.py on lines 771..774

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

      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/opkg.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/pacmanpkg.py on lines 211..217
      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

      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/opkg.py and 1 other location - About 2 hrs to fix
      salt/modules/opkg.py on lines 903..910

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

      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['comment'] = ('Package {0} is set not to be held.'
                                        .format(target))
                  else:
      Severity: Major
      Found in salt/modules/opkg.py and 1 other location - About 2 hrs to fix
      salt/modules/opkg.py on lines 831..838

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

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

          if pkgs:
              targets.extend(pkgs)
          elif sources:
              for source in sources:
                  targets.append(next(iter(source)))
      Severity: Major
      Found in salt/modules/opkg.py and 3 other locations - About 2 hrs to fix
      salt/modules/aptpkg.py on lines 1103..1109
      salt/modules/aptpkg.py on lines 1177..1183
      salt/modules/opkg.py on lines 880..886

      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

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

          if pkgs:
              targets.extend(pkgs)
          elif sources:
              for source in sources:
                  targets.append(next(iter(source)))
      Severity: Major
      Found in salt/modules/opkg.py and 3 other locations - About 2 hrs to fix
      salt/modules/aptpkg.py on lines 1103..1109
      salt/modules/aptpkg.py on lines 1177..1183
      salt/modules/opkg.py on lines 808..814

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

          normalize = lambda x: six.text_type(x).split(':', 1)[-1] if ignore_epoch else six.text_type(x)
      Severity: Major
      Found in salt/modules/opkg.py and 4 other locations - About 40 mins to fix
      salt/modules/aptpkg.py on lines 1425..1426
      salt/modules/rpm_lowpkg.py on lines 696..698
      salt/states/pip_state.py on lines 306..306
      salt/utils/versions.py on lines 243..244

      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 to_reinstall:
              cmd = copy.deepcopy(cmd_prefix)
              cmd.append('--force-reinstall')
              cmd.extend(to_reinstall)
              cmds.append(cmd)
      Severity: Minor
      Found in salt/modules/opkg.py and 1 other location - About 40 mins to fix
      salt/modules/opkg.py on lines 322..326

      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 to_downgrade:
              cmd = copy.deepcopy(cmd_prefix)
              cmd.append('--force-downgrade')
              cmd.extend(to_downgrade)
              cmds.append(cmd)
      Severity: Minor
      Found in salt/modules/opkg.py and 1 other location - About 40 mins to fix
      salt/modules/opkg.py on lines 327..331

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

              elif state == 'hold':
                  if 'test' in __opts__ and __opts__['test']:
                      ret[target].update(result=None)
                      ret['comment'] = ('Package {0} is set not to be held.'
                                        .format(target))
      Severity: Major
      Found in salt/modules/opkg.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/pkgng.py on lines 1942..1959
      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

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

              elif state != 'hold':
                  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/opkg.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 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
      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