rails_best_practicesでrailsのコードチェック
rails_best_practicesとは
rails_best_practices is a code metric tool to check the quality of rails codes
コード解析をしてくれるツールのようです。
便利そう。
物は試しということで、インストールして使ってみます。
インストール
gemなのでgem installかGemfileに記述します。
テストで使うのでgroupはtestにしました。
$ vim Gemfile
…
gem "rails_best_practices", :group => :test$ bundle install
実行
コマンドラインから実行します。
bundle exec rails_best_practices .
結果
$ bundle exec rails_best_practices .Source Codes: |================================================================|C:/Users/hogehoge/git/test/app/helpers/con1_helper.rb:1 - remove empty helpersPlease go to http://rails-bestpractices.com to see more useful Rails Best Practices.Found 1 warnings.-----------------------------------
app/helpers/con1_helper.rbは使ってないので消しなさいと出ました。
jenkins上で実行するとこんな感じです。
テストは通ってますが、jenkinsおじさんはお怒りです。
修正
app/helpers/con1_helper.rbを削除して再度コードチェック
$ bundle exec rails_best_practices .
Source Codes: |================================================================|
Please go to http://rails-bestpractices.com to see more useful Rails Best Practices.
No warning found. Cool!
Cool!
jenkinsおじさんもCoolです!
参考資料
The Ruby Toolbox - Code Metrics
railsbp/rails_best_practices · GitHub