Shopify / deprecation_toolkit

⚒Eliminate deprecations from your codebase ⚒
MIT License
460 stars 40 forks source link

CI and local ruby keyword args YAMLs don't match #48

Open snehaso opened 4 years ago

snehaso commented 4 years ago

Hi

I'm using deprecation-toolkit to capture ruby 2.7 warnings in our codebase. We'd disabled them earlier but want to enable again.

I recorded warnings using CIRecordHelper but I've hit a issue where the ruby code and gem paths in warnings are different on CI and developer environment. How do I handle this?

On local,

---
test_the_banking_inline_form_add_an_attachment_to_an_explanation:
- |
  DEPRECATION WARNING: /Users/snehasomwanshi/dev/accouting/app/uploaders/attachment_attachment_uploader.rb:136: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
  /Users/snehasomwanshi/.gem/ruby/2.7.1/gems/shrine-3.2.1/lib/shrine/plugins/store_dimensions.rb:75: warning: The called method `extract_metadata' is defined here
- |
  DEPRECATION WARNING: /Users/snehasomwanshi/dev/accouting/app/uploaders/attachment_attachment_uploader.rb:124: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
  /Users/snehasomwanshi/.gem/ruby/2.7.1/gems/shrine-3.2.1/lib/shrine.rb:222: warning: The called method `generate_location' is defined here

On CI,

  ---
test_the_banking_inline_form_adding_a_new_explanation:
- |
  DEPRECATION WARNING: /home/ubuntu/workspace/fac/accounting/app/uploaders/attachment_attachment_uploader.rb:136: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
  /home/ubuntu/.gem/ruby/2.7.1/gems/shrine-3.2.1/lib/shrine/plugins/store_dimensions.rb:75: warning: The called method `extract_metadata' is defined here
- |
  DEPRECATION WARNING: /home/ubuntu/workspace/fac/accounting/app/uploaders/attachment_attachment_uploader.rb:124: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
  /home/ubuntu/.gem/ruby/2.7.1/gems/shrine-3.2.1/lib/shrine.rb:222: warning: The called method `generate_location' is defined here

Does this mean that a developer can not record a new warning locally? How do I handle this?

bradparker commented 3 years ago

@snehaso in case this is still useful to you: while spiking out using deprecation toolkit I ran into this issue and worked around it by overriding deprecations_without_stacktrace. So, not a long term solution but as I said: just in case it's useful. Here's most of the initializer we were thinking of using:

DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [
  /Using the last argument as keyword parameters is deprecated/,
  /Capturing the given block using Proc.new is deprecated/,
]

module DeprecationToolkit
  class Collector
    alias old_deprecations_without_stacktrace deprecations_without_stacktrace

    def deprecations_without_stacktrace
      old_deprecations_without_stacktrace.map do |deprecation|
        deprecation
          .sub(/^DEPRECATION WARNING: \/.* warning: /, "DEPRECATION WARNING: ")
          .sub(/\/.* is defined here$/, "")
      end
    end
  end
end