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

Style/MethodCallWithArgsParentheses: auto-correct generates invalid ruby code #6071

Closed
bayandin opened this issue Jul 3, 2018 · 0 comments · Fixed by #6083
Closed

Style/MethodCallWithArgsParentheses: auto-correct generates invalid ruby code #6071

bayandin opened this issue Jul 3, 2018 · 0 comments · Fixed by #6083

Comments

@bayandin
Copy link
Contributor

bayandin commented Jul 3, 2018

I have enabled Style/MethodCallWithArgsParentheses cop in my .rubocop.yml:

Style/MethodCallWithArgsParentheses:
  Enabled: true

And my file:

puts "boom".colorize(:red)
puts 2

When I run it with auto-correct it generates invalid ruby code
Could be related to #5951 or #5983


Expected behavior

Auto-corrected file should be:

puts("boom".colorize(:red))
puts(2)

Actual behavior

Auto-corrected file is invalid:

puts(boom".colorize(:red)
puts(2)

Steps to reproduce the problem

$ rubocop --debug --auto-correct rubocop_example.rb --only Style/MethodCallWithArgsParentheses

For /Volumes/Second/work/bma-calabash: configuration from /Volumes/Second/work/bma-calabash/.rubocop.yml
Inheriting configuration from /Volumes/Second/work/bma-calabash/.rubocop_todo.yml
Default configuration from /Users/bayandin/.rvm/gems/ruby-2.5.1/gems/rubocop-0.57.2/config/default.yml
Inheriting configuration from /Users/bayandin/.rvm/gems/ruby-2.5.1/gems/rubocop-0.57.2/config/enabled.yml
Inheriting configuration from /Users/bayandin/.rvm/gems/ruby-2.5.1/gems/rubocop-0.57.2/config/disabled.yml
Inspecting 1 file
Scanning /Volumes/Second/work/bma-calabash/rubocop_example.rb
F

Offenses:

rubocop_example.rb:1:1: C: [Corrected] Style/MethodCallWithArgsParentheses: Use parentheses for method calls with arguments.
puts "boom".colorize(:red)
^^^^^^^^^^^^^^^^^^^^^^^^^^
rubocop_example.rb:1:10: F: Lint/Syntax: unterminated string meets end of file
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)
puts(boom".colorize(:red)
         ^
rubocop_example.rb:2:1: C: [Corrected] Style/MethodCallWithArgsParentheses: Use parentheses for method calls with arguments.
puts 2
^^^^^^

1 file inspected, 3 offenses detected, 2 offenses corrected
Finished in 0.41572399996221066 seconds
$ cat rubocop_example.rb 

puts(boom".colorize(:red)
puts(2)

RuboCop version

$ rubocop -V
0.57.2 (using Parser 2.5.1.0, running on ruby 2.5.1 x86_64-darwin17)
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.

1 participant