1. 這篇文章部分內容擷錄於 Top 8 tools for Ruby on Rails code optimization and cleanup - by Damir Svrtan,它對於每個工具都有簡短的描述與說明,有興趣可以過去看看。
2. 下面提到的gem,在Gemfile中應該要放在development的group之下,因為production應該不會跑這些工具。
幫你列出無用的routes。
Unused routes (3):
users/omniauth_callbacks#(?-mix:facebook)
courses#show
my/student/courses#index
Unreachable action methods (3):
grape_swagger_rails/application#index
emergency#show
devise#_prefixes
profiling每一頁花的時間。
if Rails.env == 'development'
require 'rack-mini-profiler'
# initialization is skipped so trigger it
Rack::MiniProfilerRails.initialize!(Rails.application)
end
找出 N+1 query。
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.rails_logger = true
end
檢查rails是否有安全性漏洞。
-o 檔名
可以將結果輸出至檔案。檢查rails專案中是否有違反best practices。
檢查rails專案中是否有違反ruby style guide。
使用reek, flay, flog檢查rails專案中是否有違反ruby style guide,重點是報表還蠻好看的。
在chrome的developer tool加上rails的分析工具。