theforeman/foreman

View on GitHub

Showing 719 of 1,266 total issues

Method domain_selected has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def domain_selected
    respond_to do |format|
      format.html { assign_parameter "domain", "common/" }
      format.json do
        taxonomy_scope
Severity: Minor
Found in app/controllers/concerns/foreman/controller/host_details.rb - About 25 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 submit_multiple_build has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def submit_multiple_build
    reboot = params[:host][:build] == '1' || false
    @hosts.each { |host| forward_url_options(host) }
    missed_hosts = BulkHostsManager.new(hosts: @hosts).build(reboot: reboot)

Severity: Minor
Found in app/controllers/hosts_controller.rb - About 25 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 refresh_host has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def refresh_host
    @host = Host::Base.authorized(:view_hosts, Host).find_by_id(params[:host_id] || params.dig(:host, :id))
    @host ||= Host.new(host_params)

    unless @host.is_a?(Host::Managed)
Severity: Minor
Found in app/controllers/hosts_controller.rb - About 25 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 add_label has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def add_label(options, f, attr)
    return ''.html_safe if options[:label] == :none

    label_size = options.delete(:label_size) || "col-md-2"
    required_mark = check_required(options, f, attr)
Severity: Minor
Found in app/helpers/form_helper.rb - About 25 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 permitted_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def permitted_actions(template)
    actions = [
      display_link_if_authorized(_('Clone'), template_hash_for_member(template, 'clone_template')),
      display_link_if_authorized(_('Export'), template_hash_for_member(template, 'export'), { :data => { :no_turbolink => true } }),
    ]
Severity: Minor
Found in app/helpers/provisioning_templates_helper.rb - About 25 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 expire_logs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def expire_logs
    from = (params[:from].to_i rescue 0) || 0
    if from >= 0
      logger.debug "Expired smart-proxy logs, new timestamp is #{from}"
      @smart_proxy.expired_logs = from.to_s
Severity: Minor
Found in app/controllers/smart_proxies_controller.rb - About 25 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 host_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def host_attributes(params, host = nil)
        return {} if params.nil?

        params = params.deep_clone
        if params[:interfaces_attributes]
Severity: Minor
Found in app/controllers/api/v2/hosts_controller.rb - About 25 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 find_owner_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def find_owner_class(key, change, audit)
    type = nil
    if audit.audited_changes.has_key?('owner_type')
      type = audit.audited_changes['owner_type']
      if audit.action == 'update'
Severity: Minor
Found in app/helpers/audits_helper.rb - About 25 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 process_taxonomy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def process_taxonomy
    return head(:not_found) unless @location || @organization
    refresh_host
    # revert compute resource to "Bare Metal" (nil) if selected
    # compute resource is not included taxonomy
Severity: Minor
Found in app/controllers/hosts_controller.rb - About 25 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 suggest_ip has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def suggest_ip
      iterations = 0
      loop do
        # next random IP from the sequence generated by MAC seed
        candidate = random_ip
Severity: Minor
Found in app/services/ipam/random_db.rb - About 25 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 detect_host_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def detect_host_type
        return Host::Managed if params[:type].blank?
        if params[:type].constantize.new.is_a?(Host::Base)
          logger.debug "Creating host of type: #{params[:type]}"
          params[:type].constantize
Severity: Minor
Found in app/controllers/api/v2/hosts_controller.rb - About 25 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 import_missing_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def import_missing_ids
    missing_ids.each do |row|
      # no object for table locations_organizations, so use method *_ids = [array id's] to create relationship
      if %w[Location Organization].include?(row[:taxable_type])
        if (tax = Taxonomy.find_by_id(row[:taxonomy_id]))
Severity: Minor
Found in app/services/tax_host.rb - About 25 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 inherited_by_default? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def inherited_by_default?(field, host)
    return false unless host.hostgroup && host.hostgroup_id_was.nil?
    return false if params[:action] == 'clone'
    return true unless params[:host]
    !params[:host][field]
Severity: Minor
Found in app/helpers/hosts_helper.rb - About 25 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 create_report_and_logs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create_report_and_logs
    super
    return report unless report.persisted?
    # we update our host record, so we won't need to lookup the report information just to display the host list / info
    host.update_attribute(:last_report, time) if host.last_report.nil? || host.last_report.utc < time
Severity: Minor
Found in app/services/config_report_importer.rb - About 25 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 find_associated_records_using_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def find_associated_records_using_key(key, change, audit)
    auditable_class = find_auditable_type_class(audit)
    association_class = if key == 'owner_id'
                          find_owner_class(key, change, audit)
                        else
Severity: Minor
Found in app/helpers/audits_helper.rb - About 25 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 multiple_actions_select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def multiple_actions_select
    select_action_button(_("Select Action"), {:id => 'submit_multiple'},
      multiple_actions.map do |action|
        # If the action array has 3 entries, the third one is whether to use a modal dialog or not
        modal = (action.size == 3) ? action[3] : true
Severity: Minor
Found in app/helpers/hosts_helper.rb - About 25 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 select_nic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def select_nic(fog_nics, nic)
        nic_attrs = nic.compute_attributes
        all_networks = service.list_networks(datacenter: datacenter)
        vm_network = all_networks.detect { |network| nic_attrs['network'] && [network[:name], network[:id]].compact.include?(nic_attrs['network']) }
        vm_network ||= all_networks.detect { |network| network[:_ref] == nic_attrs['network'] }
Severity: Minor
Found in lib/fog_extensions/vsphere/server.rb - About 25 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 load_variables_base has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def load_variables_base
            @medium_provider = Foreman::Plugin.medium_providers_registry.find_provider(host) if host
            if operatingsystem&.respond_to?(:pxe_type)
              send "#{operatingsystem.pxe_type}_attributes"
              pxe_config
Severity: Minor
Found in app/services/foreman/renderer/scope/variables/base.rb - About 25 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_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def foreman_url(action, params = {}, unescaped_params = {})
      options = foreman_url_options
      config = options[:config]
      host = options[:host]
      url_options = options[:url_options]
Severity: Minor
Found in app/services/foreman/foreman_url_renderer.rb - About 25 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_url_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def foreman_url_options
      # Get basic stuff
      config = URI.parse(Setting[:unattended_url])
      url_options = foreman_url_options_from_settings_or_request(config)

Severity: Minor
Found in app/services/foreman/foreman_url_renderer.rb - About 25 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