Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Rubyのコードの臭い検出ツールReekのカスタム設定をする

alt

Rubyのコードの臭い検出ツールReekのカスタム設定方法について。

サンプル

.reek

.reek で終わるファイルを作成すると、 reek が設定ファイルとして認識します。

---
IrresponsibleModule:
  enabled: false

クラスモジュールがない場合を警告対象から外します。

サンプルコード

class Hoge
  def hoge
    puts 'hige'
  end
end

実行

  • IrresponsibleModule を無効にした設定で実行します

警告が発生しません

$ reek
Inspecting 1 file(s):
.
  • 設定を変更して実行します
---
IrresponsibleModule:
  enabled: true

警告が発生しました

$ reek
Inspecting 1 file(s):
S

hoge.rb -- 1 warning:
 [1]:IrresponsibleModule: Hoge has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]

関連資料