-
Notifications
You must be signed in to change notification settings - Fork 45
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
Fix many ruby warnings #47
base: master
Are you sure you want to change the base?
Conversation
Hi @joshbuddy can you take a look at this PR? thanks so much ;) |
I've just landed here, trying to understand the reason of the hanami warnings. I also read http://stackoverflow.com/a/34275638/123527, and specifically
This is extremely sad, and confusing! |
@cllns @AlfonsoUceda FYI there is also another solution, that doesn't require to bring in the Addressable dependency. Simply replace: class HttpRouter
class Request
attr_accessor :path, :params, :rack_request, :extra_env, :continue, :passed_with, :called
attr_reader :acceptable_methods
alias_method :rack, :rack_request
alias_method :called?, :called
def initialize(path, rack_request)
@rack_request = rack_request
@path = URI.unescape(path).split(/\//) to
The relevant line is @path = URI::DEFAULT_PARSER.unescape(path).split(/\//) This is the current implementation of def unescape(*arg)
warn "#{caller(1)[0]}: warning: URI.unescape is obsolete" if $VERBOSE
DEFAULT_PARSER.unescape(*arg)
end Why I think this is a reasonable (perhaps not the best, but reasonable) solution:
|
@weppos thanks for bringing up that solution I think it's good for us and we could create a PR in hanami/controller to overwrite the initializer, what do you think? |
I'm not very familiar with how hanami/controller deals with the router. I would not recommend to override an entire initializer for the long term solution, but given this library seems to be quite static, it may be a temporary solution. /cc @jodosha |
Seeing the http_router warnings in test output in a Hanami app. Anything I can do to help get this one in? |
Addresses most of #44.
Fixing
warning: URI.escape is obsolete
andwarning: URI.unescape is obsolete
required adding a dependency, onAddressable
. I hope that's OK!All the tests pass (except for
examples/static/config.ru
doesn't run for me, regardless of these changes, see: #46).Note: this doesn't fix all the Ruby warnings in this project, but rather the ones that
hanami-router
hits in its test suite. I tried to fix others, but they weren't easy fixes (instance_eval
redefining a method). To run the tests with warnings enabled, you can do:RUBYOPT=w bundle exec rake test
Also, I couldn't fix one of the warnings that
hanami-router
hits:lib/http_router/route_helper.rb:99: warning: assigned but unused variable - params
, because the local variable is referenced in theeval
call a couple lines down, in one of the tests :/