Hey guys, Rails has been around for a while, and it''s about time we got serious about deprecating APIs which we no longer intend to support. Without getting into a discussion about which code precisely is going to be deprecated, I thought I''d describe what''s going to happen. If you run your tests, and your application calls a deprecated api you''ll see the following information printed to stdout. @@@@@@@@@@ Deprecation Warning @@@@@@@@@@ Detailed Message Goes Here @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ One of these ugly printouts for every deprecated method call in your application. When your application is in development or production mode this same information will be output to your RAILS_ENV.log. This unrepentant spamming is deliberate. Unlike some other frameworks you may use, a deprecation warning in rails isn''t a threat, it''s a promise. It will be removed in the next major rails release. So, what are people''s thoughts about the warning methods, will it get your attention? -- Cheers Koz
On Jul 25, 2006, at 6:23 PM, Michael Koziarski wrote:> So, what are people''s thoughts about the warning methods, will it > get your attention?Works for me, especially if it has some link to what the preferred way of doing things is. -- _Deirdre http://deirdre.net
I think this is an ideal warning and a good incentive to follow good practises and ''move on''. It not only avoids nasty surprises, but also forces you to re-think your code to ensure your tests no longer blurt out piles of deprecation warnings, but also that your logs don''t grow out of control before they are cleaned. Cheers, Jamie van Dyke Fear of Fish On 26 Jul 2006, at 02:23, Michael Koziarski wrote:> Hey guys, > > Rails has been around for a while, and it''s about time we got serious > about deprecating APIs which we no longer intend to support. Without > getting into a discussion about which code precisely is going to be > deprecated, I thought I''d describe what''s going to happen. > > If you run your tests, and your application calls a deprecated api > you''ll see the following information printed to stdout. > > @@@@@@@@@@ Deprecation Warning @@@@@@@@@@ > Detailed Message Goes Here > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ > > One of these ugly printouts for every deprecated method call in your > application. When your application is in development or production > mode this same information will be output to your RAILS_ENV.log. > > This unrepentant spamming is deliberate. Unlike some other > frameworks you may use, a deprecation warning in rails isn''t a > threat, it''s a promise. It will be removed in the next major rails > release. > > So, what are people''s thoughts about the warning methods, will it > get your attention? > > -- > Cheers > > Koz > _______________________________________________ > Rails-core mailing list > Rails-core@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-core_______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
On Jul 25, 2006, at 6:23 PM, Michael Koziarski wrote:> Rails has been around for a while, and it''s about time we got serious > about deprecating APIs which we no longer intend to support. Without > getting into a discussion about which code precisely is going to be > deprecated, I thought I''d describe what''s going to happen. > > If you run your tests, and your application calls a deprecated api > you''ll see the following information printed to stdout. > > @@@@@@@@@@ Deprecation Warning @@@@@@@@@@ > Detailed Message Goes Here > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ > > One of these ugly printouts for every deprecated method call in your > application. When your application is in development or production > mode this same information will be output to your RAILS_ENV.log. > > This unrepentant spamming is deliberate. Unlike some other > frameworks you may use, a deprecation warning in rails isn''t a > threat, it''s a promise. It will be removed in the next major rails > release. > > So, what are people''s thoughts about the warning methods, will it > get your attention?That would probably be useful. I''d also like to see a rake task that greps the app for deprecated calls. It might not be able to catch all of them, but it should be able to find simple things like find_first and @content_for_layout. Is there some master list of deprecated items in the API? I''d be willing to take a crack at a find_deprecated rake task. -- Josh Susser http://blog.hasmanythrough.com
On Jul 25, 2006, at 9:23 PM, Michael Koziarski wrote:> > This unrepentant spamming is deliberate. Unlike some other > frameworks you may use, a deprecation warning in rails isn''t a > threat, it''s a promise. It will be removed in the next major rails > release. > > So, what are people''s thoughts about the warning methods, will it > get your attention?I''m all for it. Lack of proper deprecation will drive any project stagnant. The rake task would be a great touch too. -Mat
> On Jul 25, 2006, at 6:23 PM, Michael Koziarski wrote: > > > So, what are people''s thoughts about the warning methods, will it > > get your attention? > > Works for me, especially if it has some link to what the preferred > way of doing things is.My Thoughts there are that the api docs should contain the necessary information, for example telling you how to use has_many :through instead of habtm with push_with_attributes so ideally it''s simply a matter of going to that site, finding your deprecated method, and it should point you in the right direction. -- Cheers Koz
> That would probably be useful. I''d also like to see a rake task that > greps the app for deprecated calls. It might not be able to catch all > of them, but it should be able to find simple things like find_first > and @content_for_layout.The grepping would actually be really difficult to make reliable, however I suppose it wouldn''t hurt to have something to help out.> Is there some master list of deprecated items in the API? I''d be > willing to take a crack at a find_deprecated rake task.The deprecations will start appearing over the next few weeks, we may be able to automate some kind of list or detection task. -- Cheers Koz
I would also suggest putting it on the weblog in batches so those with projects that are frozen on an older version can be updated proactively. Bob _____ From: rails-core-bounces@lists.rubyonrails.org [mailto:rails-core-bounces@lists.rubyonrails.org] On Behalf Of Jamie van Dyke Sent: Tuesday, July 25, 2006 6:47 PM To: rails-core@lists.rubyonrails.org Subject: Re: [Rails-core] Deprecation with a Difference I think this is an ideal warning and a good incentive to follow good practises and ''move on''. It not only avoids nasty surprises, but also forces you to re-think your code to ensure your tests no longer blurt out piles of deprecation warnings, but also that your logs don''t grow out of control before they are cleaned. Cheers, Jamie van Dyke Fear of Fish On 26 Jul 2006, at 02:23, Michael Koziarski wrote: Hey guys, Rails has been around for a while, and it''s about time we got serious about deprecating APIs which we no longer intend to support. Without getting into a discussion about which code precisely is going to be deprecated, I thought I''d describe what''s going to happen. If you run your tests, and your application calls a deprecated api you''ll see the following information printed to stdout. @@@@@@@@@@ Deprecation Warning @@@@@@@@@@ Detailed Message Goes Here @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ One of these ugly printouts for every deprecated method call in your application. When your application is in development or production mode this same information will be output to your RAILS_ENV.log. This unrepentant spamming is deliberate. Unlike some other frameworks you may use, a deprecation warning in rails isn''t a threat, it''s a promise. It will be removed in the next major rails release. So, what are people''s thoughts about the warning methods, will it get your attention? -- Cheers Koz _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
Suggestion: how about printing something during the "rake" test run to indicate you are using deprecated methods? After I update rails for a project, the first thing I do is run "rake" to make sure nothing broke. Some deprecation warnings here would bring it to people''s attention. The downside is that it could clutter the test run output at the console (I don''t usually check the test logs for output, so error messages there would go unnoticed) ... I understand if this suggestion isn''t liked because of that reason, I just thought I''d throw it out there. You could even replace the dot (.) for a passed test method with a D to indicate that the test method passed but it used a method that will be deprecated in the next release. Crazy? Ryan On 7/25/06, Jamie van Dyke <jamie@fearoffish.co.uk> wrote:> > I think this is an ideal warning and a good incentive to follow good > practises and ''move on''. It not only avoids nasty surprises, but also > forces you to re-think your code to ensure your tests no longer blurt out > piles of deprecation warnings, but also that your logs don''t grow out of > control before they are cleaned. > > > Cheers, > Jamie van Dyke > Fear of Fish > > > On 26 Jul 2006, at 02:23, Michael Koziarski wrote: > > Hey guys, > > Rails has been around for a while, and it''s about time we got serious > about deprecating APIs which we no longer intend to support. Without > getting into a discussion about which code precisely is going to be > deprecated, I thought I''d describe what''s going to happen. > > If you run your tests, and your application calls a deprecated api > you''ll see the following information printed to stdout. > > @@@@@@@@@@ Deprecation Warning @@@@@@@@@@ > Detailed Message Goes Here > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ > > One of these ugly printouts for every deprecated method call in your > application. When your application is in development or production > mode this same information will be output to your RAILS_ENV.log. > > This unrepentant spamming is deliberate. Unlike some other > frameworks you may use, a deprecation warning in rails isn''t a > threat, it''s a promise. It will be removed in the next major rails > release. > > So, what are people''s thoughts about the warning methods, will it > get your attention? > > -- > Cheers > > Koz > _______________________________________________ > Rails-core mailing list > Rails-core@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-core > > _______________________________________________ > Rails-core mailing list > Rails-core@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-core > > >
On 7/26/06, Ryan Lowe <ryanlowe@gmail.com> wrote:> Suggestion: how about printing something during the "rake" test run to > indicate you are using deprecated methods? After I update rails for a > project, the first thing I do is run "rake" to make sure nothing > broke. Some deprecation warnings here would bring it to people''s > attention.That''s exactly what koz was talking about. Though, there might be a need for some options to turn off deprecation checking or just raise an error and fail the test. -- Rick Olson http://techno-weenie.net
The things that are planned sound great. Expanding on Ryan''s idea, I think using deprecated methods should be considered an error. Once the code goes in, I''d like to write a plugin that raises a deprecation exception (when in the test environment) if deprecated methods are used. I trust it''s just a matter of plugging into some hook? Kev
On Jul 26, 2006, at 2:11 PM, Ryan Lowe wrote:> Suggestion: how about printing something during the "rake" test run to > indicate you are using deprecated methods? After I update rails for a > project, the first thing I do is run "rake" to make sure nothing > broke. Some deprecation warnings here would bring it to people''s > attention.Yeah, that''s what he meant with:>> If you run your tests, and your application calls a deprecated api >> you''ll see the following information printed to stdout. >> >> @@@@@@@@@@ Deprecation Warning @@@@@@@@@@ >> Detailed Message Goes Here >> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-Scott
On 7/26/06, Ryan Lowe <ryanlowe@gmail.com> wrote:> The downside is that it could clutter the test run output at the > console (I don''t usually check the test logs for output, so error > messages there would go unnoticed) ... I understand if this suggestion > isn''t liked because of that reason, I just thought I''d throw it out > there.You could even log these deprecation errors to a distinct file, just to make them stand out even more... -- * J * ~
On 2006-07-26, at 16:16 , Kevin Clark wrote:> The things that are planned sound great. Expanding on Ryan''s idea, I > think using deprecated methods should be considered an error. Once the > code goes in, I''d like to write a plugin that raises a deprecation > exception (when in the test environment) if deprecated methods are > used. I trust it''s just a matter of plugging into some hook?That would depend on how they decide to implement it. If they use the same method to warn about all deprecations, changing it to raise would be as simple as overriding that method. One could also change it to email the coder on each deprecated call. The possibilities are endless :P I also like the idea of the code scanner task, even if it''s unreliable. It may detect things that are otherwise undetecable, such as the use of @content_for_layout
On Wed, Jul 26, 2006 at 02:11:52PM -0400, Ryan Lowe wrote:> Suggestion: how about printing something during the "rake" test run to > indicate you are using deprecated methods? After I update rails for aI think you missed something in the original announcement e-mail:> >On 26 Jul 2006, at 02:23, Michael Koziarski wrote: > >If you run your tests, and your application calls a deprecated api > >you''ll see the following information printed to stdout.In other words, your idea is so good that the core team were able to feel the brilliance and retroactively propose it, to general agreement and good cheer. <grin> BTW, I''m 110% in favour of this whole plan: deprecate or die, just tell us about it beforehand. Anyone without a test suite deserves what they get -- missing deprecation warnings will be the least of their worries on upgrades. - Matt
Caio Chassot wrote:> > On 2006-07-26, at 16:16 , Kevin Clark wrote: > >> The things that are planned sound great. Expanding on Ryan''s idea, I >> think using deprecated methods should be considered an error. Once the >> code goes in, I''d like to write a plugin that raises a deprecation >> exception (when in the test environment) if deprecated methods are >> used. I trust it''s just a matter of plugging into some hook? > > That would depend on how they decide to implement it. If they use the > same method to warn about all deprecations, changing it to raise would > be as simple as overriding that method. > > One could also change it to email the coder on each deprecated call. The > possibilities are endless :P > > I also like the idea of the code scanner task, even if it''s unreliable. > It may detect things that are otherwise undetecable, such as the use of > @content_for_layoutI think you''d be surprised--Koz has got a deprecation solution for the instance variables, too. :) Be prepared to be amazed when he releases this thing! - Jamis
> That would depend on how they decide to implement it. If they use the > same method to warn about all deprecations, changing it to raise > would be as simple as overriding that method.This has been committed now. As you can see from deprecation_test.rb in activesupport, it''s fairly easy to monkeypatch. Raising an exception should be easy. For a while we considered raising an exception as a built in measure, however while we want to get your attention, it''s probably not good to crash your app repeatedly until you check your exception logs.> One could also change it to email the coder on each deprecated call. > The possibilities are endless :P > > I also like the idea of the code scanner task, even if it''s > unreliable. It may detect things that are otherwise undetecable, such > as the use of @content_for_layoutAs Jamis mentioned, we can quite easily catch references to deprecated instance variables. I''ll hopefully have something to commit in the next few days which takes care of that. -- Cheers Koz