| 赞 | 72 |
| VIP | |
| 好人卡 | |
| 积分 | 23 |
| 经验 | |
| 最后登录 | 2022-3-9 |
| 在线时间 | 4033 小时 |
…あたしは天
- 梦石
- 0
- 星屑
- 2308
- 在线时间
- 4033 小时
- 注册时间
- 2010-10-4
- 回帖
- 10548
 
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 taroxd 于 2014-11-16 14:21 编辑
Rubycop 是一个可以让强迫症发现 Ruby 代码的不规范之处的东西。
然后我就对着英文的默认脚本扫了一遍(因为如果用中文的,由于注释的原因必定有更多的问题)
扫描结果超过10000行,500KB。现截取 BattleManager 的扫描结果如下:
点击展开/收起
Inspecting 110 files
WCCCCWCCWWWWCWCCCWWWWCCWCCCCCCWWCCCCCWCCCWCCCCCCCCCCCCCCCCCCCCCCCCWCCCWCCCCCCCWCCCCCWCCCCCCCCCCWCWCWCCCCWCCCWC
Offenses:
BattleManager.rb:1:1: C: Use snake_case for source file names.
#==============================================================================
^
BattleManager.rb:1:1: C: Missing space after #.
#==============================================================================
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BattleManager.rb:5:1: C: Missing space after #.
#==============================================================================
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BattleManager.rb:7:1: C: Missing top-level module documentation comment.
module BattleManager
^^^^^^
BattleManager.rb:13:5: C: Do not introduce global variables.
$game_troop.setup(troop_id)
^^^^^^^^^^^
BattleManager.rb:21:3: C: Method has too many lines. [11/10]
def self.init_members
^^^
BattleManager.rb:45:5: C: Do not introduce global variables.
$game_party.rate_preemptive($game_troop.agi)
^^^^^^^^^^^
BattleManager.rb:45:33: C: Do not introduce global variables.
$game_party.rate_preemptive($game_troop.agi)
^^^^^^^^^^^
BattleManager.rb:51:5: C: Do not introduce global variables.
$game_party.rate_surprise($game_troop.agi)
^^^^^^^^^^^
BattleManager.rb:51:31: C: Do not introduce global variables.
$game_party.rate_surprise($game_troop.agi)
^^^^^^^^^^^
BattleManager.rb:64:5: C: Do not introduce global variables.
$game_system.battle_bgm.play
^^^^^^^^^^^^
BattleManager.rb:71:5: C: Do not introduce global variables.
$game_system.battle_end_me.play
^^^^^^^^^^^^
BattleManager.rb:77:28: C: Do not introduce global variables.
@map_bgm.replay unless $BTEST
^^^^^^
BattleManager.rb:78:28: C: Do not introduce global variables.
@map_bgs.replay unless $BTEST
^^^^^^
BattleManager.rb:84:33: C: Do not introduce global variables.
@escape_ratio = 1.5 - 1.0 * $game_troop.agi / $game_party.agi
^^^^^^^^^^^
BattleManager.rb:84:51: C: Do not introduce global variables.
@escape_ratio = 1.5 - 1.0 * $game_troop.agi / $game_party.agi
^^^^^^^^^^^
BattleManager.rb:107:3: C: Use attr_reader to define trivial reader methods.
def self.can_escape?
^^^
BattleManager.rb:114:25: C: Do not introduce global variables.
@actor_index >= 0 ? $game_party.members[@actor_index] : nil
^^^^^^^^^^^
BattleManager.rb:129:41: C: Do not introduce global variables.
return false if @actor_index >= $game_party.members.size
^^^^^^^^^^^
BattleManager.rb:131:9: W: Use Kernel#loop with break rather than begin/end/until(or while).
end until actor.inputable?
^^^^^
BattleManager.rb:132:5: C: Redundant return detected.
return true
^^^^^^
BattleManager.rb:143:9: W: Use Kernel#loop with break rather than begin/end/until(or while).
end until actor.inputable?
^^^^^
BattleManager.rb:144:5: C: Redundant return detected.
return true
^^^^^^
BattleManager.rb:149:3: C: Use attr_writer to define trivial writer methods.
def self.event_proc=(proc)
^^^
BattleManager.rb:155:3: C: Use attr_writer to define trivial writer methods.
def self.method_wait_for_message=(method)
^^^
BattleManager.rb:167:3: C: Method has too many lines. [12/10]
def self.battle_start
^^^
BattleManager.rb:168:5: C: Do not introduce global variables.
$game_system.battle_count += 1
^^^^^^^^^^^^
BattleManager.rb:169:5: C: Do not introduce global variables.
$game_party.on_battle_start
^^^^^^^^^^^
BattleManager.rb:170:5: C: Do not introduce global variables.
$game_troop.on_battle_start
^^^^^^^^^^^
BattleManager.rb:171:5: C: Do not introduce global variables.
$game_troop.enemy_names.each do |name|
^^^^^^^^^^^
BattleManager.rb:172:7: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Emerge, name))
^^^^^^^^^^^^^
BattleManager.rb:172:25: C: Favor format over sprintf.
$game_message.add(sprintf(Vocab::Emerge, name))
^^^^^^^
BattleManager.rb:175:7: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
^^^^^^^^^^^^^
BattleManager.rb:175:25: C: Favor format over sprintf.
$game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
^^^^^^^
BattleManager.rb:175:52: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
^^^^^^^^^^^
BattleManager.rb:177:7: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Surprise, $game_party.name))
^^^^^^^^^^^^^
BattleManager.rb:177:25: C: Favor format over sprintf.
$game_message.add(sprintf(Vocab::Surprise, $game_party.name))
^^^^^^^
BattleManager.rb:177:50: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Surprise, $game_party.name))
^^^^^^^^^^^
BattleManager.rb:192:33: C: Do not introduce global variables.
return process_abort if $game_party.members.empty?
^^^^^^^^^^^
BattleManager.rb:193:33: C: Do not introduce global variables.
return process_defeat if $game_party.all_dead?
^^^^^^^^^^^
BattleManager.rb:194:33: C: Do not introduce global variables.
return process_victory if $game_troop.all_dead?
^^^^^^^^^^^
BattleManager.rb:197:5: C: Redundant return detected.
return false
^^^^^^
BattleManager.rb:205:5: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Victory, $game_party.name))
^^^^^^^^^^^^^
BattleManager.rb:205:23: C: Favor format over sprintf.
$game_message.add(sprintf(Vocab::Victory, $game_party.name))
^^^^^^^
BattleManager.rb:205:47: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Victory, $game_party.name))
^^^^^^^^^^^
BattleManager.rb:212:5: C: Redundant return detected.
return true
^^^^^^
BattleManager.rb:217:3: C: Method has too many lines. [12/10]
def self.process_escape
^^^
BattleManager.rb:218:5: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
^^^^^^^^^^^^^
BattleManager.rb:218:23: C: Favor format over sprintf.
$game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
^^^^^^^
BattleManager.rb:218:51: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
^^^^^^^^^^^
BattleManager.rb:225:7: C: Do not introduce global variables.
$game_message.add('\.' + Vocab::EscapeFailure)
^^^^^^^^^^^^^
BattleManager.rb:226:7: C: Do not introduce global variables.
$game_party.clear_actions
^^^^^^^^^^^
BattleManager.rb:229:5: C: Redundant return detected.
return success
^^^^^^
BattleManager.rb:238:5: C: Redundant return detected.
return true
^^^^^^
BattleManager.rb:243:3: C: Method has too many lines. [11/10]
def self.process_defeat
^^^
BattleManager.rb:244:5: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
^^^^^^^^^^^^^
BattleManager.rb:244:23: C: Favor format over sprintf.
$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
^^^^^^^
BattleManager.rb:244:46: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
^^^^^^^^^^^
BattleManager.rb:254:5: C: Redundant return detected.
return true
^^^^^^
BattleManager.rb:260:5: C: Do not introduce global variables.
$game_party.battle_members.each do |actor|
^^^^^^^^^^^
BattleManager.rb:271:5: C: Do not introduce global variables.
$game_party.on_battle_end
^^^^^^^^^^^
BattleManager.rb:272:5: C: Do not introduce global variables.
$game_troop.on_battle_end
^^^^^^^^^^^
BattleManager.rb:273:26: C: Do not introduce global variables.
SceneManager.exit if $BTEST
^^^^^^
BattleManager.rb:281:7: C: Do not introduce global variables.
$game_party.make_actions
^^^^^^^^^^^
BattleManager.rb:282:7: C: Do not introduce global variables.
$game_troop.make_actions
^^^^^^^^^^^
BattleManager.rb:285:5: C: Redundant return detected.
return !@surprise && $game_party.inputable?
^^^^^^
BattleManager.rb:285:26: C: Do not introduce global variables.
return !@surprise && $game_party.inputable?
^^^^^^^^^^^
BattleManager.rb:293:5: C: Do not introduce global variables.
$game_troop.increase_turn
^^^^^^^^^^^
BattleManager.rb:308:8: C: Do not introduce global variables.
if $game_troop.exp_total > 0
^^^^^^^^^^^
BattleManager.rb:309:14: C: Favor format over sprintf.
text = sprintf(Vocab::ObtainExp, $game_troop.exp_total)
^^^^^^^
BattleManager.rb:309:40: C: Do not introduce global variables.
text = sprintf(Vocab::ObtainExp, $game_troop.exp_total)
^^^^^^^^^^^
BattleManager.rb:310:7: C: Do not introduce global variables.
$game_message.add('\.' + text)
^^^^^^^^^^^^^
BattleManager.rb:317:8: C: Do not introduce global variables.
if $game_troop.gold_total > 0
^^^^^^^^^^^
BattleManager.rb:318:14: C: Favor format over sprintf.
text = sprintf(Vocab::ObtainGold, $game_troop.gold_total)
^^^^^^^
BattleManager.rb:318:41: C: Do not introduce global variables.
text = sprintf(Vocab::ObtainGold, $game_troop.gold_total)
^^^^^^^^^^^
BattleManager.rb:319:7: C: Do not introduce global variables.
$game_message.add('\.' + text)
^^^^^^^^^^^^^
BattleManager.rb:320:7: C: Do not introduce global variables.
$game_party.gain_gold($game_troop.gold_total)
^^^^^^^^^^^
BattleManager.rb:320:29: C: Do not introduce global variables.
$game_party.gain_gold($game_troop.gold_total)
^^^^^^^^^^^
BattleManager.rb:328:5: C: Do not introduce global variables.
$game_troop.make_drop_items.each do |item|
^^^^^^^^^^^
BattleManager.rb:329:7: C: Do not introduce global variables.
$game_party.gain_item(item, 1)
^^^^^^^^^^^
BattleManager.rb:330:7: C: Do not introduce global variables.
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
^^^^^^^^^^^^^
BattleManager.rb:330:25: C: Favor format over sprintf.
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
^^^^^^^
BattleManager.rb:338:5: C: Do not introduce global variables.
$game_party.all_members.each do |actor|
^^^^^^^^^^^
BattleManager.rb:339:22: C: Do not introduce global variables.
actor.gain_exp($game_troop.exp_total)
^^^^^^^^^^^
BattleManager.rb:348:25: C: Do not introduce global variables.
@action_battlers += $game_party.members unless @surprise
^^^^^^^^^^^
BattleManager.rb:349:25: C: Do not introduce global variables.
@action_battlers += $game_troop.members unless @preemptive
^^^^^^^^^^^
BattleManager.rb:350:5: C: Pass &:make_speed as an argument to each instead of a block.
@action_battlers.each {|battler| battler.make_speed }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BattleManager.rb:350:27: C: Space between { and | missing.
@action_battlers.each {|battler| battler.make_speed }
^^
BattleManager.rb:351:28: C: Space between { and | missing.
@action_battlers.sort! {|a,b| b.speed - a.speed }
^^
BattleManager.rb:351:31: C: Space missing after comma.
@action_battlers.sort! {|a,b| b.speed - a.speed }
^
BattleManager.rb:369:3: C: Use attr_reader to define trivial reader methods.
def self.action_forced_battler
^^^
完整的扫描结果见附件:
rubycop.rar
(45.23 KB, 下载次数: 34)
注:这只是玩玩,并不是要否定预设脚本什么的
|
评分
-
查看全部评分
|