byroot/frozen_record

View on GitHub

Showing 10 of 10 total issues

Class Scope has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Scope
    DISALLOWED_ARRAY_METHODS = [
      :compact!, :flatten!, :reject!, :reverse!, :rotate!, :map!,
      :shuffle!, :slice!, :sort!, :sort_by!, :delete_if,
      :keep_if, :pop, :shift, :delete_at, :compact
Severity: Minor
Found in lib/frozen_record/scope.rb - About 5 hrs to fix

    Class Base has 38 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Base
        extend ActiveSupport::DescendantsTracker
        extend ActiveModel::Naming
        include ActiveModel::Conversion
        include ActiveModel::AttributeMethods
    Severity: Minor
    Found in lib/frozen_record/base.rb - About 5 hrs to fix

      File scope.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module FrozenRecord
        class Scope
          DISALLOWED_ARRAY_METHODS = [
            :compact!, :flatten!, :reject!, :reverse!, :rotate!, :map!,
            :shuffle!, :slice!, :sort!, :sort_by!, :delete_if,
      Severity: Minor
      Found in lib/frozen_record/scope.rb - About 2 hrs to fix

        File base.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'active_support/descendants_tracker'
        require 'frozen_record/backends'
        
        module FrozenRecord
          SlowQuery = Class.new(StandardError)
        Severity: Minor
        Found in lib/frozen_record/base.rb - About 2 hrs to fix

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

              def select_records(records)
                return records if @where_values.empty? && @where_not_values.empty?
          
                indices = @klass.index_definitions
                indexed_where_values, unindexed_where_values = @where_values.partition { |criteria| indices.key?(criteria.first) }
          Severity: Minor
          Found in lib/frozen_record/scope.rb - About 1 hr to fix

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

                def select_records(records)
                  return records if @where_values.empty? && @where_not_values.empty?
            
                  indices = @klass.index_definitions
                  indexed_where_values, unindexed_where_values = @where_values.partition { |criteria| indices.key?(criteria.first) }
            Severity: Minor
            Found in lib/frozen_record/scope.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 load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def load(file_path)
                    if !File.exist?(file_path) && File.exist?("#{file_path}.erb")
                      file_path = "#{file_path}.erb"
                    end
            
            
            Severity: Minor
            Found in lib/frozen_record/backends/yaml.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 memsize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def memsize(object = self, seen = Set.new.compare_by_identity)
                    return 0 unless seen.add?(object)
            
                    size = ObjectSpace.memsize_of(object)
                    object.instance_variables.each { |v| size += memsize(object.instance_variable_get(v), seen) }
            Severity: Minor
            Found in lib/frozen_record/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 compare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def compare(record_a, record_b)
                  @order_values.each do |attr, order|
                    a_value, b_value = record_a.send(attr), record_b.send(attr)
                    cmp = a_value <=> b_value
                    next if cmp == 0
            Severity: Minor
            Found in lib/frozen_record/scope.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 unload_fixture has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def unload_fixture(model_class)
                    return unless defined?(@cache) && @cache
            
                    ensure_model_class_is_frozenrecord(model_class)
            
            
            Severity: Minor
            Found in lib/frozen_record/test_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