sferik/rails_admin

View on GitHub

Showing 107 of 107 total issues

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

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

              additional_control = $(
                '<input class="additional-fieldset default form-control form-control-sm" type="text" />'
              )
                .css(
                  "display",
    Severity: Major
    Found in src/rails_admin/filter-box.js and 1 other location - About 1 hr to fix
    src/rails_admin/filter-box.js on lines 128..163

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

    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

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

      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

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

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

          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

            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

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

                      } else {
                        $(option)
                          .clone()
                          .appendTo(widget.collection)
                          .prop("selected", false)
              Severity: Major
              Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
              src/rails_admin/filtering-multiselect.js on lines 252..258

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

              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

                      if (option.selected) {
                        $(option)
                          .clone()
                          .appendTo(widget.selection)
                          .prop("selected", false)
              Severity: Major
              Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
              src/rails_admin/filtering-multiselect.js on lines 258..264

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

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

                          def add(field, value, operator)
                            field.searchable_columns.flatten.each do |column_infos|
                              statement, value1, value2 = StatementBuilder.new(column_infos[:column], column_infos[:type], value, operator, @scope.connection.adapter_name).to_statement
                              @statements << statement if statement.present?
                              @values << value1 unless value1.nil?
                  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 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

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

                          def type
                            case property.type.to_s
                            when 'Array', 'Hash', 'Money'
                              :serialized
                            when 'BigDecimal'
                  Severity: Minor
                  Found in lib/rails_admin/adapters/mongoid/property.rb - About 1 hr to fix

                    Function change has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            change: function (event, ui) {
                              if (ui.item) {
                                return;
                              }
                    
                    
                    Severity: Minor
                    Found in src/rails_admin/filtering-select.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language