saltstack/salt

View on GitHub
salt/modules/win_pkg.py

Summary

Maintainability
F
3 wks
Test Coverage

File win_pkg.py has 1625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
A module to manage software on Windows

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

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

    def install(name=None, refresh=False, pkgs=None, **kwargs):
        r'''
        Install the passed package(s) on the system using winrepo
    
        Args:
    Severity: Minor
    Found in salt/modules/win_pkg.py - About 2 days to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function _get_reg_software has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_reg_software(include_components=True,
                          include_updates=True):
        '''
        This searches the uninstall keys in the registry to find a match in the sub
        keys, it will return a dict with the display name as the key and the
    Severity: Minor
    Found in salt/modules/win_pkg.py - About 2 days to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function remove has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove(name=None, pkgs=None, **kwargs):
        '''
        Remove the passed package(s) from the system using winrepo
    
        .. versionadded:: 0.16.0
    Severity: Minor
    Found in salt/modules/win_pkg.py - About 2 days to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    def install(name=None, refresh=False, pkgs=None, **kwargs):
        r'''
        Install the passed package(s) on the system using winrepo
    
        Args:
    Severity: Minor
    Found in salt/modules/win_pkg.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 remove. (43)
    Open

    def remove(name=None, pkgs=None, **kwargs):
        '''
        Remove the passed package(s) from the system using winrepo
    
        .. versionadded:: 0.16.0
    Severity: Minor
    Found in salt/modules/win_pkg.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 list_pkgs has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_pkgs(versions_as_list=False,
                  include_components=True,
                  include_updates=True,
                  **kwargs):
        '''
    Severity: Minor
    Found in salt/modules/win_pkg.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 _get_reg_software. (37)
    Open

    def _get_reg_software(include_components=True,
                          include_updates=True):
        '''
        This searches the uninstall keys in the registry to find a match in the sub
        keys, it will return a dict with the display name as the key and the
    Severity: Minor
    Found in salt/modules/win_pkg.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 _repo_process_pkg_sls has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def _repo_process_pkg_sls(filename, short_path_name, ret, successful_verbose):
        renderers = salt.loader.render(__opts__, __salt__)
    
        def _failed_compile(prefix_msg, error_msg):
            log.error('%s \'%s\': %s ', prefix_msg, short_path_name, error_msg)
    Severity: Minor
    Found in salt/modules/win_pkg.py - About 3 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function genrepo has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def genrepo(**kwargs):
        '''
        Generate package metadata db based on files within the winrepo_source_dir
    
        Kwargs:
    Severity: Minor
    Found in salt/modules/win_pkg.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 refresh_db has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def refresh_db(**kwargs):
        r'''
        Generates the local software metadata database (`winrepo.p`) on the minion.
        The database is stored in a serialized format located by default at the
        following location:
    Severity: Minor
    Found in salt/modules/win_pkg.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 latest_version has a Cognitive Complexity of 16 (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/win_pkg.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 _get_repo_details has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_repo_details(saltenv):
        '''
        Return repo details for the specified saltenv as a namedtuple
        '''
        contextkey = 'winrepo._get_repo_details.{0}'.format(saltenv)
    Severity: Minor
    Found in salt/modules/win_pkg.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_available has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_available(*names, **kwargs):
        '''
        Return a list of available versions of the specified package.
    
        Args:
    Severity: Minor
    Found in salt/modules/win_pkg.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

    Avoid deeply nested control flow statements.
    Open

                        if not cached_file:
                            log.error('Unable to cache %s', cache_file)
                            ret[pkg_name] = {
                                'failed to cache cache_file': cache_file
                            }
    Severity: Major
    Found in salt/modules/win_pkg.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for pkg_ver in pkg_info.keys():
                              if pkg_info[pkg_ver]['full_name'] == pkg_name:
                                  val = pkg_ver
                      __salt__['pkg_resource.add_pkg'](ret, key, val)
      Severity: Major
      Found in salt/modules/win_pkg.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if report_reboot_exit_codes:
                                __salt__['system.set_reboot_required_witnessed']()
                            ret[pkgname] = {'uninstall status': 'success, reboot required'}
        Severity: Major
        Found in salt/modules/win_pkg.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if not cached_pkg:
                                  log.error('Unable to cache %s', uninstaller)
                                  ret[pkgname] = {'unable to cache': uninstaller}
                                  continue
          
          
          Severity: Major
          Found in salt/modules/win_pkg.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if not pkg_info:
                                    continue
                                for pkg_ver in pkg_info.keys():
            Severity: Major
            Found in salt/modules/win_pkg.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  while time.time() < t_end:
                                      time.sleep(0.25)
                                      task_running = __salt__['task.status'](
                                              'update-salt-software') == 'Running'
                                      if task_running:
              Severity: Major
              Found in salt/modules/win_pkg.py - About 45 mins to fix

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

                def _get_source_sum(source_hash, file_path, saltenv):
                    '''
                    Extract the hash sum, whether it is in a remote hash file, or just a string.
                    '''
                    ret = dict()
                Severity: Minor
                Found in salt/modules/win_pkg.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 not cached_pkg:
                                        log.error('Unable to cache %s', installer)
                                        ret[pkg_name] = {'unable to cache': installer}
                                        continue
                        else:
                Severity: Major
                Found in salt/modules/win_pkg.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if __salt__['cp.hash_file'](uninstaller, saltenv) != \
                                              __salt__['cp.hash_file'](cached_pkg):
                                          try:
                                              cached_pkg = __salt__['cp.cache_file'](
                                                  uninstaller, saltenv)
                  Severity: Major
                  Found in salt/modules/win_pkg.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if not task_running:
                                            log.error('Failed to install %s', pkg_name)
                                            log.error('Scheduled Task failed to run')
                                            ret[pkg_name] = {'install status': 'failed'}
                    
                    
                    Severity: Major
                    Found in salt/modules/win_pkg.py - About 45 mins to fix

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

                      def list_upgrades(refresh=True, **kwargs):
                          '''
                          List all available package upgrades on this system
                      
                          Args:
                      Severity: Minor
                      Found in salt/modules/win_pkg.py - About 25 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

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

                      def _refresh_db_conditional(saltenv, **kwargs):
                          '''
                          Internal use only in this module, has a different set of defaults and
                          returns True or False. And supports checking the age of the existing
                          generated metadata db, as well as ensure metadata db exists to begin with
                      Severity: Minor
                      Found in salt/modules/win_pkg.py - About 25 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

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

                      def compare_versions(ver1='', oper='==', ver2=''):
                          '''
                          Compare software package versions
                      
                          Args:
                      Severity: Minor
                      Found in salt/modules/win_pkg.py - About 25 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

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

                      def get_repo_data(saltenv='base'):
                          '''
                          Returns the existing package metadata db. Will create it, if it does not
                          exist, however will not refresh it.
                      
                      
                      Severity: Minor
                      Found in salt/modules/win_pkg.py - About 25 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

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

                      def _get_msiexec(use_msiexec):
                          '''
                          Return if msiexec.exe will be used and the command to invoke it.
                          '''
                          if use_msiexec is False:
                      Severity: Minor
                      Found in salt/modules/win_pkg.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

                                      if not result['retcode']:
                                          ret[pkgname] = {'uninstall status': 'success'}
                                          changed.append(pkgname)
                                      elif result['retcode'] == 3010:
                                          # 3010 is ERROR_SUCCESS_REBOOT_REQUIRED
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 1 day to fix
                      salt/modules/win_pkg.py on lines 1693..1712

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

                      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 not result['retcode']:
                                      ret[pkg_name] = {'install status': 'success'}
                                      changed.append(pkg_name)
                                  elif result['retcode'] == 3010:
                                      # 3010 is ERROR_SUCCESS_REBOOT_REQUIRED
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 1 day to fix
                      salt/modules/win_pkg.py on lines 2005..2024

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

                      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 sub_key in __utils__['reg.list_keys'](hive=kwargs['hive'],
                                                                        key=kwargs['key'],
                                                                        use_32bit_registry=kwargs['use_32bit']):
                                  kwargs['sub_key'] = sub_key
                                  if skip_component(**kwargs):
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 6 hrs to fix
                      salt/modules/win_pkg.py on lines 651..665

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

                      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 sub_key in __utils__['reg.list_keys'](hive=kwargs['hive'],
                                                                    key=kwargs['key'],
                                                                    use_32bit_registry=kwargs['use_32bit']):
                              kwargs['sub_key'] = sub_key
                              if skip_component(**kwargs):
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 6 hrs to fix
                      salt/modules/win_pkg.py on lines 732..746

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

                      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 uninstaller.startswith('salt:'):
                                          if __salt__['cp.hash_file'](uninstaller, saltenv) != \
                                                  __salt__['cp.hash_file'](cached_pkg):
                                              try:
                                                  cached_pkg = __salt__['cp.cache_file'](
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 6 hrs to fix
                      salt/modules/win_pkg.py on lines 1572..1584

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 110.

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

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

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

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

                      Refactorings

                      Further Reading

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

                                  if installer.startswith('salt:'):
                                      if __salt__['cp.hash_file'](installer, saltenv) != \
                                              __salt__['cp.hash_file'](cached_pkg):
                                          try:
                                              cached_pkg = __salt__['cp.cache_file'](installer, saltenv)
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 6 hrs to fix
                      salt/modules/win_pkg.py on lines 1931..1944

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 110.

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

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

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

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

                      Refactorings

                      Further Reading

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

                              for sub_key in __utils__['reg.list_keys'](hive=kwargs['hive'],
                                                                        key=kwargs['key']):
                                  kwargs['sub_key'] = sub_key
                                  if skip_component(**kwargs):
                                      continue
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 5 hrs to fix
                      salt/modules/win_pkg.py on lines 634..647

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

                      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 sub_key in __utils__['reg.list_keys'](hive=kwargs['hive'],
                                                                    key=kwargs['key']):
                              kwargs['sub_key'] = sub_key
                              if skip_component(**kwargs):
                                  continue
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 5 hrs to fix
                      salt/modules/win_pkg.py on lines 698..711

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

                      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

                                  __salt__['task.create_task'](name='update-salt-software',
                                                               user_name='System',
                                                               force=True,
                                                               action_type='Execute',
                                                               cmd=cmd_shell,
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 2 hrs to fix
                      salt/modules/win_pkg.py on lines 1981..1986

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

                                      __salt__['task.create_task'](name='update-salt-software',
                                                                   user_name='System',
                                                                   force=True,
                                                                   action_type='Execute',
                                                                   cmd=cmd_shell,
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 2 hrs to fix
                      salt/modules/win_pkg.py on lines 1641..1646

                      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

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

                                  if re.search(r'salt[\s_.-]*minion',
                                               pkg_name,
                                               flags=re.IGNORECASE + re.UNICODE) is not None:
                                      ret[pkg_name] = {'install status': 'task started'}
                                      if not __salt__['task.run'](name='update-salt-software'):
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 1 hr to fix
                      salt/modules/win_pkg.py on lines 1994..1997

                      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

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

                                      if not __salt__['task.run_wait'](name='update-salt-software'):
                                          log.error('Failed to remove %s', pkgname)
                                          log.error('Scheduled Task failed to run')
                                          ret[pkgname] = {'uninstall status': 'failed'}
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 1 hr to fix
                      salt/modules/win_pkg.py on lines 1656..1685

                      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

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

                                      if __salt__['cp.hash_file'](cache_file, saltenv) != \
                                              __salt__['cp.hash_file'](cached_file):
                                          cached_file = __salt__['cp.cache_file'](cache_file, saltenv)
                      
                                          # Check if the cache_file was cached successfully
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 1 hr to fix
                      salt/modules/win_pkg.py on lines 1918..1926

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

                                      if not cached_pkg:
                                          # It's not cached. Cache it, mate.
                                          cached_pkg = __salt__['cp.cache_file'](uninstaller, saltenv)
                      
                                          # Check if the uninstaller was cached successfully
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 1 hr to fix
                      salt/modules/win_pkg.py on lines 1543..1553

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

                          try:
                              os.makedirs(local_dest)
                          except OSError as exc:
                              if exc.errno != errno.EEXIST:
                                  raise CommandExecutionError(
                      Severity: Major
                      Found in salt/modules/win_pkg.py and 1 other location - About 1 hr to fix
                      salt/cache/localfs.py on lines 49..55

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 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

                                  if __utils__['reg.read_value'](
                                          hive=hive,
                                          key='{0}\\{1}'.format(key, sub_key),
                      Severity: Minor
                      Found in salt/modules/win_pkg.py and 1 other location - About 35 mins to fix
                      salt/modules/win_pkg.py on lines 492..494

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 41.

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

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

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

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

                      Refactorings

                      Further Reading

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

                                  if __utils__['reg.read_value'](
                                          hive=hive,
                                          key='{0}\\{1}'.format(key, sub_key),
                      Severity: Minor
                      Found in salt/modules/win_pkg.py and 1 other location - About 35 mins to fix
                      salt/modules/win_pkg.py on lines 516..518

                      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