sferik/rails_admin

View on GitHub
lib/rails_admin/adapters/active_record.rb

Summary

Maintainability
B
7 hrs
Test Coverage

File active_record.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'active_record'
require 'rails_admin/adapters/active_record/association'
require 'rails_admin/adapters/active_record/object_extension'
require 'rails_admin/adapters/active_record/property'

Severity: Minor
Found in lib/rails_admin/adapters/active_record.rb - About 2 hrs to fix

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

      There are no issues that match your filters.

      Category
      Status