Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: code quality issues #3259

Merged
merged 6 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fluent/command/bundler_injection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
File.expand_path(File.join(File.dirname(__FILE__), 'fluentd.rb')),
] + ARGV

exec *cmdline
exec(*cmdline)
exit! 127
end
1 change: 0 additions & 1 deletion lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
usage $!.to_s
end

require 'thread'
require 'socket'
require 'yajl'
require 'msgpack'
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/command/plugin_config_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def dump_section_markdown(base_section, level = 0)
else
sections, params = base_section.partition {|_name, value| value[:section] }
end
if @table and not params.empty?
if @table && (not params.empty?)
dumped << "### Configuration\n\n"
dumped << "|parameter|type|description|default|\n"
dumped << "|---|---|---|---|\n"
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/compat/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ def convert_field_type!(record)
end

def convert_value_to_nil(value)
if value and @null_empty_string
if value && @null_empty_string
value = (value == '') ? nil : value
end
if value and @null_value_pattern
if value && @null_value_pattern
value = ::Fluent::StringUtil.match_regexp(@null_value_pattern, value) ? nil : value
end
value
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/config/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def self.generate(proxy, conf, logger, plugin_class, stack = [], strict_config_v
end

if section_params[varname].nil?
unless proxy.defaults.has_key?(varname) and proxy.defaults[varname].nil?
unless proxy.defaults.has_key?(varname) && proxy.defaults[varname].nil?
logger.error "config error in:\n#{conf}" if logger
raise ConfigError, "'#{name}' parameter is required but nil is specified"
end
Expand Down
1 change: 0 additions & 1 deletion lib/fluent/load.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'thread'
require 'socket'
require 'fcntl'
require 'time'
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def on_message_complete
# For every incoming request, we check if we have some CORS
# restrictions and allow listed origins through @cors_allow_origins.
unless @cors_allow_origins.nil?
unless @cors_allow_origins.include?('*') or include_cors_allow_origin
unless @cors_allow_origins.include?('*') || include_cors_allow_origin
send_response_and_close(RES_403_STATUS, {'Connection' => 'close'}, "")
return
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_monitor_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def get_monitor_info(pe, opts={})
obj.merge!(pe.statistics['output'] || {})
end

obj['retry'] = get_retry_info(pe.retry) if opts[:with_retry] and pe.instance_variable_defined?(:@retry)
obj['retry'] = get_retry_info(pe.retry) if opts[:with_retry] && pe.instance_variable_defined?(:@retry)

# include all instance variables if :with_debug_info is set
if opts[:with_debug_info]
Expand Down
6 changes: 3 additions & 3 deletions lib/fluent/plugin/out_exec_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def configure(conf)
@added_prefix_string = @add_prefix + '.'
end

@respawns = if @child_respawn.nil? or @child_respawn == 'none' or @child_respawn == '0'
@respawns = if @child_respawn.nil? || (@child_respawn == 'none') || (@child_respawn == '0')
0
elsif @child_respawn == 'inf' or @child_respawn == '-1'
elsif (@child_respawn == 'inf') || (@child_respawn == '-1')
-1
elsif @child_respawn =~ /^\d+$/
@child_respawn.to_i
Expand Down Expand Up @@ -251,7 +251,7 @@ def terminate

def tag_remove_prefix(tag)
if @remove_prefix
if (tag[0, @removed_length] == @removed_prefix_string and tag.length > @removed_length) or tag == @removed_prefix_string
if ((tag[0, @removed_length] == @removed_prefix_string) && (tag.length > @removed_length)) || (tag == @removed_prefix_string)
tag = tag[@removed_length..-1] || ''
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def self.load_config(path, params = {})
config_mtime = File.mtime(path)

# reuse previous config if last load time is within 5 seconds and mtime of the config file is not changed
if Time.now - Time.at(pre_loadtime) < 5 and config_mtime == pre_config_mtime
if (Time.now - Time.at(pre_loadtime) < 5) && (config_mtime == pre_config_mtime)
return params['pre_conf']
end

Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_in_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def create_driver(conf)
assert{ d.events.length > 0 }
d.events.each do |event|
assert_equal 'test', event[0]
assert_match /LoadError/, event[2]['message']
assert_match(/LoadError/, event[2]['message'])
end
end
end