-
Notifications
You must be signed in to change notification settings - Fork 34
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
Absolute Path vs Relative Path on deprecations #70
Comments
Another way: class DeprecationToolkit::Collector
def initialize(deprecations)
# This will remove the absolute paths from the deprecations since it varies
# from environment to environment.
#
# See https://github.com/Shopify/deprecation_toolkit/issues/70
self.deprecations = deprecations.map do |deprecation|
deprecation
.gsub(Gem.dir.to_s, "[GEM_DIR]")
.gsub(Rails.root.to_s, "[RAILS_ROOT]")
end
end
end |
What is adding paths to the deprecation message? Active Support deprecation doesn't do it |
Ah, it is the message Ruby generates. We ignore stacktraces when writing and comparing deprecations (for deprecation using But, if we remove it from the recorded deprecation, like we do with Tough position to be since I want to allow automation, but I also want to match the same behavior as I think we should really think on how to allow automation in both contexts in order to fix this issue properly. |
The code snippet is working fine, probably allowing to change the collector (to avoid the monkey patch) or either allowing to scrub data from the deprecation messages would work (if do not want to couple to Rails, for instance, even though we could loose couple with a |
Would this be solved by #60, if that were in a releasable state? |
I had to add 3rd gsub to handle # At spec/support/deprecation_toolkit.rb
# frozen_string_literal: true
require 'deprecation_toolkit'
require 'deprecation_toolkit/rspec'
# Monkeypatch the DeprecationToolkit
# This will remove the absolute paths from the deprecations since it varies from environment to environment.
# See https://github.com/Shopify/deprecation_toolkit/issues/70
module DeprecationToolkit
class Collector
def initialize(deprecations)
self.deprecations = deprecations.map do |deprecation|
deprecation
.gsub(Gem.dir.to_s, '[GEM_DIR]')
.gsub(Rails.root.to_s, '[RAILS_ROOT]')
.gsub(RbConfig::CONFIG['rubylibdir'].to_s, '[RUBY_LIBS_DIR]') # For default ruby gems such as psych
end
end
end
end
DeprecationToolkit::Configuration.test_runner = :rspec
DeprecationToolkit::Configuration.deprecation_path = 'spec/fixtures/deprecations'
# Empty regex matches every warning to be treated as a deprecation error
DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [//] |
Hi there!
When recording deprecations as suggested on https://about.gitlab.com/blog/2021/02/03/how-we-automatically-fixed-hundreds-of-ruby-2-7-deprecation-warnings/ we are seeing recordings like:
But when running on CI, we have:
Which leads to a
DeprecationToolkit::Behaviors::DeprecationMismatch
failure.I'm currently fixing those with a dirty sed:
Does it worth to have a way of replacing paths/values from deprecations or at least mention how on README?
The text was updated successfully, but these errors were encountered: