theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Method available? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def available?
      return false unless Setting['authorize_login_delegation']
      return false if controller.api_request? && !(Setting['authorize_login_delegation_api'])
      return false if http_token.present?
      return false if controller.api_request? && request.env[CAS_USERNAME].blank?
Severity: Minor
Found in app/services/sso/apache.rb - About 35 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

Method boot has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def boot(args)
      # valid additional arguments args[:reboot] = true|false, args[:persistent] = true|false
      #  put "/bmc/:host/chassis/config/?:function?/?:action?" do
      case args[:function]
      when "bootdevice"
Severity: Minor
Found in app/services/proxy_api/bmc.rb - About 35 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

Method can? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def can?(permission, subject = nil, cache = true)
    return false if user.nil? || user.disabled?
    return true if user.admin?

    if subject.nil?
Severity: Minor
Found in app/services/authorizer.rb - About 35 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

Method snippet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

          def snippet(name, options = {}, variables: {})
            template = source.find_snippet(name)
            unless template
              raise "The specified snippet '#{name}' does not exist, or is not a snippet." unless options[:silent]
              return
Severity: Minor
Found in app/services/foreman/renderer/scope/macros/snippet_rendering.rb - About 35 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

Method valid_json_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def valid_json_type(cell)
          if cell.is_a?(String) || [true, false].include?(cell) || cell.is_a?(Numeric) || cell.nil?
            cell
          elsif cell.is_a?(Enumerable)
            hashify = cell.is_a?(Hash)
Severity: Minor
Found in app/services/foreman/renderer/scope/report.rb - About 35 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

Method valid_issuer? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def valid_issuer?
      logger = Foreman::Logging.logger('app')
      payload = jwt_token.decoded_payload
      if payload.nil?
        logger.error "Invalid JWT received, please check connectivity with the OpenID Provider"
Severity: Minor
Found in app/services/sso/openid_connect.rb - About 35 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

Method foreman_server_ca_cert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

          def foreman_server_ca_cert(server_ca_file_enabled: true, ssl_ca_file_enabled: true)
            setting_values = []
            setting_values << Setting[:server_ca_file] if server_ca_file_enabled
            setting_values << Setting[:ssl_ca_file] if ssl_ca_file_enabled

Severity: Minor
Found in app/services/foreman/renderer/scope/macros/base.rb - About 35 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

Method authenticate! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def authenticate!
      payload = jwt_token.decode || {}
      user_id = payload['user_id']

      unless valid_scope?(payload['scope'])
Severity: Minor
Found in app/services/sso/jwt.rb - About 35 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

Method ping_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def ping_cache
      response = {}

      if redis_cache_store?
        redis = Rails.cache.redis
Severity: Minor
Found in app/services/ping.rb - About 35 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

Method update_packages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

          def update_packages
            banner = <<~CMD
              echo '#'
              echo '# Updating packages'
              echo '#'
Severity: Minor
Found in app/services/foreman/renderer/scope/macros/host_template.rb - About 35 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

Method method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(method, *args, &block)
      if method.to_s.starts_with?('power_', 'boot_', 'identify_', 'lan_')
        margs = args.first
        farg  = method.to_s.split('_')
        # method must contain 2 parts, ie: power_on, boot_disk
Severity: Minor
Found in app/services/proxy_api/bmc.rb - About 35 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

Method update_generic_matcher has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def update_generic_matcher(lookup_values, options)
        computed_lookup_value = nil
        lookup_values.each do |lookup_value|
          element, element_name = get_element_and_element_name(lookup_value)
          next if (options[:skip_fqdn] && element == "fqdn")
Severity: Minor
Found in app/services/classification/values_hash_query.rb - About 35 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 too many return statements within this function.
Open

      return state.merge(payload);
Severity: Major
Found in webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return state
            .set('searchQuery', '')
            .set('isFetchingHosts', false)
            .set('isSearchingHosts', false);
    Severity: Major
    Found in webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return state.set('templateKindId', payload);
      Severity: Major
      Found in webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return state.set('isLoading', true);
        Severity: Major
        Found in webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return state.merge(payload);
          Severity: Major
          Found in webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return state.set('isFetchingHosts', false).merge(payload);
            Severity: Major
            Found in webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return state.merge({
                      notifications,
                      hasUnreadMessages: hasUnreadMessages(notifications),
                    });

                Avoid too many return statements within this function.
                Open

                      return state.set('selectedView', payload);
                Severity: Major
                Found in webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language