ruby-grape/grape

View on GitHub
lib/grape/router.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

  class Router
    attr_reader :map, :compiled

    def self.normalize_path(path)
      path = +"/#{path}"
Severity: Minor
Found in lib/grape/router.rb - About 2 hrs to fix

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

        def rotation(env, exact_route = nil)
          response = nil
          input, method = *extract_input_and_method(env)
          map[method].each do |route|
            next if exact_route == route
    Severity: Minor
    Found in lib/grape/router.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 transaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def transaction(env)
          input, method = *extract_input_and_method(env)
          response = yield(input, method)
    
          return response if response && !(cascade = cascade?(response))
    Severity: Minor
    Found in lib/grape/router.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

    Avoid too many return statements within this method.
    Open

          return call_with_allow_headers(env, last_neighbor_route) if !cascade && last_neighbor_route
    Severity: Major
    Found in lib/grape/router.rb - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status