diff --git a/lib/fluent/command/ctl.rb b/lib/fluent/command/ctl.rb index a042c989e2..656d0008da 100644 --- a/lib/fluent/command/ctl.rb +++ b/lib/fluent/command/ctl.rb @@ -146,7 +146,7 @@ def call_windows_event(command, pid_or_svcname) event = Win32::Event.open("#{prefix}#{suffix}") event.set event.close - rescue Errno::ENOENT => e + rescue Errno::ENOENT puts "Error: Cannot find the fluentd process with the event name: \"#{prefix}\"" end end diff --git a/lib/fluent/config/literal_parser.rb b/lib/fluent/config/literal_parser.rb index ce9307b3ce..5664986481 100644 --- a/lib/fluent/config/literal_parser.rb +++ b/lib/fluent/config/literal_parser.rb @@ -191,9 +191,9 @@ def eval_embedded_code(code) EOM begin @eval_context.instance_eval(code) - rescue SetNil => e + rescue SetNil nil - rescue SetDefault => e + rescue SetDefault :default end end diff --git a/lib/fluent/plugin/file_wrapper.rb b/lib/fluent/plugin/file_wrapper.rb index c0ce2315a5..57d6b4949d 100644 --- a/lib/fluent/plugin/file_wrapper.rb +++ b/lib/fluent/plugin/file_wrapper.rb @@ -106,7 +106,7 @@ def initialize(path, mode='r', sharemode=FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_S @mode = mode - access, creationdisposition, seektoend = case mode.delete('b') + access, creationdisposition, _seektoend = case mode.delete('b') when "r" ; [FILE_GENERIC_READ , OPEN_EXISTING, false] when "r+"; [FILE_GENERIC_READ | FILE_GENERIC_WRITE, OPEN_ALWAYS , false] when "w" ; [FILE_GENERIC_WRITE , CREATE_ALWAYS, false] diff --git a/lib/fluent/plugin/parser_syslog.rb b/lib/fluent/plugin/parser_syslog.rb index 6b89596450..acf2cbfa71 100644 --- a/lib/fluent/plugin/parser_syslog.rb +++ b/lib/fluent/plugin/parser_syslog.rb @@ -484,7 +484,7 @@ def parse_rfc5424(text, &block) time = begin @time_parser_rfc5424.parse(time_str) - rescue Fluent::TimeParser::TimeParseError => e + rescue Fluent::TimeParser::TimeParseError @time_parser_rfc5424_without_subseconds.parse(time_str) end record['time'] = time_str if @keep_time_key diff --git a/test/command/test_ctl.rb b/test/command/test_ctl.rb index 4ab43a0d7a..a29ff62308 100644 --- a/test/command/test_ctl.rb +++ b/test/command/test_ctl.rb @@ -7,7 +7,6 @@ class TestFluentdCtl < ::Test::Unit::TestCase def assert_win32_event(event_name, command, pid_or_svcname) - command, event_suffix = data event = Win32::Event.new(event_name) ipc = Win32::Ipc.new(event.handle) ret = Win32::Ipc::TIMEOUT diff --git a/test/config/test_system_config.rb b/test/config/test_system_config.rb index 5dcf0ff0ad..f4240ab30e 100644 --- a/test/config/test_system_config.rb +++ b/test/config/test_system_config.rb @@ -174,7 +174,6 @@ def parse_text(text) EOS - s = FakeSupervisor.new sc = Fluent::SystemConfig.new(conf) assert_equal(3, sc.log.rotate_age) end diff --git a/test/config/test_types.rb b/test/config/test_types.rb index 9d7b9825a9..3a6eb8f4ce 100644 --- a/test/config/test_types.rb +++ b/test/config/test_types.rb @@ -190,7 +190,7 @@ class TestConfigTypes < ::Test::Unit::TestCase data("val" => [:val, 'val'], "v" => [:v, 'v'], "value" => [:value, 'value']) - test 'enum' do |(expected, val, list)| + test 'enum' do |(expected, val)| assert_equal expected, Config::ENUM_TYPE.call(val, {list: [:val, :value, :v]}) end diff --git a/test/plugin/in_tail/test_io_handler.rb b/test/plugin/in_tail/test_io_handler.rb index d9a18a1c94..f8704b652f 100644 --- a/test/plugin/in_tail/test_io_handler.rb +++ b/test/plugin/in_tail/test_io_handler.rb @@ -107,6 +107,7 @@ class IntailIOHandlerTest < Test::Unit::TestCase end r.on_notify + assert_equal text.bytesize, update_pos assert_equal 8, returned_lines[0].size end @@ -133,6 +134,7 @@ class IntailIOHandlerTest < Test::Unit::TestCase end r.on_notify + assert_equal text.bytesize, update_pos assert_equal 5, returned_lines[0].size assert_equal 3, returned_lines[1].size end diff --git a/test/plugin/in_tail/test_position_file.rb b/test/plugin/in_tail/test_position_file.rb index 1acbd67b4b..9ccb772627 100644 --- a/test/plugin/in_tail/test_position_file.rb +++ b/test/plugin/in_tail/test_position_file.rb @@ -40,10 +40,6 @@ def follow_inodes_block test '.load' do write_data(@file, TEST_CONTENT) - paths = { - "valid_path" => Fluent::Plugin::TailInput::TargetInfo.new("valid_path", 1), - "inode23bit" => Fluent::Plugin::TailInput::TargetInfo.new("inode23bit", 2), - } Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log}) @file.seek(0) @@ -146,11 +142,6 @@ def follow_inodes_block sub_test_case '#load' do test 'compact invalid and convert 32 bit inode value' do write_data(@file, TEST_CONTENT) - invalid_path = "invalidpath100000000000000000000000000000000" - paths = TEST_CONTENT_PATHS.merge({ - invalid_path => Fluent::Plugin::TailInput::TargetInfo.new(invalid_path, 0), - "unwatched" => Fluent::Plugin::TailInput::TargetInfo.new("unwatched", 0), - }) Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log}) @file.seek(0) diff --git a/test/plugin/test_in_syslog.rb b/test/plugin/test_in_syslog.rb index 02c7ab1b2d..f715e1fef9 100755 --- a/test/plugin/test_in_syslog.rb +++ b/test/plugin/test_in_syslog.rb @@ -497,7 +497,7 @@ def test_send_keepalive_packet_can_be_enabled def test_send_keepalive_packet_can_not_be_enabled_for_udp assert_raise(Fluent::ConfigError) do - d = create_driver(ipv4_config + %[ + create_driver(ipv4_config + %[ send_keepalive_packet true ]) end diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index c96e72f558..eb8ebddf36 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -152,13 +152,13 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true) sub_test_case "configure" do test "plain single line" do d = create_driver - assert_equal ["#{TMP_DIR}/tail.txt"], d.instance.paths - assert_equal "t1", d.instance.tag - assert_equal 2, d.instance.rotate_wait - assert_equal "#{TMP_DIR}/tail.pos", d.instance.pos_file - assert_equal 1000, d.instance.read_lines_limit - assert_equal -1, d.instance.read_bytes_limit_per_second - assert_equal false, d.instance.ignore_repeated_permission_error + assert_equal(["#{TMP_DIR}/tail.txt"], d.instance.paths) + assert_equal("t1", d.instance.tag) + assert_equal(2, d.instance.rotate_wait) + assert_equal("#{TMP_DIR}/tail.pos", d.instance.pos_file) + assert_equal(1000, d.instance.read_lines_limit) + assert_equal(-1, d.instance.read_bytes_limit_per_second) + assert_equal(false, d.instance.ignore_repeated_permission_error) assert_nothing_raised do d.instance.have_read_capability? end @@ -175,13 +175,13 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true) test "multi paths with path_delimiter" do c = config_element("ROOT", "", { "path" => "tail.txt|test2|tmp,dev", "tag" => "t1", "path_delimiter" => "|" }) d = create_driver(c + PARSE_SINGLE_LINE_CONFIG, false) - assert_equal ["tail.txt", "test2", "tmp,dev"], d.instance.paths + assert_equal(["tail.txt", "test2", "tmp,dev"], d.instance.paths) end test "multi paths with same path configured twice" do c = config_element("ROOT", "", { "path" => "test1.txt,test2.txt,test1.txt", "tag" => "t1", "path_delimiter" => "," }) d = create_driver(c + PARSE_SINGLE_LINE_CONFIG, false) - assert_equal ["test2.txt","test1.txt"].sort, d.instance.paths.sort + assert_equal(["test2.txt","test1.txt"].sort, d.instance.paths.sort) end test "multi paths with invaid path_delimiter" do @@ -223,7 +223,7 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true) test "valid" do conf = SINGLE_LINE_CONFIG + config_element("", "", { "encoding" => "utf-8" }) d = create_driver(conf) - assert_equal Encoding::UTF_8, d.instance.encoding + assert_equal(Encoding::UTF_8, d.instance.encoding) end test "invalid" do @@ -1150,7 +1150,7 @@ def test_multiline_with_flush_interval(data) config = data + config_element("", "", { "multiline_flush_interval" => "2s" }) d = create_driver(config) - assert_equal 2, d.instance.multiline_flush_interval + assert_equal(2, d.instance.multiline_flush_interval) d.run(expect_emits: 1) do File.open("#{TMP_DIR}/tail.txt", "ab") { |f| @@ -1375,13 +1375,13 @@ def test_expand_paths plugin = create_driver(EX_CONFIG, false).instance flexstub(Time) do |timeclass| timeclass.should_receive(:now).with_no_args.and_return(Time.new(2010, 1, 2, 3, 4, 5)) - assert_equal ex_paths, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path } + assert_equal(ex_paths, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path }) end # Test exclusion exclude_config = EX_CONFIG + config_element("", "", { "exclude_path" => %Q(["#{ex_paths.last.path}"]) }) plugin = create_driver(exclude_config, false).instance - assert_equal ex_paths - [ex_paths.last], plugin.expand_paths.values.sort_by { |path_ino| path_ino.path } + assert_equal(ex_paths - [ex_paths.last], plugin.expand_paths.values.sort_by { |path_ino| path_ino.path }) end def test_expand_paths_with_duplicate_configuration @@ -1392,7 +1392,7 @@ def test_expand_paths_with_duplicate_configuration duplicate_config = EX_CONFIG.dup duplicate_config["path"]="test/plugin/data/log/**/*.log, test/plugin/data/log/**/*.log" plugin = create_driver(EX_CONFIG, false).instance - assert_equal expanded_paths, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path } + assert_equal(expanded_paths, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path }) end def test_expand_paths_with_timezone @@ -1414,8 +1414,8 @@ def test_expand_paths_with_timezone # env : 2010-01-01 19:04:05 (UTC), tail path : 2010-01-02 03:04:05 (Asia/Taipei) timeclass.should_receive(:now).with_no_args.and_return(Time.new(2010, 1, 1, 19, 4, 5)) - assert_equal ex_paths, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path } - assert_equal ex_paths - [ex_paths.first], exclude_plugin.expand_paths.values.sort_by { |path_ino| path_ino.path } + assert_equal(ex_paths, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path }) + assert_equal(ex_paths - [ex_paths.first], exclude_plugin.expand_paths.values.sort_by { |path_ino| path_ino.path }) end end end @@ -1437,7 +1437,7 @@ def test_log_file_without_extension }) plugin = create_driver(config, false).instance - assert_equal expected_files, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path } + assert_equal(expected_files, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path }) end def test_unwatched_files_should_be_removed @@ -1459,7 +1459,7 @@ def test_unwatched_files_should_be_removed waiting(20) { sleep 0.1 until Dir.glob("#{TMP_DIR}/*.txt").size == 0 } # Ensure file is deleted on Windows waiting(5) { sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size <= 0 } - assert_equal 0, d.instance.instance_variable_get(:@tails).keys.size + assert_equal(0, d.instance.instance_variable_get(:@tails).keys.size) d.instance_shutdown end @@ -1511,8 +1511,8 @@ def capability_enabled? "rotate_wait" => "2s" }) + PARSE_SINGLE_LINE_CONFIG, false) - assert_equal readable_paths, d.instance.expand_paths.length - assert_equal result, d.instance.have_read_capability? + assert_equal(readable_paths, d.instance.expand_paths.length) + assert_equal(result, d.instance.have_read_capability?) end end @@ -1530,7 +1530,7 @@ def test_pos_file_dir_creation d = create_driver(config, false) d.run assert_path_exist("#{TMP_DIR}/pos") - assert_equal '755', File.stat("#{TMP_DIR}/pos").mode.to_s(8)[-3, 3] + assert_equal('755', File.stat("#{TMP_DIR}/pos").mode.to_s(8)[-3, 3]) ensure cleanup_directory(TMP_DIR) end @@ -1554,9 +1554,9 @@ def test_pos_file_dir_creation_with_system_dir_permission assert_path_exist("#{TMP_DIR}/pos") if Fluent.windows? - assert_equal '755', File.stat("#{TMP_DIR}/pos").mode.to_s(8)[-3, 3] + assert_equal('755', File.stat("#{TMP_DIR}/pos").mode.to_s(8)[-3, 3]) else - assert_equal '744', File.stat("#{TMP_DIR}/pos").mode.to_s(8)[-3, 3] + assert_equal('744', File.stat("#{TMP_DIR}/pos").mode.to_s(8)[-3, 3]) end ensure cleanup_directory(TMP_DIR) @@ -2246,7 +2246,7 @@ def test_limit_recently_modified Timecop.freeze(now) do plugin = create_driver(config, false).instance - assert_equal expected_files, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path } + assert_equal(expected_files, plugin.expand_paths.values.sort_by { |path_ino| path_ino.path }) end end @@ -2259,7 +2259,7 @@ def test_skip_refresh_on_startup }) d = create_driver(config) d.run(shutdown: false) {} - assert_equal 0, d.instance.instance_variable_get(:@tails).keys.size + assert_equal(0, d.instance.instance_variable_get(:@tails).keys.size) # detect a file at first execution of in_tail_refresh_watchers timer waiting(5) { sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size == 1 } d.instance_shutdown @@ -2333,7 +2333,6 @@ def test_EACCES end def test_shutdown_timeout - path = "#{TMP_DIR}/tail.txt" File.open("#{TMP_DIR}/tail.txt", "wb") do |f| (1024 * 1024 * 5).times do f.puts "{\"test\":\"fizzbuzz\"}" diff --git a/test/plugin/test_parser_syslog.rb b/test/plugin/test_parser_syslog.rb index 0058247eb9..64161f48f7 100644 --- a/test/plugin/test_parser_syslog.rb +++ b/test/plugin/test_parser_syslog.rb @@ -644,7 +644,7 @@ def test_parser_type_method(engine) data('regexp' => :regexp, 'string' => :string) def test_parser_engine(engine) - d = @parser.configure({'parser_engine' => engine.to_s}) + @parser.configure({'parser_engine' => engine.to_s}) assert_equal(engine, @parser.instance.parser_engine) end end diff --git a/test/plugin_helper/test_cert_option.rb b/test/plugin_helper/test_cert_option.rb index 3464d37dce..df3c915cbe 100644 --- a/test/plugin_helper/test_cert_option.rb +++ b/test/plugin_helper/test_cert_option.rb @@ -19,7 +19,7 @@ class Dummy < Fluent::Plugin::TestBase test 'raise an error for broken certificates_from_file file' do d = Dummy.new assert_raise Fluent::ConfigError do - certs = d.cert_option_certificates_from_file("test/plugin_helper/data/cert/empty.pem") + d.cert_option_certificates_from_file("test/plugin_helper/data/cert/empty.pem") end end end