theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Method update_multiple_parameters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update_multiple_parameters
    if params[:name].empty?
      warning _("No parameters were allocated to the selected hosts, can't mass assign")
      redirect_to hosts_path
      return
Severity: Minor
Found in app/controllers/hosts_controller.rb - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

          if (
            fileExtension === '.js' &&
            !dirent.name.endsWith('.test.js') &&
            !dirent.name.endsWith('.fixtures.js') &&
            !dirent.name.endsWith('mockRequests.js') &&
    Severity: Major
    Found in webpack/assets/javascripts/exportAll.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

            if !old.build? || (old.medium != medium || old.arch != arch) ||
                (os && old.os && (old.os.name != os.name || old.os != os))
              return true
            end
      Severity: Major
      Found in app/models/concerns/orchestration/dhcp.rb - About 1 hr to fix

        Function SettingForm has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        const SettingForm = ({
          setting,
          initialValues,
          setModalClosed,
          submitForm,

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

          def self.expire(conditions, batch_size, sleep_time)
            timerange = conditions[:timerange] || 1.week
            status = conditions[:status]
            created = (Time.now.utc - timerange).to_formatted_s(:db)
            logger.info "Starting #{to_s.underscore.humanize.pluralize} expiration before #{created} status #{status || 'not set'} batch size #{batch_size} sleep #{sleep_time}"
        Severity: Minor
        Found in app/models/report.rb - About 55 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 preallocate_and_clone_disks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def preallocate_and_clone_disks(args, template)
              volumes_to_change = args[:volumes_attributes].values.select { |x| x[:id].present? }
              return unless volumes_to_change.present?
        
              template_disks = template.volumes
        Severity: Minor
        Found in app/models/compute_resources/foreman/model/ovirt.rb - About 55 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 queue_puppetca_update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def queue_puppetca_update
            if old.build? && !build?
              # Host has been built --> remove auto sign
              queue_puppetca_autosign_destroy
            elsif !old.build? && build?
        Severity: Minor
        Found in app/models/concerns/orchestration/puppet_ca.rb - About 55 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 validate_compute_provisioning has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def validate_compute_provisioning
            return true if compute_attributes.nil?
            if image_build?
              return true if (compute_attributes[:image_id] || compute_attributes[:image_ref]).blank?
              img = find_image
        Severity: Minor
        Found in app/models/concerns/orchestration/compute.rb - About 55 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 getSelectionController has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getSelectionController = ({
          tableID,
          allRowsSelected,
          rows,
          selectedRows,

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

          def self.spawn_if_missing(world)
            return if (Foreman.in_rake? && !Foreman.in_rake?('dynflow:executor')) || Rails.env.test?
        
            # While in scheduled and planning, the execution plan still doesn't have its label set, but it could have
            # a delayed plan record, which should contain the data we need to match
        Severity: Minor
        Found in app/jobs/application_job.rb - About 55 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 check_permissions_after_save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_permissions_after_save
            return true if Thread.current[:ignore_permission_check]
        
            authorizer = Authorizer.new(User.current)
            creation = saved_change_to_id?
        Severity: Minor
        Found in app/models/concerns/authorizable.rb - About 55 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_available_operating_systems has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_available_operating_systems
              return false if errors.any?
              ovirt_operating_systems = client.operating_systems if client.respond_to?(:operating_systems)
        
              attrs[:available_operating_systems] = ovirt_operating_systems.map do |os|
        Severity: Minor
        Found in app/models/compute_resources/foreman/model/ovirt.rb - About 55 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 selectionReducer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const selectionReducer = currentTableID => (
          state = initialState,
          { tableID, type, payload }
        ) => {
          if (tableID === undefined || tableID !== currentTableID) return state;

        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 dirty_has_many_associations has a Cognitive Complexity of 9 (exceeds 5 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 55 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 BreadcrumbSwitcher has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        const BreadcrumbSwitcher = ({
          isOpen,
          isLoading,
          hasError,
          items,

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

              def push(obj, options = {})
                parent = options[:parent] || @parent
        
                target_root = (parent && (subtree = find(parent))) ? subtree : @menu_items.root
        
        
        Severity: Minor
        Found in app/registries/menu/manager.rb - About 55 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 try_to_auto_create_user has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.try_to_auto_create_user(login, password)
            return if login.blank? || password.blank?
            # User is not yet registered, try to authenticate with available sources
            logger.debug "Attempting to log into an auth source as #{login} for account auto-creation"
            return unless (attrs = AuthSource.authenticate(login, password))
        Severity: Minor
        Found in app/models/user.rb - About 55 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 normalize_vm_attrs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def normalize_vm_attrs(vm_attrs)
              normalized = slice_vm_attributes(vm_attrs, ['cpus', 'firmware', 'guest_id', 'annotation', 'resource_pool_id', 'image_id'])
        
              normalized['cores_per_socket'] = vm_attrs['corespersocket']
              normalized['memory'] = vm_attrs['memory_mb'].nil? ? nil : (vm_attrs['memory_mb'].to_i * 1024)
        Severity: Minor
        Found in app/models/compute_resources/foreman/model/vmware.rb - About 55 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 editing_self? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def editing_self?(options = {})
            options[:controller].to_s == 'users' &&
              options[:action] =~ /edit|update/ &&
              options[:id].to_i == id ||
            options[:controller].to_s =~ /\Aapi\/v\d+\/users\Z/ &&
        Severity: Minor
        Found in app/models/user.rb - About 55 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 get_interface_by_flag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_interface_by_flag(flag)
              if new_record?
                interfaces.detect(&flag)
              else
                cache = "@#{flag}_interface"
        Severity: Minor
        Found in app/models/host/base.rb - About 55 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