saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not cur_value:
                        ret['comment'] += 'Key {0}{1} does not exist.\n'.format(key, section_name)
                        continue
                    ret['comment'] += 'Deleted key {0}{1}.\n'.format(key, section_name)
Severity: Major
Found in salt/states/ini_manage.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if to_trim:
                            msg += ' trim "{0}"'.format(list(to_trim))
                        msg += ' in make.conf'
    Severity: Major
    Found in salt/states/makeconf.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if only_reload_needed:
                              if 'service.force_reload' in __salt__ and force:
                                  func = __salt__['service.force_reload']
                                  verb = 'forcefully reload'
                              else:
      Severity: Major
      Found in salt/states/service.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if __salt__['cmd.retcode'](
                                            ['xz', '-t', cached],
                                            python_shell=False,
                                            ignore_retcode=True) == 0:
                                        # XZ-compressed data
        Severity: Major
        Found in salt/states/archive.py - About 45 mins to fix

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

          def _inherited_row(row, base_rows_from_pillar, ret):
              '''Return a row with properties from parents.'''
              base_rows = []
              for base_row_from_pillar in base_rows_from_pillar:
                  base_row = __salt__['pillar.get'](base_row_from_pillar)
          Severity: Minor
          Found in salt/states/grafana_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 value in to_append:
                                  __salt__['makeconf.append_var'](upper_name, value)
                              for value in to_trim:
          Severity: Major
          Found in salt/states/makeconf.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if six.text_type(section_body[option]) == \
                                            six.text_type(original_sections.get(section_name, {}).get(option, '#-#-')):
                                        ret['comment'] += 'Unchanged key {0}{1}.\n'.format(option, section_descr)
                                    else:
                                        ret['comment'] += 'Changed key {0}{1}.\n'.format(option, section_descr)
            Severity: Major
            Found in salt/states/ini_manage.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  for value in to_trim:
                                      __salt__['makeconf.trim_var'](upper_name, value)
                                  new_value = __salt__['makeconf.get_var'](upper_name)
              Severity: Major
              Found in salt/states/makeconf.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if opt.startswith('-'):
                                            tar_longopts.append(opt)
                                        else:
                                            if position > 0:
                                                tar_longopts.append(opt)
                Severity: Major
                Found in salt/states/archive.py - About 45 mins to fix

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

                  def unmonitor(name):
                      '''
                      Get the summary from module monit and try to see if service is
                      being monitored. If it is then stop monitoring the service.
                      '''
                  Severity: Minor
                  Found in salt/states/monit.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 isinstance(kwargs[key], bool):
                                          old = (current[switch] == '1')
                                          new = (changes[switch] == '1')
                                      else:
                                          old = current[switch]
                  Severity: Major
                  Found in salt/states/blockdev.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if exc.errno == errno.ENOENT:
                                                extraction_needed = True
                                                contents_missing = True
                                            elif exc.errno != errno.ENOTDIR:
                                                # In cases where a directory path was occupied by a
                    Severity: Major
                    Found in salt/states/archive.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if not force:
                                              ret['comment'] += (
                                                  ' To proceed with extraction, set \'force\' to '
                                                  'True. Note that this will remove these paths '
                                                  'before extracting.{0}'.format(incorrect_paths)
                      Severity: Major
                      Found in salt/states/archive.py - About 45 mins to fix

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

                        def _inherited_panel(panel, base_panels_from_pillar, ret):
                            '''Return a panel with properties from parents.'''
                            base_panels = []
                            for base_panel_from_pillar in base_panels_from_pillar:
                                base_panel = __salt__['pillar.get'](base_panel_from_pillar)
                        Severity: Minor
                        Found in salt/states/grafana_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

                                                if __opts__['test']:
                                                    ret['comment'] += 'Deleted key {0}{1}.\n'.format(key_to_remove, section_descr)
                                                    ret['result'] = None
                                                else:
                                                    __salt__['ini.remove_option'](name, section_name, key_to_remove, separator)
                        Severity: Major
                        Found in salt/states/ini_manage.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if key == 'read-write':
                                                  old = not old
                                                  new = not new
                                              changeset[key] = 'Changed from {0} to {1}'.format(old, new)
                          Severity: Major
                          Found in salt/states/blockdev.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/grafana_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

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

                            def unmasked(name, runtime=False):
                                '''
                                .. versionadded:: 2017.7.0
                            
                                .. note::
                            Severity: Minor
                            Found in salt/states/service.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 watch_item in kwargs['__reqs__']['watch']:
                                                    if __running__[_gen_tag(watch_item)]['changes']:
                                                        match_found = False
                                                        for this_reload in reload_:
                                                            for state, id_ in six.iteritems(this_reload):
                            Severity: Major
                            Found in salt/states/service.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if salt.utils.data.is_true(sanitizedkwargs[kwarg]) != \
                                                          salt.utils.data.is_true(pre[kwarg]):
                                                      break
                                              else:
                              Severity: Major
                              Found in salt/states/pkgrepo.py - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language