Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #10635 - Formalize deprecation warning #2444

Closed
wants to merge 1 commit into from

Conversation

alongoldboim
Copy link
Member

I have added Foreman::Deprecation service which wraps ActiveSupport::Deprecation that we are currently using, formalizing the messages and enforces deprecation.
I have changed all the deprecations calls on the core to the new format and placed a default
two versions up (1.10.0) as a deadline(all deprecations with 1.10.0 will be deleted on it's release).

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • dd175f7 must be in the format Fixes/refs #redmine_number - brief description.

Guidelines are available on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@domcleal domcleal changed the title Refactor #10635 - Formalize deprecation warning Fixes #10635 - Formalize deprecation warning Jun 9, 2015
@@ -15,7 +15,7 @@ def mail(headers = {}, &block)

class GroupMail
def initialize(emails)
ActiveSupport::Deprecation.warn 'GroupMail will be removed as mailers should not generate multiple messages, use MailNotification#deliver'
ForemanDeprecation.deprecation_warning("MailNotification","deliver","1.10.0","GroupMail will be removed as mailers should not generate multiple messages")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on all of these changes - code without spacing around arguments is hard to read, please include it as standard.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing.

2015-06-09 15:09 GMT+03:00 Dominic Cleal notifications@github.com:

In app/mailers/application_mailer.rb
#2444 (comment):

@@ -15,7 +15,7 @@ def mail(headers = {}, &block)

class GroupMail
def initialize(emails)

  •  ActiveSupport::Deprecation.warn 'GroupMail will be removed as mailers should not generate multiple messages, use MailNotification#deliver'
    
  •  ForemanDeprecation.deprecation_warning("MailNotification","deliver","1.10.0","GroupMail will be removed as mailers should not generate multiple messages")
    

Same comment on all of these changes - code without spacing around
arguments is hard to read, please include it as standard.


Reply to this email directly or view it on GitHub
https://github.com/theforeman/foreman/pull/2444/files#r32005809.

class Deprecation
#aviliable options: controller, method, general info, callstack
def self.deprecation_warning(foreman_version_deadline, options={})
raise Foreman::Exception, _("Invalid version format, please enter in x.y.z") unless foreman_version_deadline.to_s.match(/\A^\d[.]\d+[.]\d$\z/)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domcleal I tried using Gem:Version.correct? and it wasn't strict enough (e.g 1.2.e was accepted).
So I decided sticking with the Reg ex.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm okay, not sure that matters a lot.

  1. The regexp now contains both \A and ^, ditto for EOL, just use one or the other.

@@ -12,17 +12,17 @@ class SmartProxy < ActiveRecord::Base
#TODO check if there is a way to look into the tftp_id too
# maybe with a predefined sql
has_and_belongs_to_many :features
has_many :subnets, :foreign_key => 'dhcp_id'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't re-format files like this, revert changes that aren't to do with this PR.

@domcleal
Copy link
Contributor

Unit tests are failing due to ForemanDeprecation usage, and rubocop is also failing - possibly because of the reformatting, please revert those and run rubocop to see the remaining warnings.

@domcleal
Copy link
Contributor

domcleal commented Jul 1, 2015

The author of your commit is set as @elobato according to GitHub, is that deliberate?

@alongoldboim
Copy link
Member Author

It was by mistake, fixed it.

@domcleal
Copy link
Contributor

domcleal commented Jul 1, 2015

Looks good. Just scanning for other deprecation warnings when rebased onto develop, I see:

  1. app/controllers/api/v1/operatingsystems_controller.rb:91
  2. config/initializers/deprecations.rb:4

Could you update those too please?

@alongoldboim
Copy link
Member Author

Added them.
Thanks Dominic.

@@ -2,6 +2,7 @@ module Deprecations
def const_missing(const_name)
return(super) unless const_name.to_s == 'ConfigTemplate'
warn '`ConfigTemplate` has been deprecated. Use `ProvisioningTemplate` instead.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And remove this to stop a duplicate warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry forgot :).

@domcleal
Copy link
Contributor

domcleal commented Jul 2, 2015

Merged as 319d1ff for Foreman 1.9, thanks @alongoldboim.

@domcleal domcleal closed this Jul 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants