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 from

Conversation

unasuke
Copy link
Contributor

@unasuke 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 7 commits April 13, 2018 00:29
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.
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
```
show warning messages from ruby on ci
Suppress warning message that enabled from ruby 2.6 .
To format ruby files generated by ragel.
To suppress warning messages from ruby
"mismatched indentations at 'when' with 'case'" .
@unasuke unasuke force-pushed the reduce_warnings_on_ruby_2_6 branch from 197ecc3 to 6a246bc Compare April 12, 2018 17:17
@jeremy jeremy closed this in c8657d7 Apr 13, 2018
jeremy pushed a commit that referenced this pull request Apr 13, 2018
@unasuke unasuke deleted the reduce_warnings_on_ruby_2_6 branch April 13, 2018 07:20
@unasuke
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants