actionpack/lib/action_dispatch/routing/route_set.rb

Summary

Maintainability
F
3 days
Test Coverage

File route_set.rb has 691 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "action_dispatch/journey"
require "active_support/core_ext/object/to_query"
require "active_support/core_ext/module/redefine_method"
require "active_support/core_ext/module/remove_method"
require "active_support/core_ext/array/extract_options"
Severity: Major
Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 1 day to fix

    Class RouteSet has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class RouteSet
          # Since the router holds references to many parts of the system like engines,
          # controllers and the application itself, inspecting the route set can actually
          # be really slow, therefore we default alias inspect to to_s.
          alias inspect to_s
    Severity: Minor
    Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 4 hrs to fix

      Method generate_url_helpers has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def generate_url_helpers(supports_path)
              routes = self
      
              Module.new do
                extend ActiveSupport::Concern
      Severity: Major
      Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 2 hrs to fix

        Method recognize_path_with_request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def recognize_path_with_request(req, path, extras, raise_on_missing: true)
                @router.recognize(req) do |route, params|
                  params.merge!(extras)
                  params.each do |key, value|
                    if value.is_a?(String)
        Severity: Minor
        Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 1 hr 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 url_for has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def url_for(options, route_name = nil, url_strategy = UNKNOWN, method_name = nil, reserved = RESERVED_OPTIONS)
                options = default_url_options.merge options
        
                user = password = nil
        
        
        Severity: Minor
        Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 1 hr to fix

          Method handle_positional_args has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                    def handle_positional_args(controller_options, inner_options, args, result, path_params)
                      if args.size > 0
                        # take format into account
                        if path_params.include?(:format)
                          path_params_size = path_params.size - 1
          Severity: Minor
          Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 1 hr 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 add_route has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_route(mapping, name)
                  raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)
          
                  if name && named_routes[name]
                    raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \
          Severity: Minor
          Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 45 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 url_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def url_for(options, route_name = nil, url_strategy = UNKNOWN, method_name = nil, reserved = RESERVED_OPTIONS)
                  options = default_url_options.merge options
          
                  user = password = nil
          
          
          Severity: Minor
          Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 45 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 url_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def url_for(options, route_name = nil, url_strategy = UNKNOWN, method_name = nil, reserved = RESERVED_OPTIONS)
          Severity: Minor
          Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 35 mins to fix

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

                        def call(t, method_name, args, inner_options, url_strategy)
            Severity: Minor
            Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 35 mins to fix

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

                        def handle_positional_args(controller_options, inner_options, args, result, path_params)
              Severity: Minor
              Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 35 mins to fix

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

                          def call(t, method_name, args, inner_options, url_strategy)
                Severity: Minor
                Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 35 mins to fix

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

                        def default_env
                          if default_url_options != @default_env&.[]("action_dispatch.routes.default_url_options")
                            url_options = default_url_options.dup.freeze
                            uri = URI(ActionDispatch::Http::URL.full_url_for(host: "example.org", **url_options))
                  
                  
                  Severity: Minor
                  Found in actionpack/lib/action_dispatch/routing/route_set.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                              def call(t, method_name, args, inner_options, url_strategy)
                                if args.size == arg_size && !inner_options && optimize_routes_generation?(t)
                                  options = t.url_options.merge @options
                                  path = optimized_helper(args)
                                  path << "/" if options[:trailing_slash] && !path.end_with?("/")
                  Severity: Minor
                  Found in actionpack/lib/action_dispatch/routing/route_set.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