brynary/rack-test

View on GitHub

Showing 5 of 5 total issues

Method env_for has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def env_for(uri, env)
        env = default_env.merge(env)

        env['HTTP_HOST'] ||= [uri.host, (uri.port if uri.port != uri.default_port)].compact.join(':')

Severity: Minor
Found in lib/rack/test.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

Class Session has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Session
      extend Forwardable
      include Rack::Test::Utils

      def_delegators :@rack_mock_session, :clear_cookies, :set_cookie, :last_response, :last_request
Severity: Minor
Found in lib/rack/test.rb - About 2 hrs to fix

    Method env_for has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def env_for(uri, env)
            env = default_env.merge(env)
    
            env['HTTP_HOST'] ||= [uri.host, (uri.port if uri.port != uri.default_port)].compact.join(':')
    
    
    Severity: Minor
    Found in lib/rack/test.rb - About 1 hr to fix

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

            def custom_request(verb, uri, params = {}, env = {}, &block)
      Severity: Minor
      Found in lib/rack/test.rb - About 35 mins to fix

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

              def parse_uri(path, env)
                URI.parse(path).tap do |uri|
                  uri.path = "/#{uri.path}" unless uri.path[0] == '/'
                  uri.host ||= @default_host
                  uri.scheme ||= 'https' if env['HTTPS'] == 'on'
        Severity: Minor
        Found in lib/rack/test.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

        Severity
        Category
        Status
        Source
        Language