saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if optval in ('""', "''"):
                            optval = ''
                    self._add_option(cursect, optname, optval)
Severity: Major
Found in salt/utils/configparser.py - About 45 mins to fix

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

    def merge_subreturn(original_return, sub_return, subkey=None):
        '''
        Update an existing state return (`original_return`) in place
        with another state return (`sub_return`), i.e. for a subresource.
    
    
    Severity: Minor
    Found in salt/utils/state.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 idx in range(len(bindings[cport])):
                            if bindings[cport][idx] is None:
                                # Now that we are adding multiple
                                # bindings
                                try:
    Severity: Major
    Found in salt/utils/docker/translate/container.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                      if 'kb' + kb in item.lower():
                                          pkg = item.split(' : ')[1]
      
                                          ret['DismPackage'] = pkg
      
      
      Severity: Major
      Found in salt/utils/win_update.py - About 45 mins to fix

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

        def human_to_bytes(size):
            '''
            Given a human-readable byte string (e.g. 2G, 30M),
            return the number of bytes.  Will return 0 if the argument has
            unexpected form.
        Severity: Minor
        Found in salt/utils/stringutils.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 _string_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _string_check(self, value, allow_list=False):
                '''
                Based on the string-checking code from the SafeConfigParser's set()
                function, this enforces string values for config options.
                '''
        Severity: Minor
        Found in salt/utils/configparser.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 LooseVersion(version_text) <= LooseVersion(ver_item):
                                    break
                                insert_point += 1
        Severity: Major
        Found in salt/utils/pkg/win.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if not update.IsInstalled:
                                          ret['Updates'][uid]['Result'] = \
                                              'Uninstallation Succeeded'
                                      else:
                                          ret['Updates'][uid]['Result'] = \
          Severity: Major
          Found in salt/utils/win_update.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if comment:
                                    if not curr_desc:
                                        pp_res['desc'] = comment
                                    elif comment != curr_desc:
                                        pp_res['desc'] = '{0}, {1}'.format(curr_desc, comment)
            Severity: Major
            Found in salt/utils/dns.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if not isinstance(fchunk, list):
                                      continue
                                  else:
                                      # bydefault onfail will fail, but you can
                                      # set onfail_stop: False to prevent the highstate
              Severity: Major
              Found in salt/utils/state.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if isinstance(bindings[cport], list):
                                        # Append to existing list of bindings for this
                                        # container port.
                                        bindings[cport].append(bind_def)
                                    else:
                Severity: Major
                Found in salt/utils/docker/translate/container.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if isinstance(curr_proto, (list, tuple)):
                                          curr_proto.append(proto)
                                      else:
                                          pp_res['proto'] = [curr_proto, proto]
                  
                  
                  Severity: Major
                  Found in salt/utils/dns.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                    if ip_net not in sortlist:
                                                        sortlist.append(ip_net)
                                        elif directive == 'options':
                    Severity: Major
                    Found in salt/utils/dns.py - About 45 mins to fix

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

                      def translate_command(val):
                          '''
                          Input should either be a single string, or a list of strings. This is used
                          for the two args that deal with commands ("command" and "entrypoint").
                          '''
                      Severity: Minor
                      Found in salt/utils/docker/translate/helpers.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 in ip_raw:
                                                          # No netmask has been provided, guess
                                                          # the "natural" one
                                                          if ip_net.version == 4:
                                                              ip_addr = six.text_type(ip_net.network_address)
                      Severity: Major
                      Found in salt/utils/dns.py - About 45 mins to fix

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

                        def camel_to_snake_case(camel_input):
                            '''
                            Converts camelCase (or CamelCase) to snake_case.
                            From https://codereview.stackexchange.com/questions/185966/functions-to-convert-camelcase-strings-to-snake-case
                        
                        
                        Severity: Minor
                        Found in salt/utils/stringutils.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 extend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def extend(self, *state_funcs):
                                if self.options.ordered or self.last_func():
                                    raise PyDslError(
                                        'Cannot extend() after the ordered option was turned on!'
                                    )
                        Severity: Minor
                        Found in salt/utils/pydsl.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 mod_ == st['state'] and fstate == st['__id__']:
                                                ofresult = rstate.get('result', _empty)
                                                if ofresult in [False, True]:
                                                    nret = ofresult
                                                if ofresult is False:
                        Severity: Major
                        Found in salt/utils/state.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              for tag in tags:
                                                  if fnmatch.fnmatch(event['tag'], tag):
                                                      found_match = True
                                              publish = found_match
                          Severity: Major
                          Found in salt/engines/http_logstash.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                        if '' == suffix:
                                                            continue  # Next suffix (__init__ must have a suffix)
                                                        init_file = '__init__{0}'.format(suffix)
                            Severity: Major
                            Found in salt/loader.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language