Showing 664 of 664 total issues
Method on_record
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def on_record(time, record)
tag = extract_tag_from_record(record)
tag = @added_prefix_string + tag if tag && @add_prefix
tag ||= @tag
time ||= extract_time_from_record(record) || Fluent::EventTime.now
- 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 parser_create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parser_create(usage: '', type: nil, conf: nil, default_type: nil)
parser = @_parsers[usage]
return parser if parser && !type && !conf
type = if type
- 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 formatter_create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def formatter_create(usage: '', type: nil, conf: nil, default_type: nil)
formatter = @_formatters[usage]
return formatter if formatter && !type && !conf
type = if type
- 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 parse_multilines
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_multilines(lines, tail_watcher)
lb = tail_watcher.line_buffer_timer_flusher.line_buffer
es = Fluent::MultiEventStream.new
if @parser.has_firstline?
tail_watcher.line_buffer_timer_flusher.reset_timer
Method create_transfer_socket
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_transfer_socket(host, port, hostname, &block)
case @transport
when :tls
socket_create_tls(
host, port,
Method configure
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure(conf)
compat_parameters_convert(conf, :parser)
parser_config = conf.elements('parse').first
unless parser_config
raise Fluent::ConfigError, "<parse> section is required."
Method dump_stacktrace
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dump_stacktrace(type, backtrace, level)
return if @level > level
time = Time.now
Method thread_create
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def thread_create(title)
raise ArgumentError, "BUG: title must be a symbol" unless title.is_a? Symbol
raise ArgumentError, "BUG: callback not specified" unless block_given?
m = Mutex.new
m.lock
Similar blocks of code found in 2 locations. Consider refactoring. Open
(1..REGEXP_MAX_NUM).each do |i|
next unless conf["regexp#{i}"]
key, regexp = conf["regexp#{i}"].split(/ /, 2)
raise Fluent::ConfigError, "regexp#{i} does not contain 2 parameters" unless regexp
raise Fluent::ConfigError, "regexp#{i} contains a duplicated key, #{key}" if regexp_and_conditions[key]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 59.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
(1..REGEXP_MAX_NUM).each do |i|
next unless conf["exclude#{i}"]
key, exclude = conf["exclude#{i}"].split(/ /, 2)
raise Fluent::ConfigError, "exclude#{i} does not contain 2 parameters" unless exclude
raise Fluent::ConfigError, "exclude#{i} contains a duplicated key, #{key}" if exclude_or_conditions[key]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 59.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method initialize
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(title, wait, timeout, forever, max_steps, randomize, randomize_width, backoff_base, max_interval, secondary, secondary_threshold)
Method tls_verify_result_name
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.tls_verify_result_name(code)
case code
when OpenSSL::X509::V_OK then 'V_OK'
when OpenSSL::X509::V_ERR_AKID_SKID_MISMATCH then 'V_ERR_AKID_SKID_MISMATCH'
when OpenSSL::X509::V_ERR_APPLICATION_VERIFICATION then 'V_ERR_APPLICATION_VERIFICATION'
Method read_ack_from_sock
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_ack_from_sock(sock)
begin
raw_data = sock.instance_of?(Fluent::PluginHelper::Socket::WrappedSocket::TLS) ? sock.readpartial(@read_length) : sock.recv(@read_length)
rescue Errno::ECONNRESET, EOFError # ECONNRESET for #recv, #EOFError for #readpartial
raw_data = ''
Method start_tcp_server
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_tcp_server(tls: false)
octet_count_frame = @frame_type == :octet_count
delimiter = octet_count_frame ? " " : @delimiter
delimiter_size = delimiter.size
Method parse
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse(text)
m = REGEXP.match(text)
unless m
yield nil, nil
return
Method prepare_option_parser
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_option_parser
@parser = OptionParser.new
@parser.version = Fluent::VERSION
@parser.banner = <<BANNER
Usage: #{$0} [options] <type> <name>
Method parse_rfc5424_regex
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_rfc5424_regex(text, &block)
idx = 0
record = {}
if @with_priority
Method parse!
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse!(allow_include, elem_name = nil, attrs = {}, elems = [])
while line = @iterator.next
line.force_encoding('UTF-8')
@i += 1
line.lstrip!
Method compat_parameters_parser
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def compat_parameters_parser(conf)
return unless conf.elements('parse').empty?
return if PARSER_PARAMS.keys.all?{|k| !conf.has_key?(k) }
# TODO: warn obsolete parameters if these are deprecated
Method establish_connection
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def establish_connection(sock, ri)
while ri.state != :established
begin
# TODO: On Ruby 2.2 or earlier, read_nonblock doesn't work expectedly.
# We need rewrite around here using new socket/server plugin helper.