rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.12k stars 553 forks source link

🌈The klass parameter 'inject_into_class' should be given a string type.(also inject_into_module) #752

Closed ratovia closed 3 years ago

ratovia commented 3 years ago

I think that in most cases the target klass is not defined in a file that uses inject_into_class. So it is more friendly to set the default comment to string type. as-is

inject_into_class "xxx.rb", ApplicationController, "Lorem"

to-be

inject_into_class "xxx.rb", "ApplicationController", "Lorem"

I think it's more realistic for test specs to delete the empty class definition in the first line. Also about the inject_into_module.

xjunior commented 3 years ago

Looks good, but I think it's better if both are allowed. Since the implementation already allows that, you could just add another test to make sure strings are also supported. And +1 to update the docs.

rafaelfranca commented 3 years ago

That works by "mistake" today and I prefer if we don't advertise it. I'll merge this as-is