imanel/websocket-ruby

View on GitHub

Showing 10 of 10 total issues

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

        def decode_frame
          return if @frame.data.size.zero?

          pointer = 0
          frame_type = @frame.data.getbyte(pointer)
Severity: Minor
Found in lib/websocket/frame/handler/handler75.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 decode_frame has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def decode_frame
          while @frame.data.size > 1
            valid_header, more, frame_type, mask, payload_length = decode_header
            return unless valid_header

Severity: Minor
Found in lib/websocket/frame/handler/handler03.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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(args = {})
        super

        if @url || @uri
          uri = URI.parse(@url || @uri)
Severity: Minor
Found in lib/websocket/handshake/client.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 decode_frame has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def decode_frame
          return if @frame.data.size.zero?

          pointer = 0
          frame_type = @frame.data.getbyte(pointer)
Severity: Minor
Found in lib/websocket/frame/handler/handler75.rb - About 1 hr to fix

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

          def parse_data
            header, @leftovers = @data.split("\r\n\r\n", 2)
            return false unless @leftovers # The whole header has not been received yet.
    
            lines = header.split("\r\n")
    Severity: Minor
    Found in lib/websocket/handshake/base.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 decode_frame has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def decode_frame
              result = super
              if close_code?(result)
                code = result.data.slice!(0..1)
                result.code = code.unpack('n').first
    Severity: Minor
    Found in lib/websocket/frame/handler/handler07.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 decode_payload_length has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def decode_payload_length(length)
              case length
              when 127 # Length defined by 8 bytes
                # Check buffer size
                return unless buffer_exists?(10) # Buffer incomplete
    Severity: Minor
    Found in lib/websocket/frame/handler/handler03.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 decode_header has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def decode_header
              more, frame_type = decode_first_byte
              header_length, payload_length, mask = decode_second_byte(frame_type)
              return unless header_length
    
    
    Severity: Minor
    Found in lib/websocket/frame/handler/handler03.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

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

          def rescue_method(method_name, options = {})
            define_method "#{method_name}_with_rescue" do |*args|
              begin
                send("#{method_name}_without_rescue", *args)
              rescue WebSocket::Error => e
    Severity: Minor
    Found in lib/websocket/exception_handler.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

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

          def set_version
            @version = @headers['sec-websocket-version'].to_i if @headers['sec-websocket-version']
            @version ||= @headers['sec-websocket-draft'].to_i if @headers['sec-websocket-draft']
            @version ||= 76 if @headers['sec-websocket-key1']
            @version ||= 75
    Severity: Minor
    Found in lib/websocket/handshake/server.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

    Severity
    Category
    Status
    Source
    Language