saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    for p_name in current_policy[policy_data['output_section']]:
                        if policy_name.lower() == p_name.lower():
                            currently_set = True
                            pol_id = p_name
                            break
Severity: Major
Found in salt/states/win_lgpo.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if not r:
                            ret['comment'] = 'No EC2 instance with tag {} == {} found'.format(tag_name,
                                    tag_value)
                            log.error(ret['comment'])
                            ret['result'] = False
    Severity: Major
    Found in salt/states/boto3_route53.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/grafana4_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 disconnected:
                                      # We succeeded in disconnecting but failed
                                      # to reconnect. This can happen if the
                                      # network's subnet has changed and we try
                                      # to reconnect with the same IP address
      Severity: Major
      Found in salt/states/docker_container.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if not policies_are_equal:
                                additional_policy_comments = []
                                if policy_data['policy_lookup'][policy_name]['rights_assignment'] and cumulative_rights_assignments:
                                    for user in policy_data['requested_policy'][policy_name]:
                                        if user not in current_policy[policy_data['output_section']][pol_id]:
        Severity: Major
        Found in salt/states/win_lgpo.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if res:
                                  log.debug('Found %s %s for instance %s', instance_attr, res, instance.id)
                                  fixed_rrs += [__salt__['boto3_route53.aws_encode'](res)]
                              else:
                                  ret['comment'] = 'Attribute {} not found on instance {}'.format(instance_attr,
          Severity: Major
          Found in salt/states/boto3_route53.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                for col, val in six.iteritems(res):
                                    output_file.write(
                                        salt.utils.stringutils.to_str(
                                            col + ':' + val + '\n'
                                        )
            Severity: Major
            Found in salt/states/mysql_query.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/grafana4_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 tid is not None and tid in removes:
                                      ix = removes.index(tid)
                                      removes.pop(ix)
                              r = __salt__['boto_cloudwatch_event.put_targets'](Rule=Name,
              Severity: Major
              Found in salt/states/boto_cloudwatch_event.py - About 45 mins to fix

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

                def absent(name, **client_args):
                    '''
                    Ensure that given user is absent.
                
                    name
                Severity: Minor
                Found in salt/states/influxdb_user.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 send_msg has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def send_msg(name,
                             recipient,
                             subject,
                             sender=None,
                             profile=None,
                Severity: Minor
                Found in salt/states/smtp.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 trim_output:
                                                files = files[:trim_output]
                                    except tarfile.ReadError:
                Severity: Major
                Found in salt/states/archive.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if internal and (current_type != ['internal']):
                                          ret['comment'] = comments['comment_port_internal']
                                      else:
                                          ret['comment'] = comments['comment_port_exists']
                                  else:
                  Severity: Major
                  Found in salt/states/openvswitch_port.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if port_add:
                                            ret['result'] = True
                                            ret['comment'] = comments['comment_port_internal']
                                            ret['changes'] = comments['changes_port_internal']
                                        else:
                    Severity: Major
                    Found in salt/states/openvswitch_port.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if created_destdir:
                                                      _cleanup_destdir(name)
                                                  ret['result'] = False
                      Severity: Major
                      Found in salt/states/archive.py - About 45 mins to fix

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

                        def monitor(name):
                            '''
                            Get the summary from module monit and try to see if service is
                            being monitored. If not then monitor 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

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

                        def mode(name):
                            '''
                            Verifies the mode SELinux is running in, can be set to enforcing,
                            permissive, or disabled
                        
                        
                        Severity: Minor
                        Found in salt/states/selinux.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 six.text_type(original_top_level_opts[option]) == six.text_type(options[option]):
                                                    ret['comment'] += 'Unchanged key {0}.\n'.format(option)
                                                else:
                                                    ret['comment'] += 'Changed key {0}.\n'.format(option)
                                                    ret['result'] = None
                        Severity: Major
                        Found in salt/states/ini_manage.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

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

                            Avoid deeply nested control flow statements.
                            Open

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