saltstack/salt

View on GitHub

Showing 17,495 of 17,590 total issues

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

    if output == 'grain':
        if grain is not None and key is None:
            if not overwrite and grain in __salt__['grains.ls']():
                ret['comment'] = 'No execution needed. Grain ' + grain\
                               + ' already set'
Severity: Major
Found in salt/states/mysql_query.py and 1 other location - About 4 days to fix
salt/states/mysql_query.py on lines 127..170

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

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

File __init__.py has 1718 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
The client module is used to create a client connection to the publisher
The data structure needs to be:
    {'enc': 'clear',
Severity: Major
Found in salt/client/__init__.py - About 4 days to fix

    File bigip.py has 1714 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    '''
    An execution module which can manipulate an f5 bigip via iControl REST
        :maturity:      develop
        :platform:      f5_bigip_11.6
    Severity: Major
    Found in salt/modules/bigip.py - About 4 days to fix

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

          if existing_obj:
              diff_params = __salt__['zabbix.compare_params'](input_params, existing_obj)
              log.info('Zabbix Value map: input params: {%s', six.text_type(json.dumps(input_params, indent=4)))
              log.info('Zabbix Value map: Object comparison result. Differences: %s', six.text_type(diff_params))
      
      
      Severity: Major
      Found in salt/states/zabbix_valuemap.py and 1 other location - About 4 days to fix
      salt/states/zabbix_action.py on lines 104..149

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

      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 existing_obj:
              diff_params = __salt__['zabbix.compare_params'](input_params, existing_obj)
              log.info('Zabbix Action: input params: {%s', six.text_type(json.dumps(input_params, indent=4)))
              log.info('Zabbix Action: Object comparison result. Differences: %s', six.text_type(diff_params))
      
      
      Severity: Major
      Found in salt/states/zabbix_action.py and 1 other location - About 4 days to fix
      salt/states/zabbix_valuemap.py on lines 79..124

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

      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

      def _create_resource(name, name_param=None, desc=None, res_type=None, wait=0, status_param=None,
                           status_good='available', region=None, key=None, keyid=None, profile=None,
                           **args):
          try:
              wait = int(wait)
      Severity: Major
      Found in salt/modules/boto3_elasticache.py and 1 other location - About 4 days to fix
      salt/modules/boto3_elasticache.py on lines 231..281

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

      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

      def _modify_resource(name, name_param=None, desc=None, res_type=None, wait=0, status_param=None,
                           status_good='available', region=None, key=None, keyid=None, profile=None,
                           **args):
          try:
              wait = int(wait)
      Severity: Major
      Found in salt/modules/boto3_elasticache.py and 1 other location - About 4 days to fix
      salt/modules/boto3_elasticache.py on lines 178..228

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

      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

      Function _manage_devices has a Cognitive Complexity of 222 (exceeds 5 allowed). Consider refactoring.
      Open

      def _manage_devices(devices, vm=None, container_ref=None, new_vm_name=None):
          unit_number = 0
          bus_number = 0
          device_specs = []
          existing_disks_label = []
      Severity: Minor
      Found in salt/cloud/clouds/vmware.py - About 4 days to fix

      Cognitive Complexity

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

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

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

      Further reading

      File boto_apigateway.py has 1684 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      '''
      Manage Apigateway Rest APIs
      ===========================
      
      
      Severity: Major
      Found in salt/states/boto_apigateway.py - About 4 days to fix

        File ipaddress.py has 1677 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        '''
        Python 2.[67] port of Python 3.4's ipaddress module
        
        Almost verbatim copy of the core lib, with compatibility changes
        Source: https://bitbucket.org/kwi/py2-ipaddress/
        Severity: Major
        Found in salt/ext/ipaddress.py - About 4 days to fix

          Function installed has a Cognitive Complexity of 220 (exceeds 5 allowed). Consider refactoring.
          Open

          def installed(
                  name,
                  version=None,
                  refresh=None,
                  fromrepo=None,
          Severity: Minor
          Found in salt/states/pkg.py - About 4 days to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function _check_perms has a Cognitive Complexity of 219 (exceeds 5 allowed). Consider refactoring.
          Open

          def _check_perms(obj_name, obj_type, new_perms, cur_perms, access_mode, ret):
              '''
              Helper function used by ``check_perms`` for checking and setting Grant and
              Deny permissions.
          
          
          Severity: Minor
          Found in salt/utils/win_dacl.py - About 4 days to fix

          Cognitive Complexity

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

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

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

          Further reading

          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

            File network.py has 1624 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            '''
            Define some generic socket functions for network modules
            '''
            
            
            Severity: Major
            Found in salt/utils/network.py - About 4 days to fix

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

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

              Cognitive Complexity

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

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

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

              Further reading

              File tls.py has 1617 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # -*- coding: utf-8 -*-
              r'''
              A salt module for SSL/TLS.
              Can create a Certificate Authority (CA)
              or use Self-Signed certificates.
              Severity: Major
              Found in salt/modules/tls.py - About 4 days to fix

                Function manage_file has a Cognitive Complexity of 211 (exceeds 5 allowed). Consider refactoring.
                Open

                def manage_file(name,
                                sfn,
                                ret,
                                source,
                                source_sum,
                Severity: Minor
                Found in salt/modules/file.py - About 4 days to fix

                Cognitive Complexity

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

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

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

                Further reading

                File loader.py has 1602 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # -*- coding: utf-8 -*-
                '''
                The Salt loader is the core to Salt's plugin system, the loader scans
                directories for python loadable code and organizes the code into the
                plugin interfaces used by Salt.
                Severity: Major
                Found in salt/loader.py - About 4 days to fix

                  Function _check_directory_win has a Cognitive Complexity of 204 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _check_directory_win(name,
                                           win_owner=None,
                                           win_perms=None,
                                           win_deny_perms=None,
                                           win_inheritance=None,
                  Severity: Minor
                  Found in salt/states/file.py - About 4 days to fix

                  Cognitive Complexity

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

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

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

                  Further reading

                  File debian_ip.py has 1555 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # -*- coding: utf-8 -*-
                  '''
                  The networking module for Debian-based distros
                  
                  References:
                  Severity: Major
                  Found in salt/modules/debian_ip.py - About 4 days to fix
                    Severity
                    Category
                    Status
                    Source
                    Language