activerecord/lib/active_record/fixtures.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class FixtureSet has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class FixtureSet
    require "active_record/fixture_set/file"
    require "active_record/fixture_set/render_context"
    require "active_record/fixture_set/table_rows"

Severity: Minor
Found in activerecord/lib/active_record/fixtures.rb - About 3 hrs to fix

    File fixtures.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "erb"
    require "yaml"
    require "zlib"
    require "set"
    require "active_support/dependencies"
    Severity: Minor
    Found in activerecord/lib/active_record/fixtures.rb - About 2 hrs to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(_, name, class_name, path, config = ActiveRecord::Base)
      Severity: Minor
      Found in activerecord/lib/active_record/fixtures.rb - About 35 mins to fix

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

              def read_fixture_files(path)
                yaml_files = Dir["#{path}{.yml,/{**,*}/*.yml}"].select { |f|
                  ::File.file?(f)
                }
        
        
        Severity: Minor
        Found in activerecord/lib/active_record/fixtures.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 insert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def insert(fixture_sets, connection_pool) # :nodoc:
                  fixture_sets_by_pool = fixture_sets.group_by do |fixture_set|
                    if fixture_set.model_class
                      fixture_set.model_class.connection_pool
                    else
        Severity: Minor
        Found in activerecord/lib/active_record/fixtures.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