byroot/frozen_record

View on GitHub
lib/frozen_record/scope.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    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

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

        There are no issues that match your filters.

        Category
        Status