railties/lib/rails/engine.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Engine has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Engine < Railtie
    autoload :Configuration, "rails/engine/configuration"

    class << self
      attr_accessor :called_from, :isolated
Severity: Minor
Found in railties/lib/rails/engine.rb - About 4 hrs to fix

    File engine.rb has 314 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "rails/railtie"
    require "rails/engine/railties"
    require "active_support/callbacks"
    require "active_support/core_ext/module/delegation"
    require "active_support/core_ext/object/try"
    Severity: Minor
    Found in railties/lib/rails/engine.rb - About 3 hrs to fix

      Method isolate_namespace has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def isolate_namespace(mod)
              engine_name(generate_railtie_name(mod.name))
      
              routes.default_scope = { module: ActiveSupport::Inflector.underscore(mod.name) }
              self.isolated = true
      Severity: Minor
      Found in railties/lib/rails/engine.rb - About 2 hrs 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 isolate_namespace has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def isolate_namespace(mod)
              engine_name(generate_railtie_name(mod.name))
      
              routes.default_scope = { module: ActiveSupport::Inflector.underscore(mod.name) }
              self.isolated = true
      Severity: Minor
      Found in railties/lib/rails/engine.rb - About 1 hr to fix

        Method find_root_with_flag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.find_root_with_flag(flag, root_path, default = nil) # :nodoc:
                while root_path && File.directory?(root_path) && !File.exist?("#{root_path}/#{flag}")
                  parent = File.dirname(root_path)
                  root_path = parent != root_path && parent
                end
        Severity: Minor
        Found in railties/lib/rails/engine.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