railties/lib/rails/application/configuration.rb

Summary

Maintainability
F
4 days
Test Coverage

Method load_defaults has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

      def load_defaults(target_version)
        # To introduce a change in behavior, follow these steps:
        # 1. Add an accessor on the target object (e.g. the ActiveJob class for
        #    global Active Job config).
        # 2. Set a default value there preserving existing behavior for existing
Severity: Minor
Found in railties/lib/rails/application/configuration.rb - About 1 day 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_defaults has 188 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def load_defaults(target_version)
        # To introduce a change in behavior, follow these steps:
        # 1. Add an accessor on the target object (e.g. the ActiveJob class for
        #    global Active Job config).
        # 2. Set a default value there preserving existing behavior for existing
Severity: Major
Found in railties/lib/rails/application/configuration.rb - About 7 hrs to fix

    File configuration.rb has 474 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "ipaddr"
    require "active_support/core_ext/array/wrap"
    require "active_support/core_ext/kernel/reporting"
    require "active_support/file_update_checker"
    require "active_support/configuration_file"
    Severity: Minor
    Found in railties/lib/rails/application/configuration.rb - About 7 hrs to fix

      Method database_configuration has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

            def database_configuration
              path = paths["config/database"].existent.first
              yaml = Pathname.new(path) if path
      
              config = if yaml&.exist?
      Severity: Minor
      Found in railties/lib/rails/application/configuration.rb - About 3 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

      Class Configuration has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Configuration < ::Rails::Engine::Configuration
            attr_accessor :allow_concurrency, :asset_host, :assume_ssl, :autoflush_log,
                          :cache_classes, :cache_store, :consider_all_requests_local, :console,
                          :eager_load, :exceptions_app, :file_watcher, :filter_parameters, :precompile_filter_parameters,
                          :force_ssl, :helpers_paths, :hosts, :host_authorization, :logger, :log_formatter,
      Severity: Minor
      Found in railties/lib/rails/application/configuration.rb - About 3 hrs to fix

        Method initialize has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def initialize(*)
                super
                self.encoding                            = Encoding::UTF_8
                @allow_concurrency                       = nil
                @consider_all_requests_local             = false
        Severity: Major
        Found in railties/lib/rails/application/configuration.rb - About 2 hrs to fix

          Method database_configuration has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def database_configuration
                  path = paths["config/database"].existent.first
                  yaml = Pathname.new(path) if path
          
                  config = if yaml&.exist?
          Severity: Minor
          Found in railties/lib/rails/application/configuration.rb - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  def autoload_lib_once(ignore:)
                    lib = root.join("lib")
            
                    # Set as a string to have the same type as default autoload paths, for
                    # consistency.
            Severity: Minor
            Found in railties/lib/rails/application/configuration.rb and 1 other location - About 25 mins to fix
            railties/lib/rails/application/configuration.rb on lines 476..485

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 29.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  def autoload_lib(ignore:)
                    lib = root.join("lib")
            
                    # Set as a string to have the same type as default autoload paths, for
                    # consistency.
            Severity: Minor
            Found in railties/lib/rails/application/configuration.rb and 1 other location - About 25 mins to fix
            railties/lib/rails/application/configuration.rb on lines 488..497

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 29.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status