imanel/websocket-ruby

View on GitHub
lib/websocket/frame/handler/handler03.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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 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

There are no issues that match your filters.

Category
Status