actionpack/lib/action_controller/test_case.rb

Summary

Maintainability
D
2 days
Test Coverage

File test_case.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "rack/session/abstract/id"
require "active_support/core_ext/hash/conversions"
require "active_support/core_ext/object/to_query"
require "active_support/core_ext/module/anonymous"
require "active_support/core_ext/module/redefine_method"
Severity: Minor
Found in actionpack/lib/action_controller/test_case.rb - About 5 hrs to fix

    Class TestCase has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class TestCase < ActiveSupport::TestCase
        singleton_class.attr_accessor :executor_around_each_request
    
        module Behavior
          extend ActiveSupport::Concern
    Severity: Minor
    Found in actionpack/lib/action_controller/test_case.rb - About 2 hrs to fix

      Method assign_parameters has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def assign_parameters(routes, controller_path, action, parameters, generated_path, query_string_keys)
            non_path_parameters = {}
            path_parameters = {}
      
            parameters.each do |key, value|
      Severity: Minor
      Found in actionpack/lib/action_controller/test_case.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 assign_parameters has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def assign_parameters(routes, controller_path, action, parameters, generated_path, query_string_keys)
            non_path_parameters = {}
            path_parameters = {}
      
            parameters.each do |key, value|
      Severity: Major
      Found in actionpack/lib/action_controller/test_case.rb - About 2 hrs to fix

        Method setup_controller_request_and_response has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def setup_controller_request_and_response
                @controller = nil unless defined? @controller
        
                @response_klass = ActionDispatch::TestResponse
        
        
        Severity: Minor
        Found in actionpack/lib/action_controller/test_case.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 process has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def process(action, method: "GET", params: nil, session: nil, body: nil, flash: {}, format: nil, xhr: false, as: nil)
                check_required_ivars
                @controller.clear_instance_variables_between_requests
        
                action = +action.to_s
        Severity: Minor
        Found in actionpack/lib/action_controller/test_case.rb - About 1 hr to fix

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

                  def process_controller_response(action, cookies, xhr)
                    begin
                      @controller.recycle!
          
                      wrap_execution { @controller.dispatch(action, @request, @response) }
          Severity: Minor
          Found in actionpack/lib/action_controller/test_case.rb - About 1 hr to fix

            Method assign_parameters has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def assign_parameters(routes, controller_path, action, parameters, generated_path, query_string_keys)
            Severity: Minor
            Found in actionpack/lib/action_controller/test_case.rb - About 45 mins to fix

              Method setup_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def setup_request(controller_class_name, action, parameters, session, flash, xhr)
              Severity: Minor
              Found in actionpack/lib/action_controller/test_case.rb - About 45 mins to fix

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

                        def process_controller_response(action, cookies, xhr)
                          begin
                            @controller.recycle!
                
                            wrap_execution { @controller.dispatch(action, @request, @response) }
                Severity: Minor
                Found in actionpack/lib/action_controller/test_case.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

                There are no issues that match your filters.

                Category
                Status