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

Warnings when parsing #1384

Open
mikosullivan opened this issue Mar 14, 2020 · 3 comments
Open

Warnings when parsing #1384

mikosullivan opened this issue Mar 14, 2020 · 3 comments

Comments

@mikosullivan
Copy link

When I create a new Mail::Address object, a long list of warnings it output. For example, this code:

#!/usr/bin/ruby -w
require 'mail'
Mail::Address.new 'miko@example.com'

produces these errors:

/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32454: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32615: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32651: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32740: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32756: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32822: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32863: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32888: warning: statement not reached
/var/lib/gems/2.5.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:31984: warning: assigned but unused variable - testEof

The fixes are actually pretty easy... all that's needed is removing some lines. I've attached a file in which I made those changes. Just search for "CHANGE:"

address_lists_parser.rb.txt

@qortex
Copy link

qortex commented Mar 26, 2020

A fix would be really appreciated. I get the warnings in all my RSpec tests even though my app does not have anything to do with the mail gem:

/home/mic/.rbenv/versions/2.6.5/bin/ruby -I/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.1/lib:/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-support-3.9.2/lib /home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32454: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32615: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32651: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32740: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32756: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32822: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32863: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32888: warning: statement not reached
/home/mic/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:31984: warning: assigned but unused variable - testEof

@mrrusof
Copy link

mrrusof commented Jul 19, 2020

I get the following warnings when I run tests for my project:

/home/ruslan/.rvm/gems/ruby-2.7.1/gems/mail-2.7.1/lib/mail/parsers/content_type_parser.rb:939: warning: statement not reached
/home/ruslan/.rvm/gems/ruby-2.7.1/gems/mail-2.7.1/lib/mail/parsers/content_type_parser.rb:963: warning: statement not reached
/home/ruslan/.rvm/gems/ruby-2.7.1/gems/mail-2.7.1/lib/mail/parsers/content_type_parser.rb:709: warning: assigned but unused variable - testEof

In the case of unreachable statements, it looks like there are at least two instances where a block is preceded by next, making the block unreachable.

@qortex
Copy link

qortex commented Jul 19, 2020

Did a blog post on how to suppress those when it's not patched upstream: https://dev.to/qortex/ruby-suppress-those-warnings-you-can-t-do-anything-about-6ie

enescakir added a commit to ubicloud/ubicloud that referenced this issue Jun 8, 2023
These warnings make reading rspec results harder. mikel/mail gem has 3
years old issues at GitHub for them. But they aren't resolved.

mikel/mail#1384
mikel/mail#1424
mikel/mail#1572
enescakir added a commit to ubicloud/ubicloud that referenced this issue Jun 8, 2023
These warnings make reading rspec results harder. mikel/mail gem has 3
years old issues at GitHub for them. But they aren't resolved.

mikel/mail#1384
mikel/mail#1424
mikel/mail#1572
eval added a commit that referenced this issue Jan 3, 2024
@eval eval mentioned this issue Jan 3, 2024
eval added a commit that referenced this issue Jan 3, 2024
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 a pull request may close this issue.

3 participants