hendolim/countonanon

View on GitHub
faye-1.1.2/lib/faye/adapters/rack_adapter.rb

Summary

Maintainability
C
1 day
Test Coverage

Method handle_request has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_request(request)
      unless json_msg = message_from_request(request)
        error 'Received request with no message: ?', format_request(request)
        return [400, TYPE_TEXT, ['Bad request']]
      end
Severity: Minor
Found in faye-1.1.2/lib/faye/adapters/rack_adapter.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 handle_request has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def handle_request(request)
      unless json_msg = message_from_request(request)
        error 'Received request with no message: ?', format_request(request)
        return [400, TYPE_TEXT, ['Bad request']]
      end
Severity: Minor
Found in faye-1.1.2/lib/faye/adapters/rack_adapter.rb - About 1 hr to fix

    Method handle_websocket has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_websocket(request)
          options   = {:extensions => @extensions, :ping => @options[:ping]}
          ws        = Faye::WebSocket.new(request.env, [], options)
          client_id = nil
    
    
    Severity: Minor
    Found in faye-1.1.2/lib/faye/adapters/rack_adapter.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 call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(env)
          Faye.ensure_reactor_running!
          request = Rack::Request.new(env)
    
          unless request.path_info =~ @endpoint_re
    Severity: Minor
    Found in faye-1.1.2/lib/faye/adapters/rack_adapter.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

    Avoid too many return statements within this method.
    Open

          return handle_eventsource(request) if Faye::EventSource.eventsource?(env)
    Severity: Major
    Found in faye-1.1.2/lib/faye/adapters/rack_adapter.rb - About 30 mins to fix

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

          def initialize(app = nil, options = nil, &block)
            @app     = app if app.respond_to?(:call)
            @options = [app, options].grep(Hash).first || {}
      
            ::WebSocket::Driver.validate_options(@options, [:engine, :mount, :ping, :timeout, :extensions, :websocket_extensions])
      Severity: Minor
      Found in faye-1.1.2/lib/faye/adapters/rack_adapter.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