Skip to content

Loading…

Usage of Hash#diff prints a million deprecation warnings to server log #93

Closed
wants to merge 1 commit into from
@tommireinikainen

Footnotes::Extensions::Routes::filtered_routes uses Hash#diff which has been deprecated by Rails 4 (or earlier?), see rails/rails#8158. This cause the server to print a bazillion deprecation warnings to the server log on every refresh:

DEPRECATION WARNING: Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead. (called from require at bin/rails:4)
DEPRECATION WARNING: Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead. (called from require at bin/rails:4)
DEPRECATION WARNING: Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead. (called from require at bin/rails:4)
...

I just extracted the original diff into a local function without touching the logic in filtered_routes.

@thejamespinto

this commit works perfecly, thank you =D
@josevalim I found this gem by accident helping somebody on IRC, amazing! thank you!

@mclee

This saved my development logs. Thanks! Hope it gets merged soon.

@gustavolobo

It will be nice to see this merged :+1:

@iabdulin

+1

@Perf

+1

@romanvbabenko
Collaborator

fixed

@cmalpeli

Has this been merged into 3.7.4? Just installed Rails 4.0.2 and this is filling up my logs!

@aaronmcadam

:+1: to this too, waiting for a proper release

@memoht

+1 to this. rails-footnotes 3.8 please.

@daryllxd

+1 this please

@josevalim josevalim reopened this
@josevalim
Owner

Can someone please submit a new pull request? Also, we should move diff to a private method instead of defining it inline. :)

@aaronmcadam

@josevalim It looks like this fix is already in master? https://github.com/josevalim/rails-footnotes/blob/master/lib/rails-footnotes/notes/routes_note.rb#L37-L52. Am I missing something? It looks like it follows the same algorithm as this PR.

@josevalim
Owner

Awesome, thanks!

@josevalim josevalim closed this
@jmuheim

I'm still getting tons of these:

DEPRECATION WARNING: Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead. (called from handle at /Users/josh/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:145)
DEPRECATION WARNING: Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead. (called from handle at /Users/josh/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:145)
DEPRECATION WARNING: Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead. (called from handle at /Users/josh/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:145)

While nothing seems to point to rails-footnotes here, removing it from Gemfile results in no such deprecation warnings are logged anymore. Anyone has the same problem?

@aaronmcadam

@jmuheim Are you pointing at master?

@jmuheim

When pointing go master, I get these:

DEPRECATION WARNING: ActionController::AbstractRequest and ActionController::Request are deprecated and will be removed, use ActionDispatch::Request instead. (called from <top (required)> at /Users/josh/.rvm/gems/ruby-2.1.0@synaesthesia/bundler/gems/rails-footnotes-e16074fa3b98/lib/rails-footnotes/notes/routes_note.rb:59)
DEPRECATION WARNING: ActionController::AbstractResponse and ActionController::Response are deprecated and will be removed, use ActionDispatch::Response instead. (called from <top (required)> at /Users/josh/.rvm/gems/ruby-2.1.0@synaesthesia/bundler/gems/rails-footnotes-e16074fa3b98/lib/rails-footnotes/notes/routes_note.rb:59)
DEPRECATION WARNING: ActionController::Routing is deprecated and will be removed, use ActionDispatch::Routing instead. (called from <top (required)> at /Users/josh/.rvm/gems/ruby-2.1.0@synaesthesia/bundler/gems/rails-footnotes-e16074fa3b98/lib/rails-footnotes/notes/routes_note.rb:59)
DEPRECATION WARNING: Filter object with #filter method is deprecated. Define method corresponding to filter type (#before, #after or #around). (called from included at /Users/josh/.rvm/gems/ruby-2.1.0@synaesthesia/bundler/gems/rails-footnotes-e16074fa3b98/lib/rails-footnotes/extension.rb:4)
DEPRECATION WARNING: Filter object with #filter method is deprecated. Define method corresponding to filter type (#before, #after or #around). (called from included at /Users/josh/.rvm/gems/ruby-2.1.0@synaesthesia/bundler/gems/rails-footnotes-e16074fa3b98/lib/rails-footnotes/extension.rb:5)
@Intrepidd
Collaborator

Hey, a new version is being cooked, all warnings should be gone. See branch wip-refactoring and release-4.0

Pull requests are welcome on those branches.

@jmuheim jmuheim pushed a commit to jmuheim/synaesthesia that referenced this pull request
Joshua Muheim Remove rails-footnotes because of deprecation warnings. 8fdde13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 23, 2013
  1. @tommireinikainen
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/rails-footnotes/notes/routes_note.rb
View
10 lib/rails-footnotes/notes/routes_note.rb
@@ -45,10 +45,16 @@ module Routes
# Filter routes according to the filter sent
#
def filtered_routes(filter = {})
+ def diff(h1,h2)
+ h1.dup.delete_if { |k, v|
+ h2[k] == v
+ }.merge!(h2.dup.delete_if { |k, v| h1.has_key?(k) })
+ end
+
return [] unless filter.is_a?(Hash)
return routes.reject do |r|
- filter_diff = filter.diff(r.requirements)
- route_diff = r.requirements.diff(filter)
+ filter_diff = diff(filter, r.requirements)
+ route_diff = diff(r.requirements, filter)
(filter_diff == filter) || (filter_diff != route_diff)
end
end
Something went wrong with that request. Please try again.