actionpack/lib/action_dispatch/journey/formatter.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

      def generate(name, options, path_parameters)
        original_options = options.dup
        path_params = options.delete(:path_params) || {}
        options = path_params.merge(options)
        constraints = path_parameters.merge(options)
Severity: Minor
Found in actionpack/lib/action_dispatch/journey/formatter.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

Method missing_keys has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def missing_keys(route, parts)
          missing_keys = nil
          tests = route.path.requirements_for_missing_keys_check
          route.required_parts.each { |key|
            case tests[key]
Severity: Minor
Found in actionpack/lib/action_dispatch/journey/formatter.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 generate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def generate(name, options, path_parameters)
        original_options = options.dup
        path_params = options.delete(:path_params) || {}
        options = path_params.merge(options)
        constraints = path_parameters.merge(options)
Severity: Minor
Found in actionpack/lib/action_dispatch/journey/formatter.rb - About 1 hr to fix

    Method match_route has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def match_route(name, options)
              if named_routes.key?(name)
                yield named_routes[name]
              else
                routes = non_recursive(cache, options)
    Severity: Minor
    Found in actionpack/lib/action_dispatch/journey/formatter.rb - About 55 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def initialize(constraints, missing_keys, unmatched_keys, routes, name)
    Severity: Minor
    Found in actionpack/lib/action_dispatch/journey/formatter.rb - About 35 mins to fix

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

              def non_recursive(cache, options)
                routes = []
                queue  = [cache]
      
                while queue.any?
      Severity: Minor
      Found in actionpack/lib/action_dispatch/journey/formatter.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