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

False-positive auto-correct for Style/WhileUntilModifier? #8273

Closed
utkarsh2102 opened this issue Jul 8, 2020 · 8 comments
Closed

False-positive auto-correct for Style/WhileUntilModifier? #8273

utkarsh2102 opened this issue Jul 8, 2020 · 8 comments
Assignees

Comments

@utkarsh2102
Copy link
Member

Hi,

Whilst running rubocop, I came across this situation:

➜  puma git:(master) ✗ rubocop -a 
Inspecting 116 files
..........................................................
.....................................................C....

Offenses:

test/test_thread_pool.rb:148:17: C: [Corrected] Style/WhileUntilModifier: Favor modifier
 until usage when having a single-line body.
    Thread.pass until pool.spawned == 1 ||
                ^^^^^
test/test_thread_pool.rb:214:17: C: [Corrected] Style/WhileUntilModifier: Favor modifier
 until usage when having a single-line body.
    Thread.pass until pool.spawned == 0 ||
                ^^^^^

116 files inspected, 2 offenses detected, 2 offenses corrected
➜  puma git:(master) ✗ git diff
➜  puma git:(master) ✗ rubocop   
Inspecting 116 files
..........................................................
.....................................................C....

Offenses:

test/test_thread_pool.rb:148:17: C: Style/WhileUntilModifier: Favor modifier until usage when
 having a single-line body.
    Thread.pass until pool.spawned == 1 ||
                ^^^^^
test/test_thread_pool.rb:214:17: C: Style/WhileUntilModifier: Favor modifier until usage when
 having a single-line body.
    Thread.pass until pool.spawned == 0 ||
                ^^^^^

116 files inspected, 2 offenses detected

Even though the Style/WhileUntilModifier cop marks it as [Corrected], it still doesn't really auto-correct it.
Perhaps a bug?

@marcandre
Copy link
Contributor

Is this with the latest RuboCop?

@utkarsh2102
Copy link
Member Author

Hi Marc,

Is this with the latest RuboCop?

Yep, 0.87.1.

@marcandre marcandre self-assigned this Jul 8, 2020
@marcandre
Copy link
Contributor

I am also getting a "Infinite loop detected" error. You don't have that?

@utkarsh2102
Copy link
Member Author

Ah, weird. Initially, I didn't get it, but now I do.
Here's the stacktrace:

Infinite loop detected in /home/utkarsh/github/puma/test/test_thread_pool.rb.
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:289:in `check_for_infinite_loop'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:272:in `block in iterate_until_no_changes'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:271:in `loop'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:271:in `iterate_until_no_changes'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:242:in `do_inspection_loop'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:122:in `block in file_offenses'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:147:in `file_offense_cache'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:120:in `file_offenses'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:111:in `process_file'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:90:in `block in each_inspected_file'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:89:in `each'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:89:in `reduce'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:89:in `each_inspected_file'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:78:in `inspect_files'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/runner.rb:39:in `run'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/cli/command.rb:10:in `run'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/cli/environment.rb:17:in `run'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/cli.rb:65:in `run_command'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/cli.rb:72:in `execute_runners'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/lib/rubocop/cli.rb:41:in `run'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/exe/rubocop:13:in `block in <top (required)>'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/benchmark-0.1.0/lib/benchmark.rb:308:in `realtime'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/gems/rubocop-0.87.1/exe/rubocop:12:in `<top (required)>'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/bin/rubocop:23:in `load'
/home/utkarsh/.ruby-standalone/gems/ruby/2.7.1/bin/rubocop:23:in `<main>'

@marcandre
Copy link
Contributor

Ah, ok. Thanks for the report.

I can confirm this is a false positive and I'll try to fix it.

@utkarsh2102
Copy link
Member Author

Great, thanks!
You're the best! 🎉

@marcandre
Copy link
Contributor

Took a bit more time than I hoped 😅

A complete spec refactor and three (five, really) bug reports later, it's fixed 🎉

Thanks for reporting this bug!

@utkarsh2102
Copy link
Member Author

Oh wow, this is awesome!
Thank you! ❤️

KNejad pushed a commit to KNejad/rubocop that referenced this issue Jul 9, 2020
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

No branches or pull requests

2 participants