Method on_message
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def on_message(msg, chunk_size, conn)
if msg.nil?
# for future TCP heartbeat_request
return
end
- 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
File in_forward.rb
has 382 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'fluent/plugin/input'
require 'fluent/msgpack_factory'
require 'yajl'
require 'digest'
require 'securerandom'
Method configure
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def configure(conf)
super
if @source_hostname_key
# TODO: add test
- 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 on_message
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def on_message(msg, chunk_size, conn)
if msg.nil?
# for future TCP heartbeat_request
return
end
Method handle_connection
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def handle_connection(conn)
send_data = ->(serializer, data){ conn.write serializer.call(data) }
log.trace "connected fluent socket", addr: conn.remote_addr, port: conn.remote_port
state = :established
- 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 configure
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure(conf)
super
if @source_hostname_key
# TODO: add test
Method check_ping
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def check_ping(message, remote_addr, user_auth_salt, nonce)
log.debug "checking ping"
# ['PING', self_hostname, shared_key_salt, sha512_hex(shared_key_salt + self_hostname + nonce + shared_key), username || '', sha512_hex(auth_salt + username + password) || '']
unless message.size == 6 && message[0] == 'PING'
return false, 'invalid ping message'
- 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 handle_connection
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_connection(conn)
send_data = ->(serializer, data){ conn.write serializer.call(data) }
log.trace "connected fluent socket", addr: conn.remote_addr, port: conn.remote_port
state = :established
Method check_ping
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_ping(message, remote_addr, user_auth_salt, nonce)
log.debug "checking ping"
# ['PING', self_hostname, shared_key_salt, sha512_hex(shared_key_salt + self_hostname + nonce + shared_key), username || '', sha512_hex(auth_salt + username + password) || '']
unless message.size == 6 && message[0] == 'PING'
return false, 'invalid ping message'
Method read_messages
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_messages(conn, &block)
feeder = nil
serializer = nil
bytes = 0
conn.data do |data|
Method read_messages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def read_messages(conn, &block)
feeder = nil
serializer = nil
bytes = 0
conn.data do |data|
- 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
Avoid too many return
statements within this method. Open
return if record.nil?
Avoid too many return
statements within this method. Open
return true, shared_key_salt, shared_key