saltstack/salt

View on GitHub

Showing 17,495 of 17,590 total issues

File mount.py has 1441 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''

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

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

                try:
                    minion_blackout_violation = False
                    if minion_instance.connected and minion_instance.opts['pillar'].get('minion_blackout', False):
                        whitelist = minion_instance.opts['pillar'].get('minion_blackout_whitelist', [])
                        # this minion is blacked out. Only allow saltutil.refresh_pillar and the whitelist
    Severity: Major
    Found in salt/minion.py and 1 other location - About 3 days to fix
    salt/metaproxy/proxy.py on lines 368..491

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

    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

            try:
                minion_blackout_violation = False
                if minion_instance.connected and minion_instance.opts['pillar'].get('minion_blackout', False):
                    whitelist = minion_instance.opts['pillar'].get('minion_blackout_whitelist', [])
                    # this minion is blacked out. Only allow saltutil.refresh_pillar and the whitelist
    Severity: Major
    Found in salt/metaproxy/proxy.py and 1 other location - About 3 days to fix
    salt/minion.py on lines 1673..1796

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

    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 napalm_mod.py has 1436 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    '''
    NAPALM helpers
    ==============
    
    
    Severity: Major
    Found in salt/modules/napalm_mod.py - About 3 days to fix

      File x509.py has 1411 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      '''
      Manage X509 certificates
      
      .. versionadded:: 2015.8.0
      Severity: Major
      Found in salt/modules/x509.py - About 3 days to fix

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

        # -*- coding: utf-8 -*-
        '''
        Create ssh executor system
        '''
        # Import python libs
        Severity: Major
        Found in salt/client/ssh/__init__.py - About 3 days to fix

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

          def image_update(call=None, kwargs=None):
              '''
              Replaces the image template contents.
          
              .. versionadded:: 2016.3.0
          Severity: Major
          Found in salt/cloud/clouds/opennebula.py and 2 other locations - About 3 days to fix
          salt/cloud/clouds/opennebula.py on lines 2178..2287
          salt/cloud/clouds/opennebula.py on lines 2563..2672

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

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

          def secgroup_update(call=None, kwargs=None):
              '''
              Replaces the security group template contents.
          
              .. versionadded:: 2016.3.0
          Severity: Major
          Found in salt/cloud/clouds/opennebula.py and 2 other locations - About 3 days to fix
          salt/cloud/clouds/opennebula.py on lines 1789..1894
          salt/cloud/clouds/opennebula.py on lines 2563..2672

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

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

          def template_update(call=None, kwargs=None):
              '''
              Replaces the template contents.
          
              .. versionadded:: 2016.3.0
          Severity: Major
          Found in salt/cloud/clouds/opennebula.py and 2 other locations - About 3 days to fix
          salt/cloud/clouds/opennebula.py on lines 1789..1894
          salt/cloud/clouds/opennebula.py on lines 2178..2287

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

          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 create has a Cognitive Complexity of 180 (exceeds 5 allowed). Consider refactoring.
          Open

          def create(vm_):
              '''
              To create a single VM in the VMware environment.
          
              Sample profile and arguments that can be specified in it can be found
          Severity: Minor
          Found in salt/cloud/clouds/vmware.py - About 3 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 schedule.py has 1384 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          
          # See doc/topics/jobs/index.rst
          '''
          Scheduling routines are located here. To activate the scheduler make the
          Severity: Major
          Found in salt/utils/schedule.py - About 3 days to fix

            Function managed has a Cognitive Complexity of 178 (exceeds 5 allowed). Consider refactoring.
            Open

            def managed(name,
                        source=None,
                        source_hash='',
                        source_hash_name=None,
                        keep_source=True,
            Severity: Minor
            Found in salt/states/file.py - About 3 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

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

                if policies_to_create or policies_to_delete:
                    _to_modify = list(policies_to_delete)
                    _to_modify.extend(policies_to_create)
                    if __opts__['test']:
                        ret['comment'] = '{0} policies to be modified on role {1}.'.format(', '.join(_to_modify), name)
            Severity: Major
            Found in salt/states/boto_iam_role.py and 1 other location - About 3 days to fix
            salt/states/boto_iam.py on lines 1038..1074

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

            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 isinstance(roles, (list)):
                    # compute changed
                    roles_current = __salt__['rbac.role_get'](name)
                    roles_add = [r for r in roles if r not in roles_current]
                    roles_rm = [r for r in roles_current if r not in roles]
            Severity: Major
            Found in salt/states/rbac_solaris.py and 1 other location - About 3 days to fix
            salt/states/rbac_solaris.py on lines 127..153

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

            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 isinstance(profiles, (list)):
                    # compute changed
                    profiles_current = __salt__['rbac.profile_get'](name)
                    profiles_add = [r for r in profiles if r not in profiles_current]
                    profiles_rm = [r for r in profiles_current if r not in profiles]
            Severity: Major
            Found in salt/states/rbac_solaris.py and 1 other location - About 3 days to fix
            salt/states/rbac_solaris.py on lines 98..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 382.

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

                if policies_to_create or policies_to_delete:
                    _to_modify = list(policies_to_delete)
                    _to_modify.extend(policies_to_create)
                    if __opts__['test']:
                        ret['comment'] = '{0} policies to be modified on group {1}.'.format(', '.join(_to_modify), name)
            Severity: Major
            Found in salt/states/boto_iam.py and 1 other location - About 3 days to fix
            salt/states/boto_iam_role.py on lines 391..431

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

            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 saltutil.py has 1374 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            '''
            The Saltutil module is used to manage the state of the salt minion itself. It
            is used to manage minion modules as well as automate updates to the salt
            minion.
            Severity: Major
            Found in salt/modules/saltutil.py - About 3 days to fix

              File boto_cloudfront.py has 1344 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # -*- coding: utf-8 -*-
              '''
              Connection module for Amazon CloudFront
              
              .. versionadded:: 2018.3.0
              Severity: Major
              Found in salt/modules/boto_cloudfront.py - About 3 days to fix

                Function verify_high has a Cognitive Complexity of 173 (exceeds 5 allowed). Consider refactoring.
                Open

                    def verify_high(self, high):
                        '''
                        Verify that the high data is viable and follows the data structure
                        '''
                        errors = []
                Severity: Minor
                Found in salt/state.py - About 3 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

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

                        for setting_number in range(13):
                            setting = 'scsi{0}'.format(setting_number)
                            if setting in vm_:
                                vm_config = query('get', 'nodes/{0}/qemu/{1}/config'.format(vm_['host'], vmid))
                                if setting in vm_config:
                Severity: Major
                Found in salt/cloud/clouds/proxmox.py and 1 other location - About 3 days to fix
                salt/cloud/clouds/proxmox.py on lines 668..702

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

                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

                Severity
                Category
                Status
                Source
                Language