sferik/rails_admin

View on GitHub

Showing 72 of 107 total issues

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

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

Severity
Category
Status
Source
Language