sferik/rails_admin

View on GitHub

Showing 107 of 107 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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if (nav.children().length === 0) {
                toggler
                  .addClass("disabled")
                  .removeClass("active")
                  .children("i")
      Severity: Major
      Found in src/rails_admin/widgets.js and 1 other location - About 5 hrs to fix
      src/rails_admin/widgets.js on lines 233..246

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 141.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if (nav.children().length === 0) {
                toggler
                  .addClass("disabled")
                  .removeClass("active")
                  .children("i")
      Severity: Major
      Found in src/rails_admin/widgets.js and 1 other location - About 5 hrs to fix
      src/rails_admin/widgets.js on lines 187..200

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 141.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            content.find("[data-filteringmultiselect]").each(function () {
              $(this).filteringMultiselect($(this).data("options"));
              if ($(this).parents("#modal").length) {
                $(this).parent().siblings(".modal-actions").remove();
              } else {
      Severity: Major
      Found in src/rails_admin/widgets.js and 1 other location - About 5 hrs to fix
      src/rails_admin/widgets.js on lines 142..149

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 136.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            content.find("[data-filteringselect]").each(function () {
              $(this).filteringSelect($(this).data("options"));
              if ($(this).parents("#modal").length) {
                $(this).parent().siblings(".modal-actions").remove();
              } else {
      Severity: Major
      Found in src/rails_admin/widgets.js and 1 other location - About 5 hrs to fix
      src/rails_admin/widgets.js on lines 134..141

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 136.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              options.each(function (i, option) {
                var prev = $(option).prev();
                if (prev.length > 0) {
                  var el = widget.element.find(
                    'option[value="' + option.value + '"]'
      Severity: Major
      Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 4 hrs to fix
      src/rails_admin/filtering-multiselect.js on lines 357..369

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 134.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              options.reverse().each(function (i, option) {
                var next = $(option).next();
                if (next.length > 0) {
                  var el = widget.element.find(
                    'option[value="' + option.value + '"]'
      Severity: Major
      Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 4 hrs to fix
      src/rails_admin/filtering-multiselect.js on lines 342..354

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 134.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

              File active_record.rb has 308 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 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

                    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 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

                      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
                        Severity
                        Category
                        Status
                        Source
                        Language