saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if capabilities_differ.diffs:
                            str_changes.append('  capabilities:')
                            str_changes.extend(
                                ['  {0}'.format(change) for change in
                                 capabilities_differ.changes_str2.split('\n')])
Severity: Major
Found in salt/states/pbm.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if dvs[infra_prop][idx] != \
                               current_dvs[infra_prop][idx]:
    
                                original_infra_res_pools.append(
                                    current_dvs[infra_prop][idx])
    Severity: Major
    Found in salt/states/dvs.py - About 45 mins to fix

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

      def _configure(changes):
      
          '''
          Calls the configuration template to apply the configuration changes on the device.
          '''
      Severity: Minor
      Found in salt/states/netsnmp.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 len(found) < len(minions):
                                  fail = sorted(list(minions.difference(found)))
                                  for minion in fail:
                                      ret[minion] = {
                                          'out': 'no_return',
      Severity: Major
      Found in salt/client/__init__.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    while True:
                                        ret = que.get(False)
                                        if 'id' in ret:
                                            returned.add(ret['id'])
                                            yield {ret['id']: ret['ret']}
        Severity: Major
        Found in salt/client/ssh/__init__.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not os.path.exists(os.path.join(self.opts['syndic_dir'], id_)):
                                      yield {
                                          id_: {
                                              'out': 'no_return',
                                              'ret': 'Minion did not return. [No response]'
          Severity: Major
          Found in salt/client/__init__.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if hostname in [host_id, roster_data.get('host')]:
                                        if hostname != self.opts['tgt']:
                                            self.opts['tgt'] = hostname
                                        self.__parsed_rosters[self.ROSTER_UPDATE_FLAG] = False
                                        return
            Severity: Major
            Found in salt/client/ssh/__init__.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if subprofile_differ.diffs:
                                          str_changes.extend(
                                              ['  {0}'.format(change) for change in
                                               subprofile_differ.changes_str.split('\n')])
                                      if capabilities_differ.diffs:
              Severity: Major
              Found in salt/states/pbm.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not os.path.isdir(tgt_dir):
                                        os.makedirs(tgt_dir)
                                    shutil.copy(path, tgt)
                Severity: Major
                Found in salt/client/ssh/state.py - About 45 mins to fix

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

                      def format_logstash_v1(self, record):
                          '''
                          Messages are formatted in logstash's expected format.
                          '''
                          message_dict = {
                  Severity: Minor
                  Found in salt/log/handlers/fluent_mod.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 handleError has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def handleError(self, record):
                          '''
                          Override the default error handling mechanism
                  
                          Deal with log file rotation errors due to log file in use
                  Severity: Minor
                  Found in salt/log/handlers/__init__.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 params['retcode'] == retcode:
                                              continue
                  
                  
                  Severity: Major
                  Found in salt/utils/decorators/__init__.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if fn_.endswith(('.py', '.so', '.pyx')):
                                            full = salt.utils.url.create(fn_)
                                            mod_path = fsclient.cache_file(full, env)
                                            if not os.path.isfile(mod_path):
                                                continue
                    Severity: Major
                    Found in salt/client/ssh/__init__.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if params['nonzero_retcode']:
                                                  if retcode != 0:
                                                      continue
                                              else:
                                                  if retcode == 0:
                      Severity: Major
                      Found in salt/utils/decorators/__init__.py - About 45 mins to fix

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

                            def _master_tops(self):
                                '''
                                Evaluate master_tops locally
                                '''
                                if 'id' not in self.opts:
                        Severity: Minor
                        Found in salt/client/ssh/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

                                                    if self.options.args_separator in arg:
                                                        sub_args = arg.split(self.options.args_separator)
                                                        for sub_arg_index, sub_arg in enumerate(sub_args):
                                                            if sub_arg:
                                                                self.config['arg'][cmd_index].append(sub_arg)
                        Severity: Major
                        Found in salt/utils/parsers.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if arg == self.options.args_separator:
                                                          cmd_index += 1
                                                          self.config['arg'].append([])
                                                      else:
                                                          self.config['arg'][cmd_index].append(arg)
                          Severity: Major
                          Found in salt/utils/parsers.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if isinstance(i, dict):
                                                    expand_variables(i, b, expanded, path + [str(k)])
                                                if isinstance(i, six.string_types):
                            Severity: Major
                            Found in salt/utils/saltclass.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  for filename in files:
                                                      fn = filename[len(file_client.get_cachedir(cache_dest)):].strip('/')
                                                      tgt = os.path.join(
                                                              env_root,
                                                              short,
                              Severity: Major
                              Found in salt/client/ssh/state.py - About 45 mins to fix

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

                                    def format_v0(self, record):
                                        host = salt.utils.network.get_fqhostname()
                                        message_dict = {
                                            '@timestamp': self.formatTime(record),
                                            '@fields': {
                                Severity: Minor
                                Found in salt/log/handlers/logstash_mod.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