saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if line.startswith('zone_info=GMT'):
                            return 'UTC'
                    return 'localtime'
Severity: Major
Found in salt/modules/timezone.py - About 45 mins to fix

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

    def ls(path, load_path=None):  # pylint: disable=C0103
        '''
        List the direct children of a node
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/augeas_cfg.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 'UTC=' in line:
                                is_utc = line.rstrip('\n').split('=')[-1].lower()
                                if is_utc == 'yes':
                                    return 'UTC'
                                else:
    Severity: Major
    Found in salt/modules/timezone.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if match:
                                  self.data.append(('', match[0][0]))
              else:
      Severity: Major
      Found in salt/modules/lxc.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if '='.join(line[1:]).strip() != item.strip():
                                changes['edited'].append(
                                    ({line[0]: line[1:]}, {key: item}))
                                break
                    if not matched:
        Severity: Major
        Found in salt/modules/lxc.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if os.path.isfile(repo_file):
                                  msg = ('File {1} containing repo \'{0}\' has been '
                                         'removed.')
                                  try:
                                      os.remove(repo_file)
          Severity: Major
          Found in salt/modules/aptpkg.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if state not in docs:
                                    if hasattr(st_.states[fun], '__globals__'):
                                        docs[state] = st_.states[fun].__globals__['__doc__']
                                docs[fun] = st_.states[fun].__doc__
            Severity: Major
            Found in salt/modules/sysmod.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if target is None:
                                      errors.append(
                                          'No version matching \'{0}{1}\' could be found '
                                          '(available: {2})'.format(
                                              pkgname,
              Severity: Major
              Found in salt/modules/aptpkg.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if out['retcode']:
                                        raise CommandExecutionError(
                                            'Unable to add PPA \'{0}\'. \'{1}\' exited with '
                                            'status {2!s}: \'{3}\' '.format(
                                                repo[4:],
                Severity: Major
                Found in salt/modules/aptpkg.py - About 45 mins to fix

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

                  def put_website(Bucket, ErrorDocument=None, IndexDocument=None,
                             RedirectAllRequestsTo=None, RoutingRules=None,
                             region=None, key=None, keyid=None, profile=None):
                      '''
                      Given a valid config, update the website configuration for a bucket.
                  Severity: Minor
                  Found in salt/modules/boto_s3_bucket.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 _latest_version == _version:
                                          _refresh_db = True
                                  else:
                  Severity: Major
                  Found in salt/modules/aptpkg.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        for comp in repo_comps:
                                            if comp in sub.get('comps', []):
                                                return sub
                        return {}
                    Severity: Major
                    Found in salt/modules/aptpkg.py - About 45 mins to fix

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

                      def list_objects(Bucket, Delimiter=None, EncodingType=None, Prefix=None,
                                       FetchOwner=False, StartAfter=None, region=None, key=None,
                                       keyid=None, profile=None):
                          '''
                          List objects in a given S3 bucket.
                      Severity: Minor
                      Found in salt/modules/boto_s3_bucket.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 repo_comps:
                                              return sub
                                          for comp in repo_comps:
                      Severity: Major
                      Found in salt/modules/aptpkg.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if not source.comps:
                                                try:
                                                    sources.remove(source)
                                                except ValueError:
                                                    pass
                        Severity: Major
                        Found in salt/modules/aptpkg.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if comp or (not comp and isinstance(comp, list)):
                                                      diffdict.update({i: defined[i]})
                                          return diffdict
                          Severity: Major
                          Found in salt/modules/zabbix.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if candidate.lower() == '(none)':
                                                    candidate = ''
                                            break
                            Severity: Major
                            Found in salt/modules/aptpkg.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if refresh:
                                                      refresh_db()
                                                  return {repo: out}
                              Severity: Major
                              Found in salt/modules/aptpkg.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if result['retcode'] != 0:
                                                        log.error(
                                                            'failed to set state %s for package %s',
                                                            _state, _pkg
                                                        )
                                Severity: Major
                                Found in salt/modules/aptpkg.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if return_old_value:
                                                          d_in_e.append(comp['new'])
                                                      else:
                                                          d_in_e.append(comp)
                                                  if all(d_in_e):
                                  Severity: Major
                                  Found in salt/modules/zabbix.py - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language