Showing 7 of 7 total issues
Class Parser
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Parser
attr_writer :on_message, :on_error, :on_close, :on_ping, :on_pong
def initialize
@data = ''.force_encoding("ASCII-8BIT")
Method next_message
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def next_message
read_header if @state == :header
read_payload_length if @state == :payload_length
read_mask_key if @state == :mask
read_payload if @state == :payload
- Read upRead up
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 process_message!
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def process_message!
case opcode
when :text
msg = @current_message.force_encoding("UTF-8")
raise ParserError.new('Payload data is not valid UTF-8') unless msg.valid_encoding?
- Read upRead up
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 read_extended_payload_length
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def read_extended_payload_length
if message_size == :medium && @data.size >= 2
size = unpack_bytes(2,'n')
ParserError.new("Wrong payload length. Expected to be greater than 125") unless size > 125
size
- Read upRead up
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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(verb, uri, headers = {}, proxy = {}, body = nil, version = '1.1')
Method process_frame!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def process_frame!
if @current_message
@current_message << @payload
else
@current_message = @payload
- Read upRead up
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 read_payload_length
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def read_payload_length
@payload_length = if message_size == :small
payload_length_field
else
read_extended_payload_length
- Read upRead up
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"