theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Method multiple_checkboxes has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def multiple_checkboxes(f, attr, klass, associations, options = {}, html_options = {})
Severity: Minor
Found in app/helpers/form_helper.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                unless user.update(valid_attrs)
                  logger.warn "Failed to update #{user.login} attributes: #{user.errors.full_messages.join(', ')}"
                end
    Severity: Major
    Found in app/models/user.rb - About 45 mins to fix

      Method submit_or_cancel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def submit_or_cancel(f, overwrite = false, args = { })
          args[:cancel_path] ||= resource_path(controller_name)
          cancel_btn = args[:react_cancel_button] ? react_cancel_button(args) : link_to(_("Cancel"), args[:cancel_path], :class => "btn btn-default")
          content_tag(:div, :class => "clearfix") do
            content_tag(:div, :class => "form-actions") do
      Severity: Minor
      Found in app/helpers/form_helper.rb - 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

      Method set has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def self.set(name, description, default, full_name = nil, value = nil, options = {})
      Severity: Minor
      Found in app/models/setting.rb - About 45 mins to fix

        Method not_required_interface has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def not_required_interface
              if host&.managed? && !host.being_destroyed?
                if primary?
                  errors.add :primary, _("can't delete primary interface of managed host")
                end
        Severity: Minor
        Found in app/models/nic/base.rb - 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

        Method set_ip_address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_ip_address
            return unless new_record? || managed?
            interfaces.select { |nic| nic.managed }.each do |nic|
              nic.ip  = nic.subnet.unused_ip(mac).suggest_ip if nic.subnet.present? && nic.ip.blank?
              nic.ip6 = nic.subnet6.unused_ip(mac).suggest_ip if nic.subnet6.present? && nic.ip6.blank?
        Severity: Minor
        Found in app/models/host/managed.rb - 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

        Method smart_proxy_select_f has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def smart_proxy_select_f(f, resource, options)
            required = options.fetch(:required, false)
            hidden = options[:if].present? && !options[:if].call(f.object)
            can_override = options.fetch(:can_override, false)
            override = options.fetch(:override, false)
        Severity: Minor
        Found in app/helpers/shared_smart_proxies_helper.rb - 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

        Method store_avatar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def store_avatar(avatar)
            unless avatar.instance_of?(Net::BER::BerIdentifiedString)
              avatar = avatar.to_utf8
            end
            avatar_hash = Digest::SHA1.hexdigest(avatar)
        Severity: Minor
        Found in app/models/auth_sources/auth_source_ldap.rb - 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

        Method vm_power_actions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def vm_power_actions(host, vm)
            button_group(
              if vm
                html_opts = vm.ready? ? {:data => {:confirm => _('Are you sure?')}, :class => "btn btn-danger"} : {:class => "btn btn-success"}
                link_to_if_authorized _("Power%s") % state(vm.ready?), hash_for_power_host_path(:power_action => vm.ready? ? :stop : :start).merge(:auth_object => host, :permission => 'power_hosts'),
        Severity: Minor
        Found in app/helpers/compute_resources_vms_helper.rb - 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

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

          def update_required?(old_attrs, new_attrs)
            old_attrs.deep_symbolize_keys.merge(new_attrs.deep_symbolize_keys) do |k, old_v, new_v|
              if old_v.is_a?(Hash) && new_v.is_a?(Hash)
                return true if update_required?(old_v, new_v)
              elsif old_v.to_s != new_v.to_s
        Severity: Minor
        Found in app/models/compute_resource.rb - 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

        Method parse_ip_address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_ip_address(address, ignore_link_local: true)
              return nil unless address
        
              begin
                addr = IPAddr.new(address)
        Severity: Minor
        Found in app/models/host/base.rb - 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

        Method sti_clean_up has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def sti_clean_up(e)
            require_login rescue false
            Foreman::Logging.exception("Action failed", e) unless User.current&.admin?
            @unknown_class_name = e.message.match(/subclass: '(.*)'\./)[1]
            @parent_class = e.message.match(/overwrite (.*)\.inheritance_column/)[1].constantize
        Severity: Minor
        Found in app/controllers/application_controller.rb - 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

        Method taxonomy_selects has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def taxonomy_selects(f, selected_ids, taxonomy, label, options = {}, options_html = {})
        Severity: Minor
        Found in app/helpers/taxonomy_helper.rb - About 45 mins to fix

          Method ensure_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def ensure_hash(ambiguous_param)
                case ambiguous_param
                when String
                  if ambiguous_param.present?
                    ensure_hash(JSON.parse(ambiguous_param))
          Severity: Minor
          Found in app/controllers/api/graphql_controller.rb - 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

          Method inherit_parent_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def inherit_parent_attributes
              return unless @parent.present?
          
              @hostgroup.compute_resource_id ||= @parent.compute_resource_id
              @hostgroup.architecture        ||= @parent.architecture
          Severity: Minor
          Found in app/controllers/hostgroups_controller.rb - 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

          Method create_fact_name_link has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def create_fact_name_link(parent, current_name, host_id, value, value_name, memo)
          Severity: Minor
          Found in app/helpers/fact_values_helper.rb - About 45 mins to fix

            Method scope_by_resource_id has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def scope_by_resource_id(base_scope, resource_id)
                # If resource id is nil or empty string, return empty scope
                return base_scope.none if resource_id.blank?
            
                # First try to find the resource using friendly_find
            Severity: Minor
            Found in app/controllers/concerns/application_shared.rb - 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

            Method append_array_of_ids has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def append_array_of_ids(hash_params)
                    model_name = controller_name.singularize
                    hash_params&.dup&.each do |k, v|
                      if v.is_a?(Array)
                        association_name_ids = "#{k.singularize}_ids"
            Severity: Minor
            Found in app/controllers/api/v2/base_controller.rb - 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

            Method resource_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def resource_path(type)
                return '' if type.nil?
            
                path = type.pluralize.underscore + "_path"
                prefix, suffix = path.split('/', 2)
            Severity: Minor
            Found in app/controllers/application_controller.rb - 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

            Method alert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def alert(opts = {})
                opts[:close] = true if opts[:close].nil?
                opts[:header] ||= _("Warning!")
                opts[:text]   ||= _("Alert")
                html_class = "alert #{opts[:class]} "
            Severity: Minor
            Found in app/helpers/layout_helper.rb - 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

            Severity
            Category
            Status
            Source
            Language