LoginSignup
24
25

More than 5 years have passed since last update.

Rails 4.2.6 に更新した後に [DEPRECATION] `last_comment` is deprecated. と警告されるので対処する

Last updated at Posted at 2016-03-14

本日 Rails のバージョンを 4.2.5.2 から 4.2.6 に上げました。その後、Rake タスクを実行すると、以下の警告が表示されるようになってしまいました。

$ bin/rake -T
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.

ご、5 回も言わなくても…。鬱陶しいので取り除くことにしました。

まずは Gem をインストールしたディレクトリで last_comment というメソッドを呼んでいる箇所を検索してみます。僕は .bundle 以下に Gem を bundle install しているので、その配下を検索しました。

$ grep -R "\.last_comment" .bundle
.bundle/ruby/2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/rake_task.rb:        desc "Run RSpec code examples" unless ::Rake.application.last_comment
.bundle/ruby/2.3.0/gems/rubocop-0.37.2/lib/rubocop/rake_task.rb:      desc 'Run RuboCop' unless ::Rake.application.last_comment
.bundle/ruby/2.3.0/gems/yard-0.8.7.6/lib/yard/rake/yardoc_task.rb:        desc "Generate YARD Documentation" unless ::Rake.application.last_comment

どうやら RSpec, Rubocop, YARD で使われている
Rake.application.last_comment (Rake::TaskManager#last_comment)
が原因のようですね。試しにそれぞれの Gem を最新版に更新してみました。ただし YARD は既に最新バージョンでした。

Gem 更新前 更新後
RSpec 3.3.0 3.4.0
rspec-core 3.3.2 3.4.4
Rubocop 0.37.2 0.38.0

その後、再び Rake タスクを実行すると、警告は表示されなくなりました。やったね :star:

24
25
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
24
25