r7kamura / rubocop_todo_corrector

Auto-correct offenses defined in .rubocop_todo.yml.
MIT License
5 stars 2 forks source link

YARD warning #6

Closed r7kamura closed 2 years ago

r7kamura commented 2 years ago
 [warn]: Unknown tag @safety in file /opt/hostedtoolcache/Ruby/3.1.2/x64/lib/ruby/gems/3.1.0/gems/rubocop-1.23.0/lib/rubocop/cop/style/redundant_sort.rb near line 79 Auto-correct Style/RedundantSort
r7kamura commented 2 years ago
r7kamura commented 2 years ago
r7kamura commented 2 years ago

How to reproduce:

bundle exec ruby -Ilib -r rubocop_todo_corrector -e "RubocopTodoCorrector::CopDocumentParser.call(source_path: '/home/r7kamura/ghq/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_sort.rb')"
[warn]: Unknown tag @safety in file `/home/r7kamura/ghq/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_sort.rb` near line 79
r7kamura commented 2 years ago

I found this patch would erase this warning:

$ git diff
diff --git a/lib/rubocop_todo_corrector/cop_document_parser.rb b/lib/rubocop_todo_corrector/cop_document_parser.rb
index 21df1c2..ce41bd5 100644
--- a/lib/rubocop_todo_corrector/cop_document_parser.rb
+++ b/lib/rubocop_todo_corrector/cop_document_parser.rb
@@ -42,6 +42,7 @@ module RubocopTodoCorrector
     # @return [YARD::CodeObjects::ClassObject]
     def yard_class_object
       @yard_class_object ||= begin
+        ::YARD::Tags::Library.define_tag('Cop Safety Information', :safety)
         ::YARD.parse(@source_path)
         yardoc = ::YARD::Registry.all(:class).first
         ::YARD::Registry.clear
/home/r7kamura/ghq/github.com/r7kamura/rubocop_todo_corrector main
$ bundle exec ruby -Ilib -r rubocop_todo_corrector -e "RubocopTodoCorrector::CopDocumentParser.call(source_path: '/home/r7kamura/ghq/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_sort.rb')"