sferik/rails_admin

View on GitHub

Showing 72 of 107 total issues

Method ordered_filters has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def ordered_filters
      return @ordered_filters if @ordered_filters.present?

      @index = 0
      @ordered_filters = (params[:f].try(:permit!).try(:to_h) || @model_config.list.filters).inject({}) do |memo, filter|
Severity: Minor
Found in app/helpers/rails_admin/main_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 listing_for_model_or_object has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
          sort =
            if sort.present?
              {COLUMN_MAPPING[sort.to_sym] => sort_reverse ? :desc : :asc}
            else
Severity: Minor
Found in lib/rails_admin/extensions/paper_trail/auditing_adapter.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 generic_help has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

          def generic_help
            text = "#{required? ? I18n.translate('admin.form.required') : I18n.translate('admin.form.optional')}. "
            if valid_length.present? && valid_length[:is].present?
              text += "#{I18n.translate('admin.form.char_length_of').capitalize} #{valid_length[:is]}."
            else
Severity: Minor
Found in lib/rails_admin/config/fields/types/string.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 symbolize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def self.symbolize(obj)
      case obj
      when Array
        obj.each_with_object([]) do |val, res|
          res << case val
Severity: Minor
Found in lib/rails_admin/support/hash_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 field has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def field(name, type = nil, add_to_section = true, &block)
        field = _fields.detect { |f| name == f.name }

        # some fields are hidden by default (belongs_to keys, has_many associations in list views.)
        # unhide them if config specifically defines them
Severity: Minor
Found in lib/rails_admin/config/has_fields.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 register_instance_option has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def register_instance_option(option_name, scope = self, &default)
          options = scope.instance_variable_get('@config_options') ||
                    scope.instance_variable_set('@config_options', {})

          option_name = option_name.to_s
Severity: Minor
Found in lib/rails_admin/config/configurable.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 _query has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _query: function (query, success) {
      var i,
        matches = [];

      if (query === "") {
Severity: Minor
Found in src/rails_admin/filtering-multiselect.js - About 1 hr to fix

    Function _getResultSet has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _getResultSet: function (request, data, xhr) {
          var matcher = new RegExp(
            $.ui.autocomplete.escapeRegex(request.term),
            "i"
          );
    Severity: Minor
    Found in src/rails_admin/filtering-select.js - About 1 hr to fix

      Method filter_scope has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def filter_scope(scope, filters, fields = config.list.fields.select(&:filterable?))
              statements = []
      
              filters.each_pair do |field_name, filters_dump|
                filters_dump.each_value do |filter_dump|
      Severity: Minor
      Found in lib/rails_admin/adapters/mongoid.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 navigation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def navigation(parent_groups, nodes, level = 0)
            nodes.collect do |node|
              abstract_model = node.abstract_model
              model_param = abstract_model.to_param
              url         = rails_admin.url_for(action: :index, controller: 'rails_admin/main', model_name: model_param)
      Severity: Minor
      Found in app/helpers/rails_admin/application_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

      Function _create has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _create: function () {
            var widget = this;
            var dom_widget = widget.element;
      
            var edit_url =
      Severity: Minor
      Found in src/rails_admin/remote-form.js - About 1 hr to fix

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

            _getModal: function () {
              var widget = this;
              if (!widget.dialog) {
                widget.dialog = $(
                  '<div id="modal" class="modal fade">\
        Severity: Minor
        Found in src/rails_admin/remote-form.js - About 1 hr to fix

          Method field_wrapper_for has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def field_wrapper_for(field, nested_in)
                # do not show nested field if the target is the origin
                return if nested_field_association?(field, nested_in)
          
                @template.content_tag(:div, class: "control-group row mb-3 #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do
          Severity: Minor
          Found in app/helpers/rails_admin/form_builder.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 build_statement_for_string_or_text has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  def build_statement_for_string_or_text
                    return if @value.blank?
          
                    return ["(#{@column} = ?)", @value] if ['is', '='].include?(@operator)
          
          
          Severity: Minor
          Found in lib/rails_admin/adapters/active_record.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 fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def fields(*field_names, &block)
                  return all_fields if field_names.empty? && !block
          
                  if field_names.empty?
                    defined = _fields.select(&:defined)
          Severity: Minor
          Found in lib/rails_admin/config/has_fields.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 _getSourceFunction has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _getSourceFunction: function (source) {
                var self = this;
                var requestIndex = 0;
          
                if ($.isArray(source)) {
          Severity: Minor
          Found in src/rails_admin/filtering-select.js - About 1 hr to fix

            Function _move has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _move: function (direction, options) {
                  var widget = this;
                  if (direction == "up") {
                    options.each(function (i, option) {
                      var prev = $(option).prev();
            Severity: Minor
            Found in src/rails_admin/filtering-multiselect.js - About 1 hr to fix

              Method reset has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def reset
                      @compact_show_view = true
                      @browser_validations = true
                      @authenticate = nil
                      @authorize = nil
              Severity: Minor
              Found in lib/rails_admin/config.rb - About 1 hr to fix

                Function _create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _create: function () {
                      this.filtering_select = this.element.siblings(
                        '[data-input-for="' + this.element.attr("id") + '"]'
                      );
                
                
                Severity: Minor
                Found in src/rails_admin/filtering-select.js - About 1 hr to fix

                  Method extended has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def self.extended(object)
                            object.associations.each do |name, association|
                              association = Association.new(association, object.class)
                              case association.macro
                              when :has_many
                  Severity: Minor
                  Found in lib/rails_admin/adapters/mongoid/object_extension.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

                  Severity
                  Category
                  Status
                  Source
                  Language