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

Suppress a lot of warnings #852

Merged
merged 1 commit into from
Mar 24, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/fluent/config/configure_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def initialize(name, opts = {})
@defaults = {}
@descriptions = {}
@sections = {}
@current_description = nil
end

def required?
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/config/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def secret_param?(key)

param_key = key.to_sym
@corresponding_proxies.each { |proxy|
block, opts = proxy.params[param_key]
_block, opts = proxy.params[param_key]
if opts && opts.has_key?(:secret)
return opts[:secret]
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/config/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def process_include(attrs, elems, uri, allow_include = true)
pattern = path
end

Dir.glob(pattern).sort.each { |path|
basepath = File.dirname(path)
fname = File.basename(path)
File.open(path) { |f|
Dir.glob(pattern).sort.each { |entry|
basepath = File.dirname(entry)
fname = File.basename(entry)
File.open(entry) { |f|
Parser.new(basepath, f.each_line, fname).parse!(allow_include, nil, attrs, elems)
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/config/v1_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def eval_include(attrs, elems, uri)
pattern = path
end

Dir.glob(pattern).sort.each { |path|
basepath = File.dirname(path)
fname = File.basename(path)
data = File.read(path)
Dir.glob(pattern).sort.each { |entry|
basepath = File.dirname(entry)
fname = File.basename(entry)
data = File.read(entry)
data.force_encoding('UTF-8')
ss = StringScanner.new(data)
V1Parser.new(ss, basepath, fname, @eval_context).parse_element(true, nil, attrs, elems)
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/event_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def match?(tag)

def match(tag)
collector = @match_cache.get(tag) {
c = find(tag) || @default_collector
find(tag) || @default_collector
}
collector
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def initialize(out=STDERR, level=LEVEL_TRACE, opts={})
# Fluent::Engine requires Fluent::Log, so we must take that object lazily
@engine = Fluent.const_get('Engine')

if opts.has_key?(:suppress_repeated_stacktrace)
@suppress_repeated_stacktrace = opts[:suppress_repeated_stacktrace]
end
@suppress_repeated_stacktrace = opts[:suppress_repeated_stacktrace]
end

attr_accessor :out
Expand Down Expand Up @@ -320,7 +318,9 @@ def initialize(logger)
@logger = logger
@level = @logger.level
@depth_offset = 2
@suppress_repeated_stacktrace = logger.instance_variable_get(:@suppress_repeated_stacktrace)
if logger.instance_variable_defined?(:@suppress_repeated_stacktrace)
@suppress_repeated_stacktrace = logger.instance_variable_get(:@suppress_repeated_stacktrace)
end

enable_color @logger.enable_color?
end
Expand Down
20 changes: 14 additions & 6 deletions lib/fluent/mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,18 @@ module HandleTagNameMixin
attr_accessor :remove_tag_prefix, :remove_tag_suffix, :add_tag_prefix, :add_tag_suffix
def configure(conf)
super
if remove_tag_prefix = conf['remove_tag_prefix']
@remove_tag_prefix = Regexp.new('^' + Regexp.escape(remove_tag_prefix))
end

if remove_tag_suffix = conf['remove_tag_suffix']
@remove_tag_suffix = Regexp.new(Regexp.escape(remove_tag_suffix) + '$')
end
@remove_tag_prefix = if conf.has_key?('remove_tag_prefix')
Regexp.new('^' + Regexp.escape(conf['remove_tag_prefix']))
else
nil
end

@remove_tag_suffix = if conf.has_key?('remove_tag_suffix')
Regexp.new(Regexp.escape(conf['remove_tag_suffix']) + '$')
else
nil
end

@add_tag_prefix = conf['add_tag_prefix']
@add_tag_suffix = conf['add_tag_suffix']
Expand All @@ -162,6 +167,8 @@ module SetTimeKeyMixin

def configure(conf)
@include_time_key = false
@localtime = false
@timezone = nil

super

Expand Down Expand Up @@ -257,6 +264,7 @@ def self.included(klass)
def configure(conf)
super

@type_converters = nil
@type_converters = parse_types_parameter unless @types.nil?
end

Expand Down
1 change: 1 addition & 0 deletions lib/fluent/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def initialize
@next_retry_time = 0
@num_errors = 0
@num_errors_lock = Mutex.new
@secondary = nil
@secondary_limit = 8
@emit_count = 0
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def self.lookup(format)
# built-in template
begin
Fluent::Plugin.new_parser(format)
rescue ConfigError => e # keep same error message
rescue ConfigError # keep same error message
raise ConfigError, "Unknown format template '#{format}'"
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def self.register_impl(kind, registry, type, value)
raise Fluent::ConfigError, "Invalid implementation as #{kind} plugin: '#{type}'. It must be a Class, or callable."
end
registry.register(type, value)
$log.trace "registered #{kind} plugin '#{type}'" if $log
$log.trace "registered #{kind} plugin '#{type}'" if defined?($log)
nil
end

Expand Down
9 changes: 5 additions & 4 deletions lib/fluent/plugin/buf_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def initialize
super

@uri_parser = URI::Parser.new
@symlink_path = nil
end

desc 'The path where buffer chunks are stored.'
Expand Down Expand Up @@ -171,15 +172,15 @@ def resume
}

map = {}
maps.sort_by {|(timestamp,chunk)|
maps.sort_by {|(timestamp,_chunk)|
timestamp
}.each {|(timestamp,chunk)|
}.each {|(_timestamp,chunk)|
map[chunk.key] = chunk
}

queue = queues.sort_by {|(timestamp,chunk)|
queue = queues.sort_by {|(timestamp,_chunk)|
timestamp
}.map {|(timestamp,chunk)|
}.map {|(_timestamp,chunk)|
chunk
}

Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/in_dummy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class DummyInput < Input
config_param :dummy, default: [{"message"=>"dummy"}] do |val|
begin
parsed = JSON.parse(val)
rescue JSON::ParserError => e
rescue JSON::ParserError => ex
# Fluent::ConfigParseError, "got incomplete JSON" will be raised
# at literal_parser.rb with --use-v1-config, but I had to
# take care at here for the case of --use-v0-config.
raise Fluent::ConfigError, "#{e.class}: #{e.message}"
raise Fluent::ConfigError, "#{ex.class}: #{ex.message}"
end
dummy = parsed.is_a?(Array) ? parsed : [parsed]
dummy.each_with_index do |e, i|
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/in_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def initialize
def configure(conf)
super

if localtime = conf['localtime']
if conf['localtime']
@localtime = true
elsif utc = conf['utc']
elsif conf['utc']
@localtime = false
end

Expand Down
2 changes: 2 additions & 0 deletions lib/fluent/plugin/in_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def initialize
def configure(conf)
super

@use_default = false

if conf.has_key?('format')
@parser = Plugin.new_parser(conf['format'])
@parser.configure(conf)
Expand Down
16 changes: 8 additions & 8 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,16 @@ def on_rotate(io)
@update_watcher.call(@path, swap_state(@pe))
end
end
end

def swap_state(pe)
# Use MemoryPositionEntry for rotated file temporary
mpe = MemoryPositionEntry.new
mpe.update(pe.read_inode, pe.read_pos)
@pe = mpe
@io_handler.pe = mpe # Don't re-create IOHandler because IOHandler has an internal buffer.
def swap_state(pe)
# Use MemoryPositionEntry for rotated file temporary
mpe = MemoryPositionEntry.new
mpe.update(pe.read_inode, pe.read_pos)
@pe = mpe
@io_handler.pe = mpe # Don't re-create IOHandler because IOHandler has an internal buffer.

pe # This pe will be updated in on_rotate after TailWatcher is initialized
end
pe # This pe will be updated in on_rotate after TailWatcher is initialized
end

class TimerWatcher < Coolio::TimerWatcher
Expand Down
4 changes: 4 additions & 0 deletions lib/fluent/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ module DetachProcessMixin
def configure(conf)
super

@detach_process = nil

if detach_process = conf['detach_process']
b3v = Config.bool_value(detach_process)
case b3v
Expand Down Expand Up @@ -461,6 +463,8 @@ def initialize
def configure(conf)
super

@detach_process = nil

if detach_process = conf['detach_process']
b3v = Config.bool_value(detach_process)
case b3v
Expand Down
1 change: 1 addition & 0 deletions lib/fluent/root_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def initialize(system_config = SystemConfig.new)
@started_inputs = []
@suppress_emit_error_log_interval = 0
@next_emit_error_log_time = nil
@without_source = false

suppress_interval(system_config.emit_error_log_interval) unless system_config.emit_error_log_interval.nil?
@without_source = system_config.without_source unless system_config.without_source.nil?
Expand Down
16 changes: 8 additions & 8 deletions lib/fluent/test/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ def self.setup
@now = n
}
engine.define_singleton_method(:now) {
@now || super()
}

::Test::Unit::Assertions.module_eval {
def assert_equal_event_time(a, b)
assert_equal(a.sec, b.sec)
assert_equal(a.nsec, b.nsec)
end
@now ||= super()
}

nil
Expand Down Expand Up @@ -131,3 +124,10 @@ def logs
end
end
end

Test::Unit::Assertions.module_eval do
def assert_equal_event_time(a, b)
assert_equal(a.sec, b.sec)
assert_equal(a.nsec, b.nsec)
end
end
2 changes: 1 addition & 1 deletion lib/fluent/test/input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def initialize(klass, &block)
# for checking only the number of emitted records during run
@expected_emits_length = nil
@run_timeout = 5
@run_post_conditions = []
end

def expect_emit(tag, time, record)
Expand Down Expand Up @@ -81,7 +82,6 @@ def records

def register_run_post_condition(&block)
if block
@run_post_conditions ||= []
@run_post_conditions << block
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/test/output_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def run(num_waits = 10, &block)
key = ''
if @instance.respond_to?(:time_slicer)
# this block is only for test_out_file
time, record = @entries.first
time, _record = @entries.first
key = @instance.time_slicer.call(time)
end
chunk = @instance.buffer.new_chunk(key)
Expand Down
2 changes: 1 addition & 1 deletion test/config/test_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def setup
sub_test_case 'with configuration that returns non element on top' do
sub_test_case '.parse' do
test 'does not crash' do
root = Fluent::Config::DSL::Parser.parse(DSL_CONFIG_RETURNS_NON_ELEMENT, 'dsl_config_returns_non_element.rb')
Fluent::Config::DSL::Parser.parse(DSL_CONFIG_RETURNS_NON_ELEMENT, 'dsl_config_returns_non_element.rb')
end
end
end
Expand Down
1 change: 1 addition & 0 deletions test/config/test_system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def initialize
@suppress_config_dump = nil
@suppress_repeated_stacktrace = nil
@without_source = nil
@emit_error_log_interval = nil
end
end

Expand Down
Loading