theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Method global_registration_vars has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def global_registration_vars
    permitted = Foreman::Plugin.all
                               .map(&:allowed_registration_vars)
                               .flatten.compact.uniq

Severity: Minor
Found in app/controllers/concerns/foreman/controller/registration.rb - About 1 hr to fix

    Function registerCoreTabs has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const registerCoreTabs = () => {
      addGlobalFill(
        TABS_SLOT_ID,
        DEFAULT_TAB,
        <OverviewTab key="host-details-overview-tab" />,

      Method dirty_has_many_associations has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def dirty_has_many_associations(*args)
            self.dirty_associations += args
      
            extension = Module.new do
              args.each do |association|
      Severity: Minor
      Found in app/models/concerns/dirty_associations.rb - About 1 hr to fix

        Method add_host_base_params_filter has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def add_host_base_params_filter(filter)
              filter.permit :capabilities,
                :comment,
                :enabled,
                :ip,
        Severity: Minor
        Found in app/controllers/concerns/foreman/controller/parameters/host_base.rb - About 1 hr to fix

          Function SearchAutocomplete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export const SearchAutocomplete = ({
            results,
            onSearchChange,
            value,
            onSearch,

          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 ActionsBar has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          const ActionsBar = ({
            hostId,
            hostFriendlyId,
            hostName,
            computeId,

          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 new has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def new(attributes = nil, &block)
                  if attributes.is_a?(Hash) && (type = attributes.with_indifferent_access.delete(:type)) && !type.empty?
                    if (klass = type.constantize) != self
                      raise "Invalid type #{type}" unless klass <= self
                      return klass.new(attributes, &block)
          Severity: Minor
          Found in app/models/concerns/foreman/sti.rb - About 1 hr 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 Slot has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          const Slot = ({
            fills,
            id,
            multi,
            children = null,
          Severity: Minor
          Found in webpack/assets/javascripts/react_app/components/common/Slot/Slot.js - About 1 hr 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 dhcp_update_required? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def dhcp_update_required?
              # IP Address / name changed, or 'rebuild' action is triggered and DHCP record on the smart proxy is not present/identical.
              return true if ((old.ip != ip) ||
                (old.hostname != hostname) ||
                provision_mac_addresses_changed? ||
          Severity: Minor
          Found in app/models/concerns/orchestration/dhcp.rb - About 1 hr 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 load_values has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def load_values(ignore_cache: false)
              # we are loading only known STIs as we load settings fairly early the first time and plugin classes might not be loaded yet.
              settings = Setting.unscoped
              settings = settings.where('updated_at >= ?', @values_loaded_at) unless ignore_cache || @values_loaded_at.nil?
              settings.each do |s|
          Severity: Minor
          Found in app/registries/setting_registry.rb - About 1 hr 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 validate_ranges has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def validate_ranges
              if from.present? || to.present?
                errors.add(:from, _("must be specified if to is defined"))   if from.blank?
                errors.add(:to,   _("must be specified if from is defined")) if to.blank?
              end
          Severity: Minor
          Found in app/models/subnet.rb - About 1 hr 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 global_registration_vars has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def global_registration_vars
              permitted = Foreman::Plugin.all
                                         .map(&:allowed_registration_vars)
                                         .flatten.compact.uniq
          
          
          Severity: Minor
          Found in app/controllers/concerns/foreman/controller/registration.rb - About 1 hr 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 require_smart_proxy_or_login has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def require_smart_proxy_or_login(features = nil)
              features = features.call if features.respond_to?(:call)
              allowed_smart_proxies = if features.blank?
                                        SmartProxy.unscoped.all
                                      else
          Severity: Minor
          Found in app/controllers/concerns/foreman/controller/smart_proxy_auth.rb - About 1 hr 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 search_path has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def search_path(type)
              if type.nil?
                ''
              else
                case type
          Severity: Minor
          Found in app/helpers/filters_helper.rb - About 1 hr 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 template_input_f has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def template_input_f(f, options = {})
              input_value = f.object
              input = input_value.template_input
          
              options.reverse_merge!(label: input.name, id: input.name, label_help: input.description.presence, required: input.required)
          Severity: Minor
          Found in app/helpers/templates_helper.rb - About 1 hr 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 report_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def report_data
                  if @plan.progress < 1
                    head :no_content
                  elsif @plan.failure?
                    errors = [{ message: _('Generating of report has been canceled') }] if @plan.result == :cancelled
          Severity: Minor
          Found in app/controllers/api/v2/report_templates_controller.rb - About 1 hr 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 compute_resource_selected has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def compute_resource_selected
              return not_found unless params[:host]
              Taxonomy.as_taxonomy @organization, @location do
                refresh_host
                compute_resource = ComputeResource.authorized(:view_compute_resources).find_by_id(@host.compute_resource_id) if @host.compute_resource_id
          Severity: Minor
          Found in app/controllers/hosts_controller.rb - About 1 hr 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 parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse(response)
                telemetry_increment_counter(:proxy_api_response_code, 1, code: response.code) if response&.code
                if response && response.code >= 200 && response.code < 300
                  response.body.present? ? JSON.parse(response.body) : true
                else
          Severity: Minor
          Found in app/services/proxy_api/resource.rb - About 1 hr 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 add_logger has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_logger(logger_name, logger_config)
                logger = ::Logging.logger[logger_name]
                if logger_config.key?(:enabled)
                  if logger_config[:enabled]
                    logger.additive = true
          Severity: Minor
          Found in lib/foreman/logging.rb - About 1 hr 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_form has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function update_form(element, options) {
            options = options || {};
            var url = $(element).data('url');
            var data = serializeForm().replace('method=patch', 'method=post');
            if (options.data) data = data + options.data;
          Severity: Minor
          Found in app/assets/javascripts/host_edit.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language