sferik/rails_admin

View on GitHub

Showing 72 of 107 total issues

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

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

          def initialize(objects = [], schema = nil)
            @fields = []
            @associations = []
            schema ||= {}
      
      
      Severity: Minor
      Found in lib/rails_admin/support/csv_converter.rb - About 1 hr to fix

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

            def install
              if File.read(File.join(destination_root, 'config/routes.rb')).include?('mount RailsAdmin::Engine')
                display "Skipped route addition, since it's already there"
              else
                namespace = ask_for('Where do you want to mount rails_admin?', 'admin', _namespace)
        Severity: Minor
        Found in lib/generators/rails_admin/install_generator.rb - About 1 hr to fix

          Method listing_for_model_or_object has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
          Severity: Major
          Found in lib/rails_admin/extensions/paper_trail/auditing_adapter.rb - About 1 hr to fix

            Method listing_for_object has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
            Severity: Major
            Found in lib/rails_admin/extensions/paper_trail/auditing_adapter.rb - About 1 hr to fix

              Method _fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def _fields(readonly = false)
                      return @_fields if @_fields
                      return @_ro_fields if readonly && @_ro_fields
              
                      if instance_of?(RailsAdmin::Config::Sections::Base)
              Severity: Minor
              Found in lib/rails_admin/config/has_fields.rb - About 55 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 get_collection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_collection(model_config, scope, pagination)
                    section = @action.key == :export ? model_config.export : model_config.list
                    eager_loads = section.fields.flat_map(&:eager_load_values)
                    options = {}
                    options = options.merge(page: (params[Kaminari.config.param_name] || 1).to_i, per: (params[:per] || model_config.list.items_per_page)) if pagination
              Severity: Minor
              Found in app/controllers/rails_admin/main_controller.rb - About 55 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 breadcrumb has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def breadcrumb(action = @action, _acc = [])
                    begin
                      (parent_actions ||= []) << action
                    end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent)) # rubocop:disable Lint/Loop
              
              
              Severity: Minor
              Found in app/helpers/rails_admin/application_helper.rb - About 55 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 all has a Cognitive Complexity of 9 (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 = bulk_scope(scope, options) if options[:bulk_ids]
              Severity: Minor
              Found in lib/rails_admin/adapters/active_record.rb - About 55 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_input has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def parse_input(params)
                        return unless associated_model_config.abstract_model.primary_key.is_a?(Array)
              
                        if nested_form
                          params[method_name].each_value do |value|
              Severity: Minor
              Found in lib/rails_admin/config/fields/collection_association.rb - About 55 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 fieldset_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def fieldset_for(fieldset, nested_in)
                    fields = fieldset.with(
                      form: self,
                      object: @object,
                      view: @template,
              Severity: Minor
              Found in app/helpers/rails_admin/form_builder.rb - About 55 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 listing_for_model has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
              Severity: Major
              Found in lib/rails_admin/extensions/paper_trail/auditing_adapter.rb - About 50 mins to fix

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

                    def sanitize_params_for!(action, model_config = @model_config, target_params = params[@abstract_model.param_key])
                      return unless target_params.present?
                
                      fields = visible_fields(action, model_config)
                      allowed_methods = fields.collect(&:allowed_methods).flatten.uniq.collect(&:to_s) << 'id' << '_destroy'
                Severity: Minor
                Found in app/controllers/rails_admin/main_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 sort_by has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def sort_by(options, scope)
                        return scope unless options[:sort]
                
                        case options[:sort]
                        when String
                Severity: Minor
                Found in lib/rails_admin/adapters/mongoid.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def initialize(objects = [], schema = nil)
                      @fields = []
                      @associations = []
                      schema ||= {}
                
                
                Severity: Minor
                Found in lib/rails_admin/support/csv_converter.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 included has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.included(klass)
                        # Register accessors for all the sections in this namespace
                        constants.each do |name|
                          section = RailsAdmin::Config::Sections.const_get(name)
                          name = name.to_s.underscore.to_sym
                Severity: Minor
                Found in lib/rails_admin/config/sections.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def initialize(column, type, value, operator, adapter_name)
                Severity: Minor
                Found in lib/rails_admin/adapters/active_record.rb - About 35 mins to fix

                  Method resource_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def resource_url(thumb = false)
                              return nil unless value
                  
                              if thumb && value.representable?
                                thumb = thumb_method if thumb == true
                  Severity: Minor
                  Found in lib/rails_admin/config/fields/types/active_storage.rb - About 35 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