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

Reduce warnings "mismatched indentations" on ruby 2.6 #1222

Closed
wants to merge 7 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@unasuke
Copy link
Contributor

unasuke commented Apr 12, 2018

⚠️ This pull-req is dependent #1221 . If you want to merge this, first, merge #1221 please.

summary

In Ruby 2.6 with option "-w", introduce warning message "mismatched indentations" by following case-when syntax.

case foo
  when bar
    "do something"
  when baz
    "do something else"
  else
    "do something or do nothing"
end

Fix to like this, warning message suppressed.

case foo
when bar
  "do something"
when baz
  "do something else"
else
  "do something or do nothing"
end

why

In some gem's test (that dependent to mail.gem) with "-w" option, output a ton of warning messages that makes test slow and hard to see the test results.

e.g. https://travis-ci.org/rails/rails/jobs/365674633

I know that this issue comes from auto generated ruby codes by ragel.
So "real fix" of this issue is making a patch to ragel (also I know!)

But...but, ragel is written in C. I couldn't fix the indentation issue.

Therefore, I add rufo gem as the development dependency and format in rake task to fix wrong (from ruby 2.6) case-when indents.

unsolved

Can't fix by using rufo in some case of warning messages.

  • statement not reached
  • assigned but unused variable

unasuke and others added some commits Apr 12, 2018

Set full path of the ragel source file to rake task
In Rake v12.1.0 or higher, the algorithm of resolve file dependency
was changed in ruby/rake#39 .

Then rake task "ragel:generate" is works incorrectry that require
wrong ragel source file.
As the example, rake resolves "lib/mail/parsers/address_lists_parser.rb"
needs "lib/mail/parsers/address_lists.rl", but this file is not exist.

Therefore, fixed that to pass full path of the ragel source file
to rule.
Perform `gem install bundler` to address `LoadError: cannot load such
file -- bundler/dep_proxy`

```ruby
bundle exec rake
bundler: failed to load command: rake (/home/travis/build/mikel/mail/vendor/bundle/ruby/2.5.0/bin/rake)
LoadError: cannot load such file -- bundler/dep_proxy
```
Set env "-w" to RUBYOPT
show warning messages from ruby on ci
Fix case-when indent in unicode.rb
Suppress warning message that enabled from ruby 2.6 .
Add rufo as development dependency
To format ruby files generated by ragel.
bundle exec rufo lib/mail/parsers/*.rb
To suppress warning messages from ruby
"mismatched indentations at 'when' with 'case'" .

@unasuke unasuke force-pushed the unasuke:reduce_warnings_on_ruby_2_6 branch from 197ecc3 to 6a246bc Apr 12, 2018

@jeremy

jeremy approved these changes Apr 13, 2018

@jeremy jeremy closed this in c8657d7 Apr 13, 2018

jeremy added a commit that referenced this pull request Apr 13, 2018

@unasuke unasuke deleted the unasuke:reduce_warnings_on_ruby_2_6 branch Apr 13, 2018

@unasuke

This comment has been minimized.

Copy link
Contributor Author

unasuke commented Apr 13, 2018

@jeremy Thank you!!!l 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.