• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shogi-server source


Commit MetaInfo

Revision9c4be91e5120e8fd4c5aa2e3def7bad24fea03cb (tree)
Time2016-04-03 18:55:16
AuthorDaigo Moriwaki <daigo@debi...>
CommiterDaigo Moriwaki

Log Message

Fix some lint warnings

Change Summary

Incremental Difference

--- a/changelog
+++ b/changelog
@@ -20,6 +20,7 @@
2020 - Kifu files can include the following comment for Fischer Time
2121 Control:
2222 - "'Increment:<n>"
23+ * [shogi-server] Fix some lint warnings.
2324
2425 2015-12-13 Daigo Moriwaki <daigo at debian dot org>
2526
--- a/shogi_server/command.rb
+++ b/shogi_server/command.rb
@@ -552,7 +552,7 @@ module ShogiServer
552552 board = Board.new
553553 begin
554554 board.set_from_moves(moves_array)
555- rescue => err
555+ rescue
556556 # it will never happen since moves have already been checked
557557 log_error "Failed to set up a buoy game: #{moves}"
558558 return :continue
@@ -775,7 +775,7 @@ module ShogiServer
775775 # found two players: p1 and p2
776776 log_info("Starting a buoy game: %s with %s and %s" % [@game_name, p1.name, p2.name])
777777 buoy.decrement_count(buoy_game)
778- game = Game::new(@game_name, p1, p2, board)
778+ Game::new(@game_name, p1, p2, board)
779779 return :continue
780780
781781 rescue WrongMoves => e
--- a/shogi_server/game.rb
+++ b/shogi_server/game.rb
@@ -267,6 +267,8 @@ class Game
267267 return false # time isn't expired. players aren't swapped. continue game
268268 else
269269 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))
270272 move_status = @board.handle_one_move(str, @sente == @current_player)
271273 # log_debug("move_status: %s for %s's %s" % [move_status, @sente == @current_player ? "BLACK" : "WHITE", str])
272274
--- a/shogi_server/league/floodgate.rb
+++ b/shogi_server/league/floodgate.rb
@@ -388,12 +388,12 @@ class League
388388 @@mutex.synchronize do
389389 records = @records.reverse
390390 end
391- rc = records.find do |rc|
391+ ret = records.find do |rc|
392392 rc[:winner] &&
393393 rc[:loser] &&
394394 (rc[:black] == player_id || rc[:white] == player_id)
395395 end
396- return rc
396+ return ret
397397 end
398398
399399 def win_games(player_id)
@@ -401,10 +401,10 @@ class League
401401 @@mutex.synchronize do
402402 records = @records.reverse
403403 end
404- rc = records.find_all do |rc|
404+ ret = records.find_all do |rc|
405405 rc[:winner] == player_id && rc[:loser]
406406 end
407- return rc
407+ return ret
408408 end
409409
410410 def loss_games(player_id)
@@ -412,10 +412,10 @@ class League
412412 @@mutex.synchronize do
413413 records = @records.reverse
414414 end
415- rc = records.find_all do |rc|
415+ ret = records.find_all do |rc|
416416 rc[:winner] && rc[:loser] == player_id
417417 end
418- return rc
418+ return ret
419419 end
420420 end # class History
421421
--- a/shogi_server/league/floodgate_thread.rb
+++ b/shogi_server/league/floodgate_thread.rb
@@ -79,6 +79,7 @@ module ShogiServer
7979 {:game_name => prev.game_name, :next_time => prev.next_time,
8080 :pairing_factory => prev.pairing_factory, :sacrifice => prev.sacrifice,
8181 :max_moves => prev.max_moves, :least_time_per_move => prev.least_time_per_move})
82+ floodgate
8283 end
8384 floodgate_reload_log(leagues)
8485 return leagues
@@ -100,12 +101,12 @@ module ShogiServer
100101 floodgate = next_league(leagues)
101102 next if wait_next_floodgate(floodgate)
102103
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
107108 end
108- floodgate
109+ fg
109110 end
110111
111112 reload_shogi_server
--- a/shogi_server/login.rb
+++ b/shogi_server/login.rb
@@ -87,7 +87,7 @@ class Login
8787 end
8888
8989 def Login.factory(str, player)
90- (login, player.name, password, ext) = str.chomp.split
90+ (_, player.name, password, ext) = str.chomp.split
9191 if ext
9292 return Loginx1.new(player, password)
9393 else
--- a/test/TC_command.rb
+++ b/test/TC_command.rb
@@ -287,29 +287,29 @@ class TestFactoryMethod < Test::Unit::TestCase
287287 cmd = ShogiServer::Command.factory("should_be_error", @p)
288288 assert_instance_of(ShogiServer::ErrorCommand, cmd)
289289 cmd.call
290- assert_match /unknown command: should_be_error/, cmd.msg
290+ assert_match(/unknown command: should_be_error/, cmd.msg)
291291 end
292292
293293 def test_error_login
294294 cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p)
295295 assert_instance_of(ShogiServer::ErrorCommand, cmd)
296296 cmd.call
297- assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
297+ assert_no_match( /unknown command: LOGIN hoge foo/, cmd.msg)
298298
299299 cmd = ShogiServer::Command.factory("LOGin hoge foo", @p)
300300 assert_instance_of(ShogiServer::ErrorCommand, cmd)
301301 cmd.call
302- assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
302+ assert_no_match(/unknown command: LOGIN hoge foo/, cmd.msg)
303303
304304 cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p)
305305 assert_instance_of(ShogiServer::ErrorCommand, cmd)
306306 cmd.call
307- assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
307+ assert_no_match(/unknown command: LOGIN hoge foo/, cmd.msg)
308308
309309 cmd = ShogiServer::Command.factory("LOGINhoge foo", @p)
310310 assert_instance_of(ShogiServer::ErrorCommand, cmd)
311311 cmd.call
312- assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
312+ assert_no_match(/unknown command: LOGIN hoge foo/, cmd.msg)
313313 end
314314 end
315315