Method parse
has 115 lines of code (exceeds 25 allowed). Consider refactoring.
def parse
begin
OptionParser.new do |opts|
opts.banner = ' '
Method launch
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
def launch
launch_sinatra_app if options[:web]
launch_signal_handler
tdb "config: #{config.to_h}" if Turnstile.config.trace
Method method_missing
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
def method_missing(m, *args, &block)
if redis.respond_to?(m)
t1 = Time.now
result = redis.send(m, *args, &block)
delta = Time.now - t1
Method parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
def parse
begin
OptionParser.new do |opts|
opts.banner = ' '
Method read
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def read(&_block)
file.tail do |line|
token = matcher.tokenize(line) if matcher
yield(token) if block_given? && token
break if stopping?
Method execute!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def execute!
exit_code = begin
Colored2.disable! unless stdout.tty?
$stderr = stderr
Method _logging
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def _logging(level = :info, *args, &_block)
message = args.join(' ')
log(level, message) unless block_given?
return unless block_given?
Method execute!
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
def execute!
exit_code = begin
Colored2.disable! unless stdout.tty?
$stderr = stderr
Method with_retries
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def with_retries(tries = 3)
yield(tries)
rescue Errno::EINVAL => e
on_error e
rescue ::Redis::BaseConnectionError => e
Method start
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def start
self.thread = create_thread(self, sleep_when_idle) do |actor, sleep_period|
loop do
items_remaining = actor.execute
break if actor.stopping?
Method build_string
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def build_string(data,
joiner = "\n",
prefix = nil,
suffix = nil,
&_block)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
Method execute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def execute
self.read do |token|
self.queue << token if token
end
rescue IOError
Method initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def initialize(*args)
self.options = args.last.is_a?(Hash) ? args.pop : {}
options.verbose ? Turnstile::Logger.enable : Turnstile::Logger.disable
Method method_missing
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def method_missing(method, *args, &block)
return super unless method.to_s =~ /^redis_/
prop = method.to_s.gsub(/^redis_/, '').to_sym
if self.redis.respond_to?(prop)
prop.to_s.end_with?('=') ? self.redis.send(prop, *args, &block) : self.redis.send(prop)