sferik/rails_admin

View on GitHub

Showing 70 of 103 total issues

File widgets.js has 506 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import jQuery from "jquery";
import "jquery-ui/ui/widgets/sortable.js";
import * as bootstrap from "bootstrap";
import flatpickr from "flatpickr";
import I18n from "./i18n";
Severity: Major
Found in src/rails_admin/widgets.js - About 1 day to fix

    Function append has 190 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        append: function (options) {
          var field_label = options["label"];
          var field_name = options["name"];
          var field_type = options["type"];
          var field_value = options["value"] || "";
    Severity: Major
    Found in src/rails_admin/filter-box.js - About 7 hrs to fix

      Method menu_for has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          def menu_for(parent, abstract_model = nil, object = nil, only_icon = false)
            actions = actions(parent, abstract_model, object).select { |a| a.http_methods.include?(:get) && a.show_in_menu }
            actions.collect do |action|
              wording = wording_for(:menu, action)
              li_class = ['nav-item', 'icon', "#{action.key}_#{parent}_link"].
      Severity: Minor
      Found in app/helpers/rails_admin/application_helper.rb - About 4 hrs 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

      File filter-box.js has 340 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import jQuery from "jquery";
      import I18n from "./i18n";
      import flatpickr from "flatpickr";
      
      (function ($) {
      Severity: Minor
      Found in src/rails_admin/filter-box.js - About 4 hrs to fix

        File filtering-multiselect.js has 332 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import jQuery from "jquery";
        import "jquery-ui/ui/widget.js";
        import I18n from "./i18n";
        
        (function ($) {
        Severity: Minor
        Found in src/rails_admin/filtering-multiselect.js - About 4 hrs to fix

          Function build_operator has 91 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              build_operator: function (operator, options) {
                if (operator instanceof Object) {
                  var element = $("<option></option>");
                  element.text(operator.label);
                  delete operator.label;
          Severity: Major
          Found in src/rails_admin/filter-box.js - About 3 hrs to fix

            Function _build has 90 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _build: function () {
                  var i;
            
                  this.wrapper = this.element.siblings(
                    '.ra-multiselect[data-input-for="' + this.element.attr("id") + '"]'
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js - About 3 hrs to fix

              Method build_statement_for_integer_decimal_or_float has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                    def build_statement_for_integer_decimal_or_float
                      case @value
                      when Array
                        val, range_begin, range_end = *@value.collect do |v|
                          next unless v.to_i.to_s == v || v.to_f.to_s == v
              Severity: Minor
              Found in lib/rails_admin/abstract_model.rb - About 3 hrs 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

              File base.rb has 288 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'rails_admin/config/proxyable'
              require 'rails_admin/config/configurable'
              require 'rails_admin/config/hideable'
              require 'rails_admin/config/groupable'
              require 'rails_admin/config/inspectable'
              Severity: Minor
              Found in lib/rails_admin/config/fields/base.rb - About 2 hrs to fix

                Function _bindFormEvents has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _bindFormEvents: function () {
                      var widget = this,
                        dialog = this._getModal(),
                        form = dialog.find("form"),
                        saveButtonText = dialog.find(":submit[name=_save]").html(),
                Severity: Major
                Found in src/rails_admin/remote-form.js - About 2 hrs to fix

                  File active_record.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'active_record'
                  require 'rails_admin/adapters/active_record/association'
                  require 'rails_admin/adapters/active_record/object_extension'
                  require 'rails_admin/adapters/active_record/property'
                  
                  
                  Severity: Minor
                  Found in lib/rails_admin/adapters/active_record.rb - About 2 hrs to fix

                    Method all has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def all(options = {}, scope = nil)
                            scope ||= scoped
                            scope = scope.includes(*options[:include]) if options[:include]
                            scope = scope.limit(options[:limit]) if options[:limit]
                            scope = scope.any_in(_id: options[:bulk_ids]) if options[:bulk_ids]
                    Severity: Minor
                    Found in lib/rails_admin/adapters/mongoid.rb - About 2 hrs 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

                    Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                          class Base # rubocop:disable Metrics/ClassLength
                            include RailsAdmin::Config::Proxyable
                            include RailsAdmin::Config::Configurable
                            include RailsAdmin::Config::Hideable
                            include RailsAdmin::Config::Groupable
                    Severity: Minor
                    Found in lib/rails_admin/config/fields/base.rb - About 2 hrs to fix

                      Class Association has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                            class Association
                              attr_reader :association, :model
                      
                              delegate :autosave?, to: :association
                      
                      
                      Severity: Minor
                      Found in lib/rails_admin/adapters/mongoid/association.rb - About 2 hrs to fix

                        Function _initAutocomplete has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            _initAutocomplete: function () {
                              var self = this;
                        
                              return this.input.autocomplete({
                                delay: this.options.searchDelay,
                        Severity: Major
                        Found in src/rails_admin/filtering-select.js - About 2 hrs to fix

                          File filtering-select.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import jQuery from "jquery";
                          import "jquery-ui/ui/widget.js";
                          import "jquery-ui/ui/widgets/autocomplete.js";
                          import I18n from "./i18n";
                          
                          
                          Severity: Minor
                          Found in src/rails_admin/filtering-select.js - About 2 hrs to fix

                            File mongoid.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            require 'mongoid'
                            require 'rails_admin/config/sections/list'
                            require 'rails_admin/adapters/mongoid/association'
                            require 'rails_admin/adapters/mongoid/object_extension'
                            require 'rails_admin/adapters/mongoid/property'
                            Severity: Minor
                            Found in lib/rails_admin/adapters/mongoid.rb - About 2 hrs to fix

                              Method new has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def new(m)
                                      m = m.constantize unless m.is_a?(Class)
                                      (am = old_new(m)).model && am.adapter ? am : nil
                                    rescue *([LoadError, NameError] + (defined?(ActiveRecord) ? ['ActiveRecord::NoDatabaseError'.constantize, 'ActiveRecord::ConnectionNotEstablished'.constantize] : []))
                                      puts "[RailsAdmin] Could not load model #{m}, assuming model is non existing. (#{$ERROR_INFO})" unless Rails.env.test?
                              Severity: Minor
                              Found in lib/rails_admin/abstract_model.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 _bindEvents has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  _bindEvents: function () {
                                    var widget = this;
                              
                                    /* Add all to selection */
                                    this.addAll.click(function (e) {
                              Severity: Minor
                              Found in src/rails_admin/filtering-multiselect.js - About 1 hr to fix

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language