saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                            if init_file in subfiles:
                                break
                        else:
Severity: Major
Found in salt/loader.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if _get_volume(volume, array) is not None:
                            try:
                                array.set_pgroup(name, addvollist=[volume])
                                return True
                            except purestorage.PureError:
    Severity: Major
    Found in salt/modules/purefa.py - About 45 mins to fix

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

          def do_checkout(self, repo):
              '''
              Common code for git_pillar/winrepo to handle locking and checking out
              of a repo.
              '''
      Severity: Minor
      Found in salt/utils/gitfs.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 file_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def file_hash(self, load, fnd):
              '''
              Return a file hash, the hash type is set in the master config file
              '''
              if 'env' in load:
      Severity: Minor
      Found in salt/utils/gitfs.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 salt.utils.stringutils.expr_match(key, block):
                              del ret[key]
                              log.trace('Filtering %s grain', key)
                  if not ret:
      Severity: Major
      Found in salt/loader.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if temp['vol'] == volume:
                                try:
                                    array.disconnect_hgroup(name, volume)
                                    return True
                                except purestorage.PureError:
        Severity: Major
        Found in salt/modules/purefa.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if _get_hgroup(hostgroup, array) is not None:
                                  try:
                                      array.set_pgroup(name, addhgrouplist=[hostgroup])
                                      return True
                                  except purestorage.PureError:
          Severity: Major
          Found in salt/modules/purefa.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if not os.path.isfile(key_path):
                                            _key_does_not_exist(key_type, key_path)
                                    except TypeError:
            Severity: Major
            Found in salt/utils/gitfs.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if sys.getsizeof(data[key]) > max_val_size:
                                          data[key] = replace_with
                              percent = percent - stepper_size
              Severity: Major
              Found in salt/utils/dicttrim.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not event['data']['fun'] in funs:
                                        publish = False
                                if publish:
                Severity: Major
                Found in salt/engines/http_logstash.py - About 45 mins to fix

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

                      def missing_fun_string(self, function_name):
                          '''
                          Return the error string for a missing function.
                  
                          This can range from "not available' to "__virtual__" returned False
                  Severity: Minor
                  Found in salt/loader.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 saltenv == 'base':
                                              # Remove redundant 'ref' config for base saltenv
                                              repo_obj.saltenv[saltenv].pop('ref')
                                              if ref != repo_obj.base:
                                                  log.warning(
                  Severity: Major
                  Found in salt/utils/gitfs.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if salt.utils.stringutils.expr_match(key, block):
                                            del ret[key]
                                            log.trace('Filtering %s grain', key)
                                if not ret:
                    Severity: Major
                    Found in salt/loader.py - About 45 mins to fix

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

                      def volume_extend(name, size):
                          '''
                      
                          Extend an existing volume on a Pure Storage FlashArray.
                      
                      
                      Severity: Minor
                      Found in salt/modules/purefa.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 salt.utils.platform.is_windows() \
                                                                  and not ldest.startswith('\\\\') \
                                                                  and os.path.isdir(ldest):
                                                              # On Windows, symlinks to directories
                                                              # must be removed as if they were
                      Severity: Major
                      Found in salt/utils/gitfs.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if _get_host(host, array) is not None:
                                                try:
                                                    array.set_pgroup(name, addhostlist=[host])
                                                    return True
                                                except purestorage.PureError:
                        Severity: Major
                        Found in salt/modules/purefa.py - About 45 mins to fix

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

                          def start(address=None, port=5000, ssl_crt=None, ssl_key=None):
                              '''
                              Api to listen for webhooks to send to the reactor.
                          
                              Implement the webhook behavior in an engine.
                          Severity: Minor
                          Found in salt/engines/webhook.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 _trim_dict_in_dict has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def _trim_dict_in_dict(data, max_val_size, replace_with):
                              '''
                              Takes a dictionary, max_val_size and replace_with
                              and recursively loops through and replaces any values
                              that are greater than max_val_size.
                          Severity: Minor
                          Found in salt/utils/dicttrim.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 _get_sqs_conn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def _get_sqs_conn(profile, region=None, key=None, keyid=None):
                              '''
                              Get a boto connection to SQS.
                              '''
                              if profile:
                          Severity: Minor
                          Found in salt/engines/sqs_events.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 _process_queue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def _process_queue(q, q_name, fire_master, tag='salt/engine/sqs', owner_acct_id=None, message_format=None):
                              if not q:
                                  log.warning(
                                      'failure connecting to queue: %s, waiting 10 seconds.',
                                      ':'.join([_f for _f in (six.text_type(owner_acct_id), q_name) if _f])
                          Severity: Minor
                          Found in salt/engines/sqs_events.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