saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if isinstance(requested_policy_check, six.string_types):
                        policies_are_equal = requested_policy_check == current_policy_check
                    elif isinstance(requested_policy_check, list):
                        policies_are_equal = salt.utils.data.compare_lists(
                            requested_policy_check,
Severity: Major
Found in salt/states/win_lgpo.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if reduced or _name_matches(k, names):
                            newlist.append(reduced)
                    if newlist:
    Severity: Major
    Found in salt/states/boto_apigateway.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if current[m] != desired[m]:
                              need_update[m] = desired[m]
          return need_update
      Severity: Major
      Found in salt/states/boto3_elasticache.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if current[m] != desired[m]:
                                need_update[m] = desired[m]
            return need_update
        Severity: Major
        Found in salt/states/boto3_elasticache.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if all(x == '' for x in old):
                                      return True
                              except TypeError:
          Severity: Major
          Found in salt/states/docker_container.py - About 45 mins to fix

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

            def import_cert(name, cert_format=_DEFAULT_FORMAT, context=_DEFAULT_CONTEXT, store=_DEFAULT_STORE,
                            exportable=True, password='', saltenv='base'):
                '''
                Import the certificate file into the given certificate store.
            
            
            Severity: Minor
            Found in salt/states/win_pki.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 _run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def _run(name, mod, kwargs):
                ret = {'name': name,
                       'changes': {},
                       'result': None,
                       'comment': ''}
            Severity: Minor
            Found in salt/states/chef.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 val is None:
                                    errors.append(
                                        'Config option \'{0}\' for network \'{1}\' is '
                                        'missing a value'.format(key, net_name)
                                    )
            Severity: Major
            Found in salt/states/docker_container.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if val:
                                      net_changes[key] = {'old': None, 'new': val}
                                      try:
                                          net_changes.pop('IPConfiguration')
                                      except KeyError:
              Severity: Major
              Found in salt/states/docker_container.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if 'error' in updatedint:
                                        error.append(updatedint['error'])
                
                
                Severity: Major
                Found in salt/states/zabbix_host.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for col, val in six.iteritems(res):
                                          output_file.write(
                                              salt.utils.stringutils.to_str(
                                                  col + ':' + val + '\n'
                                              )
                  Severity: Major
                  Found in salt/states/mysql_query.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if key in interface_attrs:
                                                interfaces_dict[intf_name][key] = value
                    
                    
                    Severity: Major
                    Found in salt/states/zabbix_host.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          for interface in hostinterfaces:
                                              __salt__['zabbix.hostinterface_delete'](interfaceids=interface['interfaceid'],
                                                                                      **connection_args)
                      
                      
                      Severity: Major
                      Found in salt/states/zabbix_host.py - About 45 mins to fix

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

                        def _find_image(name):
                            '''
                            Tries to find image with given name, returns
                                - image, 'Found image <name>'
                                - None, 'No such image found'
                        Severity: Minor
                        Found in salt/states/glance.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 module != mod:
                                                loaded_by_dependency.append(module)
                                        loaded['yes'].append(mod)
                        Severity: Major
                        Found in salt/states/kmod.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              for module in unload_result:
                                                  ret['changes'][module] = 'removed'
                                              unloaded['yes'].append(mod)
                          Severity: Major
                          Found in salt/states/kmod.py - About 45 mins to fix

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

                            def _inherited_dashboard(dashboard, base_dashboards_from_pillar, ret):
                                '''Return a dashboard with properties from parents.'''
                                base_dashboards = []
                                for base_dashboard_from_pillar in base_dashboards_from_pillar:
                                    base_dashboard = __salt__['pillar.get'](base_dashboard_from_pillar)
                            Severity: Minor
                            Found in salt/states/grafana4_dashboard.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

                                                for col, val in six.iteritems(query_result):
                                                    output_file.write(
                                                        salt.utils.stringutils.to_str(
                                                            '{0}:{1}\n'.format(col, val)
                                                        )
                            Severity: Major
                            Found in salt/states/mysql_query.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if current[m] != desired[m]:
                                                      need_update[m] = desired[m]
                                  return need_update
                              Severity: Major
                              Found in salt/states/boto3_elasticache.py - About 45 mins to fix

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

                                def absent(name, user=None, signal=None):
                                    '''
                                    Ensures that the named command is not running.
                                
                                    name
                                Severity: Minor
                                Found in salt/states/process.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

                                Severity
                                Category
                                Status
                                Source
                                Language