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

Remove verbose warnings in test output #1049

Merged
merged 4 commits into from
Dec 28, 2017

Conversation

asartalo
Copy link
Contributor

A fix for issue #976.

This removes most of the verbose warnings shown when running rake test.

Copy link
Owner

@lynndylanhurley lynndylanhurley left a comment

Choose a reason for hiding this comment

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

Nice!

@asartalo
Copy link
Contributor Author

Thanks!

@zachfeldman
Copy link
Contributor

zachfeldman commented Dec 23, 2017

Hey @asartalo thanks for your PR. Can you paste a screenshot of how many warnings are showing now? This is a really small commit so if we're going to a pay a bounty on this ticket, we'd want to ensure this is really removing all warnings when running the suite and not just hiding them.

@lynndylanhurley
Copy link
Owner

@zachfeldman we can just check the travis output.

Looks like there are still a couple of outstanding issues.

In this case it's logging an omniauth failure when we are testing the handling of the failure:

E, [2017-12-22T23:06:04.822416 #5994] ERROR -- omniauth: (facebook) Authentication failure! invalid_credentials encountered.

It would be nice to silence the omniauth warnings.

The other warning is an actual issue that we should fix:

DEPRECATION WARNING: Locking a record with unpersisted changes is deprecated and will raise an exception in Rails 5.2. Use `save` to persist the changes, or `reload` to discard them explicitly. (called from update_auth_header at /home/travis/build/lynndylanhurley/devise_token_auth/app/controllers/devise_token_auth/concerns/set_user_by_token.rb:105)

Should be an easy fix.

@zachfeldman
Copy link
Contributor

Thanks @lynndylanhurley ! @asartalo I'd use that comment as a guideline for how to proceed.

@asartalo
Copy link
Contributor Author

Thanks! I actually got here through the bounty system and it's my first time. After finding out how to go about this, I didn't know if I should even claim the bounty because the fix may have been too small. I'll work on it right away.

Fixes deprecation warnings in test runs when models have been
modified prior to locking in updating auth header.

Part of a fix for lynndylanhurley#976
Code improvements for 2208ae3 noted in code climate
@asartalo
Copy link
Contributor Author

There should no longer be unnecessary messages after this. Should I squash all commits into 1?

@lynndylanhurley
Copy link
Owner

Should I squash all commits into 1?

I think the commits look great. Thanks @asartalo!

Copy link
Owner

@lynndylanhurley lynndylanhurley left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@zachfeldman
Copy link
Contributor

@asartalo much better! If we remove silencing warnings though, are there still a lot of warnings?

@zachfeldman
Copy link
Contributor

@asartalo to clarify....does the silencing line silence any legit warnings? Would there be ways to remove those warnings entirely rather than just silencing them?

@asartalo
Copy link
Contributor Author

asartalo commented Dec 28, 2017

If we remove the t.warning = false on the Rakefile then these are all the warnings that appear (sorted, removing duplicates):

~/.rvm/gems/ruby-2.4.2/bundler/gems/omniauth-facebook-19634473820d/lib/omniauth/strategies/facebook.rb:79: warning: instance variable @authorization_code_from_signed_request_in_cookie not initialized
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old api_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old api_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old api_v2_scoped_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old api_v2_scoped_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_api_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_api_v2_scoped_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_evil_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_lockable_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_mang
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_nice_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_only_email_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_unconfirmable_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_unregisterable_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old current_user
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old evil_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old evil_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old lockable_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old lockable_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old mang_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old mang_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old nice_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old nice_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old only_email_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old only_email_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old render_authenticate_error
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old unconfirmable_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old unconfirmable_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old unregisterable_user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old unregisterable_user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old user_session
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old user_signed_in?
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of api_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of api_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of api_v2_scoped_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of api_v2_scoped_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_api_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_api_v2_scoped_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_evil_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_lockable_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_mang was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_nice_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_only_email_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_unconfirmable_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_unregisterable_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of current_user was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of evil_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of evil_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of lockable_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of lockable_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of mang_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of mang_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of nice_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of nice_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of only_email_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of only_email_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of render_authenticate_error was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of unconfirmable_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of unconfirmable_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of unregisterable_user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of unregisterable_user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of user_session was here
~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: previous definition of user_signed_in? was here
~/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/core_ext/class/attribute.rb:90: warning: previous definition of default_url_options was here
~/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292: warning: loading in progress, circular require considered harmful - /Users/wayne/.rvm/gems/ruby-2.4.2/gems/guard-2.14.1/lib/guard.rb
~/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292: warning: loading in progress, circular require considered harmful - /Users/wayne/.rvm/gems/ruby-2.4.2/gems/guard-2.14.1/lib/guard/guardfile/evaluator.rb
~/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292: warning: loading in progress, circular require considered harmful - /Users/wayne/.rvm/gems/ruby-2.4.2/gems/guard-minitest-2.4.6/lib/guard/minitest.rb
~/.rvm/gems/ruby-2.4.2/gems/attr_encrypted-3.0.3/lib/attr_encrypted/adapters/active_record.rb:61: warning: shadowing outer local variable - options
~/.rvm/gems/ruby-2.4.2/gems/devise-4.3.0/lib/devise/failure_app.rb:27: warning: method redefined; discarding old default_url_options
~/.rvm/gems/ruby-2.4.2/gems/devise-4.3.0/lib/devise/models/confirmable.rb:297: warning: instance variable @reconfirmation_required not initialized
~/.rvm/gems/ruby-2.4.2/gems/devise-4.3.0/lib/devise/rails/routes.rb:486: warning: previous definition of set_omniauth_path_prefix! was here
~/.rvm/gems/ruby-2.4.2/gems/devise-4.3.0/lib/devise/rails/warden_compat.rb:2: warning: method redefined; discarding old request
~/.rvm/gems/ruby-2.4.2/gems/devise-4.3.0/lib/devise/rails/warden_compat.rb:6: warning: method redefined; discarding old reset_session!
~/.rvm/gems/ruby-2.4.2/gems/faker-1.7.3/lib/faker/omniauth.rb:290: warning: mismatched indentations at 'end' with 'class' at 14
~/.rvm/gems/ruby-2.4.2/gems/hashie-3.5.5/lib/hashie/mash.rb:86: warning: instance variable @disable_warnings not initialized
~/.rvm/gems/ruby-2.4.2/gems/omniauth-1.6.1/lib/omniauth/failure_endpoint.rb:28: warning: previous definition of redirect_to_failure was here
~/.rvm/gems/ruby-2.4.2/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:282: warning: previous definition of mock_callback_call was here
~/.rvm/gems/ruby-2.4.2/gems/warden-1.2.7/lib/warden/mixins/common.rb:18: warning: previous definition of request was here
~/.rvm/gems/ruby-2.4.2/gems/warden-1.2.7/lib/warden/mixins/common.rb:39: warning: previous definition of reset_session! was here
~/Projects/ruby/devise_token_auth/app/controllers/devise_token_auth/concerns/set_user_by_token.rb:68: warning: instance variable @resource not initialized
~/Projects/ruby/devise_token_auth/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:113: warning: previous definition of omniauth_window_type was here
~/Projects/ruby/devise_token_auth/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:123: warning: method redefined; discarding old omniauth_window_type
~/Projects/ruby/devise_token_auth/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:175: warning: instance variable @oauth_registration not initialized
~/Projects/ruby/devise_token_auth/app/models/devise_token_auth/concerns/user.rb:222: warning: assigned but unused variable - expiry
~/Projects/ruby/devise_token_auth/app/models/devise_token_auth/concerns/user.rb:64: warning: instance variable @raw_confirmation_token not initialized
~/Projects/ruby/devise_token_auth/app/views/devise_token_auth/omniauth_external_window.html.erb:18:in `___sers_wayne__rojects_ruby_devise_token_auth_app_views_devise_token_auth_omniauth_external_window_html_erb__3797081075666656403_70270696309080': warning: URI.escape is obsolete
~/Projects/ruby/devise_token_auth/devise_token_auth.gemspec:19: warning: character class has duplicated range: /[.log|.sqlite3]$/
~/Projects/ruby/devise_token_auth/lib/devise_token_auth/controllers/helpers.rb:134: warning: method redefined; discarding old render_authenticate_error
~/Projects/ruby/devise_token_auth/lib/devise_token_auth/controllers/helpers.rb:134: warning: previous definition of render_authenticate_error was here
~/Projects/ruby/devise_token_auth/lib/devise_token_auth/engine.rb:57: warning: method redefined; discarding old redirect_to_failure
~/Projects/ruby/devise_token_auth/lib/devise_token_auth/engine.rb:71: warning: method redefined; discarding old mock_callback_call
~/Projects/ruby/devise_token_auth/lib/devise_token_auth/rails/routes.rb:110: warning: method redefined; discarding old set_omniauth_path_prefix!
~/Projects/ruby/devise_token_auth/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb:21:in `get_parsed_data_json': warning: URI.unescape is obsolete
~/Projects/ruby/devise_token_auth/test/controllers/devise_token_auth/registrations_controller_test.rb:180:in `block (3 levels) in <class:RegistrationsControllerTest>': warning: URI.unescape is obsolete
~/Projects/ruby/devise_token_auth/test/controllers/devise_token_auth/registrations_controller_test.rb:260: warning: instance variable @fav_color not initialized
~/Projects/ruby/devise_token_auth/test/controllers/overrides/confirmations_controller_test.rb:37:in `block (2 levels) in <class:ConfirmationsControllerTest>': warning: URI.unescape is obsolete

We can probably work on the devise_token_auth side but the rest are on the included libraries.

@zachfeldman
Copy link
Contributor

Thanks @asartalo ! @lynndylanhurley what do you think of these warnings?

@lynndylanhurley
Copy link
Owner

It looks like they should all be ignored. I'll just go through some of the different types:

~/.rvm/gems/ruby-2.4.2/gems/attr_encrypted-3.0.3/lib/attr_encrypted/adapters/active_record.rb:61: warning: shadowing outer local variable - options

^ this is a code-smell thing that should be fixed, but it's in another gem and completely outside of our control. There are several issues like this that are caused by external dependencies.

~/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/abstract_controller/helpers.rb:67: warning: method redefined; discarding old api_user_session

^ a method was redefined (intentionally). There are a ton of these warnings, and in each case it's intentional.

~/Projects/ruby/devise_token_auth/app/controllers/devise_token_auth/concerns/set_user_by_token.rb:68: warning: instance variable @resource not initialized

^ an instance variable was not initialized before it was used. The result is that it evaluates to nil, which is what we're expecting in each case. I fixed several of these by setting the initial value to nil, but I'm not sure if there is any benefit to doing so.

~/Projects/ruby/devise_token_auth/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb:21:in `get_parsed_data_json': warning: URI.unescape is obsolete

^ I've looked into this, and from what I can tell this warning is due to the method not following some kind of spec. It seems like this will eventually be resolved internally by the URI library, but the way we call the method will remain the same. So there's nothing we can do. Someone please correct me if I'm wrong about this.

And from what I can tell that's it. These warnings seem like they should be ignored. Am I missing anything?

@zachfeldman
Copy link
Contributor

Nope sounds good! Gonna merge this @lynndylanhurley

@zachfeldman zachfeldman merged commit d206c40 into lynndylanhurley:master Dec 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants