Showing 664 of 664 total issues
Method plugin_root_dir
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def plugin_root_dir
return @_plugin_root_dir if @_plugin_root_dir
return nil unless system_config.root_dir
return nil unless plugin_id_configured?
- 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_worker_id
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_worker_id(conf)
worker_id_str = conf.arg
if worker_id_str.empty?
raise Fluent::ConfigError, 'Missing worker id on <worker> directive'
- 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def configure(conf, strict_config_value=false)
@config = conf
logger = if self.respond_to?(:log)
self.log
- 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 socket_create_tcp
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def socket_create_tcp(host, port, resolve_name: false, connect_timeout: nil, **kwargs, &block)
sock = if connect_timeout
s = ::Socket.tcp(host, port, connect_timeout: connect_timeout)
s.autoclose = false # avoid GC triggered close
WrappedSocket::TCP.for_fd(s.fileno)
- 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 static_worker_analyse
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def static_worker_analyse(conf)
available_worker_ids = [*0...@workers]
ret = []
conf.elements(name: 'worker').each do |config|
- 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_attach
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def server_attach(title, proto, port, bind, shared, server)
Method server_create_for_tcp_connection
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def server_create_for_tcp_connection(shared, bind, port, backlog, socket_option_setter, &block)
Avoid deeply nested control flow statements. Open
raise Fluent::ConfigError, "Mismatched quotes. Invalid syntax: #{orig_param}" unless param[0] == param[i]
Avoid deeply nested control flow statements. Open
logger.error "config error in:\n#{conf}" if logger
Avoid deeply nested control flow statements. Open
if prev_match.include?("\n") || eof? # support 'tag_mapped' like "without value" configuration
attrs[k] = ""
else
if k == '@include'
parse_include(attrs, elems)
Avoid deeply nested control flow statements. Open
logger.error "config error in:\n#{conf}" if logger
Method generate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.generate(proxy, conf, logger, plugin_class, stack = [], strict_config_value = false)
Avoid deeply nested control flow statements. Open
if !prev_match.start_with?('@')
@logger.warn "'include' is deprecated. Use '@include' instead" if @logger
end
Method initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(sock, socket_option_setter, close_callback, log, under_plugin_development, connect_callback)
Avoid deeply nested control flow statements. Open
raise Fluent::ConfigError, "missing array index in '[]'. Invalid syntax: #{param}" if index_value == ']'
Method error_sample
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def error_sample
pos = @ss.pos
lines = @ss.string.lines.to_a
lines.each_with_index { |line, ln|
- 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 scan_embedded_code
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def scan_embedded_code
src = '"#{'+@ss.rest+"\n=begin\n=end\n}"
seek = -1
while (seek = src.index('}', seek + 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 dump_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def dump_value(k, v, nindent)
return "#{nindent}#{k} xxxxxx\n" if secret_param?(k)
return "#{nindent}#{k} #{v}\n" unless @v1_config
# for v1 config
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
INTEGER_TYPE = Proc.new { |val, opts = {}, name = nil|
if val.nil?
nil
elsif opts[:strict]
begin
- 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 37.
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
FLOAT_TYPE = Proc.new { |val, opts = {}, name = nil|
if val.nil?
nil
elsif opts[:strict]
begin
- 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 37.
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