Showing 564 of 653 total issues
Method thread_wait_until_stop
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def thread_wait_until_stop
timeout_at = Fluent::Clock.now + THREAD_SHUTDOWN_HARD_TIMEOUT_IN_TESTS
until @_threads_mutex.synchronize{ @_threads.values.reduce(true){|r,t| r && !t[:_fluentd_plugin_helper_thread_running] } }
break if Fluent::Clock.now > timeout_at
sleep 0.1
- 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 method_missing
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def method_missing(name, *args, &block)
::Kernel.raise ::ArgumentError, "Configuration DSL Syntax Error: only one argument allowed" if args.size > 1
value = args.first
if block
- 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_stream
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def filter_stream(tag, es)
new_es = Fluent::MultiEventStream.new
tag_parts = tag.split('.')
tag_prefix = tag_prefix(tag_parts)
tag_suffix = tag_suffix(tag_parts)
Method parse_rfc3164_regex
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def parse_rfc3164_regex(text, &block)
idx = 0
record = {}
if @with_priority
Method metadata
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def metadata(tag, time, record)
# this arguments are ordered in output plugin's rule
# Metadata 's argument order is different from this one (timekey, tag, variables)
raise ArgumentError, "tag must be a String: #{tag.class}" unless tag.nil? || tag.is_a?(String)
Method build_spawn_command
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_spawn_command
if ENV['TEST_RUBY_PATH']
fluentd_spawn_cmd = [ENV['TEST_RUBY_PATH']]
else
fluentd_spawn_cmd = [ServerEngine.ruby_bin_path]
Method default_options
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.default_options
{
config_path: Fluent::DEFAULT_CONFIG_PATH,
plugin_dirs: [Fluent::DEFAULT_PLUGIN_DIR],
log_level: Fluent::Log::LEVEL_INFO,
Method synchronize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def synchronize(*keys)
return if keys.empty?
locks = {}
loop do
Method configure
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def configure(conf)
compat_parameters_convert(conf, :parser)
super
Method <=>
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def <=>(o)
timekey2 = o.timekey
tag2 = o.tag
variables2 = o.variables
if (!!timekey ^ !!timekey2) || (!!tag ^ !!tag2) || (!!variables ^ !!variables2)
Method configure
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def configure(conf)
super
unless @queue_limit_length.nil?
@total_limit_size = @chunk_limit_size * @queue_limit_length
Method parse
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.parse(str, fname, basepath = Dir.pwd, v1_config = nil, syntax: :v1)
parser = if fname =~ /\.rb$/ || syntax == :ruby
:ruby
elsif v1_config.nil?
case syntax
Method fetch_compacted_entries
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def fetch_compacted_entries
entries = {}
@file.pos = 0
file_pos = 0
Method lifecycle
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def lifecycle(desc: false, kind_callback: nil)
kind_or_label_list = if desc
[:output, :filter, @labels.values.reverse, :output_with_router, :input].flatten
else
[:input, :output_with_router, @labels.values, :filter, :output].flatten
Method calc_next_time
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def calc_next_time
if @forever || !@secondary # primary
naive = naive_next_time(@steps)
if @forever
naive
Method format=
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def format=(fmt)
return if @format == fmt
@time_format = '%Y-%m-%d %H:%M:%S %z'
@time_formatter = Strftime.new(@time_format) rescue nil
Method shutdown
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def shutdown
@_child_process_mutex.synchronize{ @_child_process_processes.keys }.each do |pid|
process_info = @_child_process_processes[pid]
next if !process_info
process_info.writeio && process_info.writeio.close rescue nil
Method scan_double_quoted_string
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def scan_double_quoted_string
string = []
while true
if skip(/\"/)
if string.include?(nil)
Consider simplifying this complex logical expression. Open
Open
if (!!timekey ^ !!timekey2) || (!!tag ^ !!tag2) || (!!variables ^ !!variables2)
# One has value in a field, but another doesn't have value in same field
# This case occurs very rarely
if timekey == timekey2 # including the case of nil == nil
if tag == tag2
Method expand
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def expand(__str_to_eval__, tag, time, record, tag_parts, tag_prefix, tag_suffix, hostname)