File server.rb
has 644 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rice/irc'
require 'ndk/error'
require 'ndk/config'
require 'ndk/server_state'
require 'ndk/client'
Method start_clients_thread
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def start_clients_thread
return unless @config.client_server_port
@clients_thread = Thread.new{
begin
@cserver = TCPServer.new(@config.client_server_host,
- 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 server_main_proc
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def server_main_proc
## login
# send passwd
if @server_passwd
- 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 server_main_proc
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
def server_main_proc
## login
# send passwd
if @server_passwd
Method start
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def start
start_server_thread
start_clients_thread
timer_thread = Thread.new{
begin
- 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
Class NDK_Server
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class NDK_Server
TimerIntervalSec = 60
MAX_PONG_FAIL = 5
def initialize rc
Method start_server_thread
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def start_server_thread
@server_thread = Thread.new{
begin
@server = make_server()
@logger.slog "Server connection to #{@server.server}:#{@server.port}."
- 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 recv_from_server
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def recv_from_server
while q = @rq.pop
# Event
if q.kind_of? Array
- 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 send_to_bot
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def send_to_bot msg, *arg
selector = 'on_' +
if msg.respond_to? :command
if /^\d+$/ =~ msg.command
- 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 start_clients_thread
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_clients_thread
return unless @config.client_server_port
@clients_thread = Thread.new{
begin
@cserver = TCPServer.new(@config.client_server_host,
Method start
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start
start_server_thread
start_clients_thread
timer_thread = Thread.new{
begin
Method send_to_bot
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_to_bot msg, *arg
selector = 'on_' +
if msg.respond_to? :command
if /^\d+$/ =~ msg.command
Method enter_away
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def enter_away
return if @exitting || !@connected
send_to_server Cmd.away(@config.away_message) if @config.away_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 filter_message
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def filter_message filter, msg
return msg if filter.nil? || filter.empty?
begin
if filter.respond_to? :each
Method start_server_thread
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_server_thread
@server_thread = Thread.new{
begin
@server = make_server()
@logger.slog "Server connection to #{@server.server}:#{@server.port}."
Method exec_event
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def exec_event q
# special event
case q[0]
when :reload_config
# q[1] must be client object
Method recv_from_server
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def recv_from_server
while q = @rq.pop
# Event
if q.kind_of? Array
Method make_server
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def make_server
host, port, @server_passwd, ssl_params = next_server_info
server = ::RICE::Connection.new(host, port, "\r\n", ssl_params)
server.regist{|rq, wq|
Thread.stop
- 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 deeply nested control flow statements. Open
if negate
@isupport.delete(key)
else
@isupport[key] = value || true
end
Method exec_event
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exec_event q
# special event
case q[0]
when :reload_config
# q[1] must be client object
- 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 send_to_clients_otherwise
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def send_to_clients_otherwise msg, elt
@clients.each{|cl|
if cl != elt
cl.add_prefix(msg) unless msg.prefix
cl << msg
- 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 false
Avoid too many return
statements within this method. Open
return false