shogi-server source
Revision | 9c4be91e5120e8fd4c5aa2e3def7bad24fea03cb (tree) |
---|---|
Time | 2016-04-03 18:55:16 |
Author | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
Fix some lint warnings
@@ -20,6 +20,7 @@ | ||
20 | 20 | - Kifu files can include the following comment for Fischer Time |
21 | 21 | Control: |
22 | 22 | - "'Increment:<n>" |
23 | + * [shogi-server] Fix some lint warnings. | |
23 | 24 | |
24 | 25 | 2015-12-13 Daigo Moriwaki <daigo at debian dot org> |
25 | 26 |
@@ -552,7 +552,7 @@ module ShogiServer | ||
552 | 552 | board = Board.new |
553 | 553 | begin |
554 | 554 | board.set_from_moves(moves_array) |
555 | - rescue => err | |
555 | + rescue | |
556 | 556 | # it will never happen since moves have already been checked |
557 | 557 | log_error "Failed to set up a buoy game: #{moves}" |
558 | 558 | return :continue |
@@ -775,7 +775,7 @@ module ShogiServer | ||
775 | 775 | # found two players: p1 and p2 |
776 | 776 | log_info("Starting a buoy game: %s with %s and %s" % [@game_name, p1.name, p2.name]) |
777 | 777 | buoy.decrement_count(buoy_game) |
778 | - game = Game::new(@game_name, p1, p2, board) | |
778 | + Game::new(@game_name, p1, p2, board) | |
779 | 779 | return :continue |
780 | 780 | |
781 | 781 | rescue WrongMoves => e |
@@ -267,6 +267,8 @@ class Game | ||
267 | 267 | return false # time isn't expired. players aren't swapped. continue game |
268 | 268 | else |
269 | 269 | t = @time_clock.process_time(@current_player, @start_time, @end_time) |
270 | + log_info(sprintf("+++ DEBUG %s consumed %d sec. remain %d sec", | |
271 | + @current_player.name, t, @current_player.mytime)) | |
270 | 272 | move_status = @board.handle_one_move(str, @sente == @current_player) |
271 | 273 | # log_debug("move_status: %s for %s's %s" % [move_status, @sente == @current_player ? "BLACK" : "WHITE", str]) |
272 | 274 |
@@ -388,12 +388,12 @@ class League | ||
388 | 388 | @@mutex.synchronize do |
389 | 389 | records = @records.reverse |
390 | 390 | end |
391 | - rc = records.find do |rc| | |
391 | + ret = records.find do |rc| | |
392 | 392 | rc[:winner] && |
393 | 393 | rc[:loser] && |
394 | 394 | (rc[:black] == player_id || rc[:white] == player_id) |
395 | 395 | end |
396 | - return rc | |
396 | + return ret | |
397 | 397 | end |
398 | 398 | |
399 | 399 | def win_games(player_id) |
@@ -401,10 +401,10 @@ class League | ||
401 | 401 | @@mutex.synchronize do |
402 | 402 | records = @records.reverse |
403 | 403 | end |
404 | - rc = records.find_all do |rc| | |
404 | + ret = records.find_all do |rc| | |
405 | 405 | rc[:winner] == player_id && rc[:loser] |
406 | 406 | end |
407 | - return rc | |
407 | + return ret | |
408 | 408 | end |
409 | 409 | |
410 | 410 | def loss_games(player_id) |
@@ -412,10 +412,10 @@ class League | ||
412 | 412 | @@mutex.synchronize do |
413 | 413 | records = @records.reverse |
414 | 414 | end |
415 | - rc = records.find_all do |rc| | |
415 | + ret = records.find_all do |rc| | |
416 | 416 | rc[:winner] && rc[:loser] == player_id |
417 | 417 | end |
418 | - return rc | |
418 | + return ret | |
419 | 419 | end |
420 | 420 | end # class History |
421 | 421 |
@@ -79,6 +79,7 @@ module ShogiServer | ||
79 | 79 | {:game_name => prev.game_name, :next_time => prev.next_time, |
80 | 80 | :pairing_factory => prev.pairing_factory, :sacrifice => prev.sacrifice, |
81 | 81 | :max_moves => prev.max_moves, :least_time_per_move => prev.least_time_per_move}) |
82 | + floodgate | |
82 | 83 | end |
83 | 84 | floodgate_reload_log(leagues) |
84 | 85 | return leagues |
@@ -100,12 +101,12 @@ module ShogiServer | ||
100 | 101 | floodgate = next_league(leagues) |
101 | 102 | next if wait_next_floodgate(floodgate) |
102 | 103 | |
103 | - next_instances = leagues.collect do |floodgate| | |
104 | - unless (floodgate.next_time - Time.now) > 0 | |
105 | - start_games(floodgate) | |
106 | - floodgate.charge # updates next_time | |
104 | + next_instances = leagues.collect do |fg| | |
105 | + unless (fg.next_time - Time.now) > 0 | |
106 | + start_games(fg) | |
107 | + fg.charge # updates next_time | |
107 | 108 | end |
108 | - floodgate | |
109 | + fg | |
109 | 110 | end |
110 | 111 | |
111 | 112 | reload_shogi_server |
@@ -87,7 +87,7 @@ class Login | ||
87 | 87 | end |
88 | 88 | |
89 | 89 | def Login.factory(str, player) |
90 | - (login, player.name, password, ext) = str.chomp.split | |
90 | + (_, player.name, password, ext) = str.chomp.split | |
91 | 91 | if ext |
92 | 92 | return Loginx1.new(player, password) |
93 | 93 | else |
@@ -287,29 +287,29 @@ class TestFactoryMethod < Test::Unit::TestCase | ||
287 | 287 | cmd = ShogiServer::Command.factory("should_be_error", @p) |
288 | 288 | assert_instance_of(ShogiServer::ErrorCommand, cmd) |
289 | 289 | cmd.call |
290 | - assert_match /unknown command: should_be_error/, cmd.msg | |
290 | + assert_match(/unknown command: should_be_error/, cmd.msg) | |
291 | 291 | end |
292 | 292 | |
293 | 293 | def test_error_login |
294 | 294 | cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p) |
295 | 295 | assert_instance_of(ShogiServer::ErrorCommand, cmd) |
296 | 296 | cmd.call |
297 | - assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg | |
297 | + assert_no_match( /unknown command: LOGIN hoge foo/, cmd.msg) | |
298 | 298 | |
299 | 299 | cmd = ShogiServer::Command.factory("LOGin hoge foo", @p) |
300 | 300 | assert_instance_of(ShogiServer::ErrorCommand, cmd) |
301 | 301 | cmd.call |
302 | - assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg | |
302 | + assert_no_match(/unknown command: LOGIN hoge foo/, cmd.msg) | |
303 | 303 | |
304 | 304 | cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p) |
305 | 305 | assert_instance_of(ShogiServer::ErrorCommand, cmd) |
306 | 306 | cmd.call |
307 | - assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg | |
307 | + assert_no_match(/unknown command: LOGIN hoge foo/, cmd.msg) | |
308 | 308 | |
309 | 309 | cmd = ShogiServer::Command.factory("LOGINhoge foo", @p) |
310 | 310 | assert_instance_of(ShogiServer::ErrorCommand, cmd) |
311 | 311 | cmd.call |
312 | - assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg | |
312 | + assert_no_match(/unknown command: LOGIN hoge foo/, cmd.msg) | |
313 | 313 | end |
314 | 314 | end |
315 | 315 |