saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not kwargs.get('only_upgrade', False):
                        to_downgrade.append(pkgstr)
                    else:
                        # This should cause the command to fail.
                        to_install.append(pkgstr)
Severity: Major
Found in salt/modules/opkg.py - About 45 mins to fix

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

    def list_users(order_by='id'):
        '''
        Show all users for this company.
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/bamboohr.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 name not in schedule:
                                ret['result'] = True
                                ret['comment'] = 'Deleted Job {0} from schedule.'.format(name)
                            else:
                                ret['comment'] = 'Failed to delete job {0} from schedule.'.format(name)
    Severity: Major
    Found in salt/modules/schedule.py - About 45 mins to fix

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

      def delete_distribution(region=None, key=None, keyid=None, profile=None, **kwargs):
          '''
          Delete a CloudFront distribution.
      
          Id
      Severity: Minor
      Found in salt/modules/boto_cloudfront.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 untag_resource has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def untag_resource(region=None, key=None, keyid=None, profile=None, **kwargs):
          '''
          Remove tags from a CloudFront resource.
      
          Resource
      Severity: Minor
      Found in salt/modules/boto_cloudfront.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 _prepare_connection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _prepare_connection(**kwargs):
          '''
          Prepare the connection with the remote network device, and clean up the key
          value pairs, removing the args used for the connection init.
          '''
      Severity: Minor
      Found in salt/modules/netmiko_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 get_cloud_front_origin_access_identity_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_cloud_front_origin_access_identity_config(region=None, key=None, keyid=None, profile=None,
                                                        **kwargs):
          '''
          Get config information about a CloudFront origin access identity given its Resource ID.
      
      
      Severity: Minor
      Found in salt/modules/boto_cloudfront.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 event_ret and event_ret['complete']:
                                  _schedule_ret = event_ret['schedule']
                                  if name not in _schedule_ret:
                                      ret['result'] = True
                                      ret['comment'].append('Deleted job: {0} from schedule.'.format(name))
      Severity: Major
      Found in salt/modules/schedule.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if name in schedule:
                                    ret['result'] = True
                                    ret['comment'] = 'Added job: {0} to schedule.'.format(name)
                                    return ret
                except KeyError:
        Severity: Major
        Found in salt/modules/schedule.py - About 45 mins to fix

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

          def update_distribution_v2(region=None, key=None, keyid=None, profile=None, **kwargs):
              '''
              Update a CloudFront distribution with the provided configuration details.  A LOT of fields are
              required in DistributionConfig to make up a valid update request.  Details can be found at
              __: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-overview-required-fields.html
          Severity: Minor
          Found in salt/modules/boto_cloudfront.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 update_cloud_front_origin_access_identity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def update_cloud_front_origin_access_identity(region=None, key=None, keyid=None, profile=None,
                                                        **kwargs):
              '''
              Update a CloudFront origin access identity with the provided configuration details.
          
          
          Severity: Minor
          Found in salt/modules/boto_cloudfront.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 name in schedule and not schedule[name]['enabled']:
                                      ret['result'] = True
                                      ret['comment'] = 'Disabled Job {0} in schedule.'.format(name)
                                  else:
                                      ret['result'] = False
          Severity: Major
          Found in salt/modules/schedule.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if name in schedule and schedule[name]['enabled']:
                                        ret['result'] = True
                                        ret['comment'] = 'Added Skip Job {0} in schedule.'.format(name)
                                    else:
                                        ret['result'] = False
            Severity: Major
            Found in salt/modules/schedule.py - About 45 mins to fix

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

              def blkid(device=None, token=None):
                  '''
                  Return block device attributes: UUID, LABEL, etc. This function only works
                  on systems where blkid is available.
              
              
              Severity: Minor
              Found in salt/modules/disk.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_distribution_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_distribution_config(region=None, key=None, keyid=None, profile=None, **kwargs):
                  '''
                  Get config information about a CloudFront distribution given its Resource ID.
              
                  Id
              Severity: Minor
              Found in salt/modules/boto_cloudfront.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 _cli_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def _cli_command(commands,
                               method='cli',
                               **kwargs):
                  '''
                  Execute a list of CLI commands.
              Severity: Minor
              Found in salt/modules/nxos_api.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 'enabled' in schedule and schedule['enabled']:
                                          ret['result'] = True
                                          ret['comment'] = 'Enabled schedule on minion.'
                                      else:
                                          ret['result'] = False
              Severity: Major
              Found in salt/modules/schedule.py - About 45 mins to fix

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

                def tag_resource(region=None, key=None, keyid=None, profile=None, **kwargs):
                    '''
                    Add tags to a CloudFront resource.
                
                    Resource
                Severity: Minor
                Found in salt/modules/boto_cloudfront.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 _render_cmd has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _render_cmd(cmd, cwd, template, saltenv='base', pillarenv=None, pillar_override=None):
                    '''
                    If template is a valid template engine, process the cmd and cwd through
                    that engine.
                    '''
                Severity: Minor
                Found in salt/modules/cmdmod.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_cloud_front_origin_access_identity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_cloud_front_origin_access_identity(region=None, key=None, keyid=None, profile=None,
                                                           **kwargs):
                    '''
                    Get information about a CloudFront origin access identity given its Resource ID.
                
                
                Severity: Minor
                Found in salt/modules/boto_cloudfront.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