saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if '=' in val:
                            deep_key, val = val.split('=', 1)
                            deep_key = deep_key.strip()
                            val = val.strip()
                            if val:
Severity: Major
Found in salt/modules/disk.py - About 45 mins to fix

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

    def _docker_client(wrapped):
        '''
        Decorator to run a function that requires the use of a docker.Client()
        instance.
        '''
    Severity: Minor
    Found in salt/modules/dockermod.py - About 45 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    def logs(name, **kwargs):
        '''
        .. versionchanged:: 2018.3.0
            Support for all of docker-py's `logs()`_ function's arguments, with the
            exception of ``stream``.
    Severity: Minor
    Found in salt/modules/dockermod.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 'enabled' in schedule and not schedule['enabled']:
                                ret['result'] = True
                                ret['comment'] = 'Disabled schedule on minion.'
                            else:
                                ret['result'] = False
    Severity: Major
    Found in salt/modules/schedule.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if name in schedule and schedule[name]['enabled']:
                                  ret['result'] = True
                                  ret['comment'] = 'Postponed Job {0} in schedule.'.format(name)
                              else:
                                  ret['result'] = False
      Severity: Major
      Found in salt/modules/schedule.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if name in schedule and schedule[name]['enabled']:
                                    ret['result'] = True
                                    ret['comment'] = 'Enabled Job {0} in schedule.'.format(name)
                                else:
                                    ret['result'] = False
        Severity: Major
        Found in salt/modules/schedule.py - About 45 mins to fix

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

          def delete_cloud_front_origin_access_identity(region=None, key=None, keyid=None, profile=None,
                                                        **kwargs):
              '''
              Delete a CloudFront origin access identity.
          
          
          Severity: Minor
          Found in salt/modules/boto_cloudfront.py - About 45 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

          def set_offload(devname, **kwargs):
              '''
              Changes the offload parameters and other features of the specified network device
          
              CLI Example:
          Severity: Minor
          Found in salt/modules/ethtool.py - About 45 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

          def vgcreate(vgname, devices, **kwargs):
              '''
              Create an LVM volume group
          
              CLI Examples:
          Severity: Minor
          Found in salt/modules/linux_lvm.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 key == 'Aliases':
                                  try:
                                      val.remove(result2['Config']['Hostname'])
                                  except (ValueError, AttributeError):
                                      pass
          Severity: Major
          Found in salt/modules/dockermod.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if not old_val:
                                    old_val = None
                                try:
            Severity: Major
            Found in salt/modules/dockermod.py - About 45 mins to fix

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

              def rm_(name, force=False, volumes=False, **kwargs):
                  '''
                  Removes a container
              
                  name
              Severity: Minor
              Found in salt/modules/dockermod.py - About 45 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

              def wait(name, ignore_already_stopped=False, fail_on_exit_status=False):
                  '''
                  Wait for the container to exit gracefully, and return its exit code
              
                  .. note::
              Severity: Minor
              Found in salt/modules/dockermod.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 new_val:
                                      new_val = None
                              elif key == 'IPAMConfig':
              Severity: Major
              Found in salt/modules/dockermod.py - About 45 mins to fix

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

                def install(app_id, enable=True):
                    '''
                    Install a bundle ID or command as being allowed to use
                    assistive access.
                
                
                Severity: Minor
                Found in salt/modules/mac_assistive.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 SPLIT not in line:
                                            SPLIT = SPLIT.strip()
                                        key, value = line.split(SPLIT, 1)
                Severity: Major
                Found in salt/modules/linux_sysctl.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if not val:
                                              # The only alias was the default one for the
                                              # hostname
                                              continue
                                  ret.setdefault(net_name, {})[key] = {'old': val, 'new': None}
                  Severity: Major
                  Found in salt/modules/dockermod.py - About 45 mins to fix

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

                    def NS(domain, resolve=True, nameserver=None):
                        '''
                        Return a list of IPs of the nameservers for ``domain``
                    
                        If ``resolve`` is False, don't resolve names.
                    Severity: Minor
                    Found in salt/modules/dig.py - About 45 mins to fix

                    Cognitive Complexity

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

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

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

                    Further reading

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

                    def create_snapshot(vm, name, key='uuid'):
                        '''
                        Create snapshot of a vm
                    
                        vm : string
                    Severity: Minor
                    Found in salt/modules/smartos_vmadm.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 config1 != config2:
                                            ret.setdefault('IPAM', {})['Config'] = {
                                                'old': config1, 'new': config2
                                            }
                                    elif subval1 != subval2:
                    Severity: Major
                    Found in salt/modules/dockermod.py - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language