railsadminteam/rails_admin

View on GitHub

Showing 103 of 103 total issues

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

            if (this._cache.hasOwnProperty(i)) {
              var option = this._cache[i];
              matches.push({ id: option.id, label: option.value });
            }
Severity: Minor
Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 40 mins to fix
src/rails_admin/filtering-multiselect.js on lines 308..314

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

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

module RailsAdmin
  module Config
    module Fields
      module Types
        class SimpleMDE < Text
Severity: Minor
Found in lib/rails_admin/config/fields/types/simple_mde.rb and 1 other location - About 40 mins to fix
lib/rails_admin/config/fields/types/froala.rb on lines 5..31

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

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

module RailsAdmin
  module Config
    module Fields
      module Types
        class Froala < Text
Severity: Minor
Found in lib/rails_admin/config/fields/types/froala.rb and 1 other location - About 40 mins to fix
lib/rails_admin/config/fields/types/simple_mde.rb on lines 5..32

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

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

    new_tab.children("a").each(function (index, element) {
      bootstrap.Tab.getOrCreateInstance(element).show();
    });
Severity: Minor
Found in src/rails_admin/nested-form-hooks.js and 1 other location - About 40 mins to fix
src/rails_admin/widgets.js on lines 181..185

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

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

          nav
            .find("> li > a[data-bs-toggle='tab']:first")
            .each(function (index, element) {
              bootstrap.Tab.getOrCreateInstance(element).show();
            });
Severity: Minor
Found in src/rails_admin/widgets.js and 1 other location - About 40 mins to fix
src/rails_admin/nested-form-hooks.js on lines 43..45

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

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

        def action_missing(name, *_args)
          action = RailsAdmin::Config::Actions.find(name.to_sym)
          raise AbstractController::ActionNotFound.new("The action '#{name}' could not be found for #{self.class.name}") unless action
    
          get_model unless action.root?
    Severity: Minor
    Found in app/controllers/rails_admin/main_controller.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

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

            def sort_column
              if sortable == true
                "#{abstract_model.quoted_table_name}.#{abstract_model.quote_column_name(name)}"
              elsif (sortable.is_a?(String) || sortable.is_a?(Symbol)) && sortable.to_s.include?('.') # just provide sortable, don't do anything smart
                sortable
    Severity: Minor
    Found in lib/rails_admin/config/fields/base.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

    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.variable?
                  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

    Method edit_user_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def edit_user_link
          return nil unless _current_user.try(:email).present?
          return nil unless (abstract_model = RailsAdmin.config(_current_user.class).abstract_model)
    
          edit_action = action(:edit, abstract_model, _current_user)
    Severity: Minor
    Found in app/helpers/rails_admin/application_helper.rb - About 25 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 build_statement_for_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_statement_for_date
            start_date, end_date = get_filtering_duration
            if start_date
              start_date = begin
                start_date.to_date
    Severity: Minor
    Found in lib/rails_admin/abstract_model.rb - About 25 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 encoding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def encoding
            adapter =
              if ::ActiveRecord::Base.respond_to?(:connection_db_config)
                ::ActiveRecord::Base.connection_db_config.configuration_hash[:adapter]
              else
    Severity: Minor
    Found in lib/rails_admin/adapters/active_record.rb - About 25 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 include_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def include_fields(*field_names, &block)
            if field_names.empty?
              _fields.select { |f| f.instance_eval(&block) }.each do |f|
                next if f.defined
    
    
    Severity: Minor
    Found in lib/rails_admin/config/has_fields.rb - About 25 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 wording_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def wording_for(label, action = @action, abstract_model = @abstract_model, object = @object)
          model_config = abstract_model.try(:config)
          object = nil unless abstract_model && object.is_a?(abstract_model.model)
          action = RailsAdmin::Config::Actions.find(action.to_sym) if action.is_a?(Symbol) || action.is_a?(String)
    
    
    Severity: Minor
    Found in app/helpers/rails_admin/application_helper.rb - About 25 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 factory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.factory(parent)
            fields = []
            # Load fields for all properties (columns)
    
            parent.abstract_model.properties.each do |properties|
    Severity: Minor
    Found in lib/rails_admin/config/fields.rb - About 25 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 generate_csv_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_csv_string(options)
          generator_options = (options[:generator] || {}).symbolize_keys.delete_if { |_, value| value.blank? }
          method = @objects.respond_to?(:find_each) ? :find_each : :each
    
          CSV.generate(**generator_options) do |csv|
    Severity: Minor
    Found in lib/rails_admin/support/csv_converter.rb - About 25 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def get(id, scope = scoped)
            object = scope.find(id)
            return nil unless object
    
            object.extend(ObjectExtension)
    Severity: Minor
    Found in lib/rails_admin/adapters/mongoid.rb - About 25 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 asset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def asset
          return options['asset'] if options['asset']
    
          if defined?(Webpacker)
            'webpacker'
    Severity: Minor
    Found in lib/generators/rails_admin/install_generator.rb - About 25 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 optional has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def optional(state = nil, &block)
              if !state.nil? || block
                required state.nil? ? proc { instance_eval(&block) == false } : state == false
              else
                optional?
    Severity: Minor
    Found in lib/rails_admin/config/fields/base.rb - About 25 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

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

                    respond_to do |format|
                      format.html { redirect_to_on_success }
                      format.json { render json: {id: @object.id.to_s, label: @model_config.with(object: @object).object_label} }
    Severity: Minor
    Found in lib/rails_admin/config/actions/new.rb and 1 other location - About 15 mins to fix
    lib/rails_admin/config/actions/edit.rb on lines 34..36

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

    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