LoginSignup
1
0

More than 5 years have passed since last update.

Dangerでコンパイラ警告をコメントする

Posted at

Dangerを導入して、Rubyをほんの少し触ったので、備忘ついでです。

Danger導入

Cookpadの記事を見てDangerを導入してみました。

導入もそれほど苦労せず、実際にBOT稼働まで半日かかったくらいでした。

内情

AndroidLintをコメントしてくれるようにはできたのですが、コンパイラ警告を拾ってくれるプラグインがないため、自分で警告をコメントするようにしてみました。
コンパイラ警告を無視しないでくれれば一番いいのですが・・

実装

Dangerfile
regexp = /^w: #{Dir.pwd}\/(?<file>.*): \((?<line>[0-9]+), .*\): (?<message>.*)$/
File.foreach('stdout.log') do |line|
    match = regexp.match(line) || next
    message = match[:message]
    file = match[:file]
    line = match[:line].to_i
    warn(message, file: file, line: line)
end

上記に加えて、CI側でビルドタスクのログをstdout.logに出力させる必要があります。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0