sferik/rails_admin

View on GitHub

Showing 107 of 107 total issues

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

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

                    this.down.click(function (e) {
                      widget._move("down", $(":selected", widget.selection));
                      e.preventDefault();
                    });
            Severity: Minor
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 50 mins to fix
            src/rails_admin/filtering-multiselect.js on lines 185..188

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

            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

                    this.up.click(function (e) {
                      widget._move("up", $(":selected", widget.selection));
                      e.preventDefault();
                    });
            Severity: Minor
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 50 mins to fix
            src/rails_admin/filtering-multiselect.js on lines 191..194

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

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

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

                  if ($(this).has("i.fa-chevron-right").length) {
                    $(this).siblings(".control-group:hidden").show("slow");
                    $(this).children("i").toggleClass("fa-chevron-down fa-chevron-right");
                  }
            Severity: Minor
            Found in src/rails_admin/ui.js and 1 other location - About 45 mins to fix
            src/rails_admin/ui.js on lines 59..67

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

            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

                  def authorize_with(*args, &block)
                    extension = args.shift
                    if extension
                      klass = RailsAdmin::AUTHORIZATION_ADAPTERS[extension]
                      klass.setup if klass.respond_to? :setup
            Severity: Minor
            Found in lib/rails_admin/config.rb and 1 other location - About 45 mins to fix
            lib/rails_admin/config.rb on lines 120..132

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

            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

                  def audit_with(*args, &block)
                    extension = args.shift
                    if extension
                      klass = RailsAdmin::AUDITING_ADAPTERS[extension]
                      klass.setup if klass.respond_to? :setup
            Severity: Minor
            Found in lib/rails_admin/config.rb and 1 other location - About 45 mins to fix
            lib/rails_admin/config.rb on lines 157..169

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

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

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

                if ($(this).has("i.fa-chevron-down").length) {
                  $(this).siblings(".control-group:visible").hide("slow");
                  $(this).children("i").toggleClass("fa-chevron-down fa-chevron-right");
                } else {
                  if ($(this).has("i.fa-chevron-right").length) {
            Severity: Minor
            Found in src/rails_admin/ui.js and 1 other location - About 45 mins to fix
            src/rails_admin/ui.js on lines 63..66

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

            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

            Severity
            Category
            Status
            Source
            Language