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

Layout/SpaceAroundOperators incorrectly flags word arrays when used as first argument to method #9311

Closed
rmm5t opened this issue Dec 30, 2020 · 2 comments

Comments

@rmm5t
Copy link
Contributor

rmm5t commented Dec 30, 2020

Given:

a method call with one argument as a word-array (example taken from a Guardfile):

directories %w[app config lib test]

Expected behavior

No rubocop offenses.

Actual behavior

Guardfile:3:12: C: [Correctable] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
directories %w[app config lib test]

Actual (auto-correct) behavior

Guardfile:3:12: C: [Corrected] Layout/SpaceAroundOperators: Surrounding space missing for operator %.
directories%w[app config lib test]
           ^
Guardfile:3:12: C: [Corrected] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
directories %w[app config lib test]
           ^
Guardfile:3:13: C: Lint/Void: Operator % used in void context.
directories % w[app config lib test]
            ^

RuboCop version

bundle exec rubocop -V
1.7.0 (using Parser 3.0.0.0, rubocop-ast 1.3.0, running on ruby 2.5.8 x86_64-darwin19)
  - rubocop-minitest 0.10.2
  - rubocop-performance 1.9.1
  - rubocop-rails 2.9.1
  - rubocop-rake 0.5.1
@koic koic added the duplicate label Dec 30, 2020
@koic
Copy link
Member

koic commented Dec 30, 2020

This issue dup with #9290 and it has been fixed by #9291. Please wait the next release. Thank you.

@koic koic closed this as completed Dec 30, 2020
@jesperronn
Copy link

Thanks for both the issue report (@rmm5t ) and the fix (@koic)

is there a way to push for a release, since in my perspective, the suggested auto-fix is pretty serously wrong with 1.7.0

This is what happened for me:

rubocop lib/capistrano/tasks/setup.rake
Inspecting 1 file
C

Offenses:

lib/capistrano/tasks/setup.rake:157:20: C: [Correctable] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
        yum_install %w(nodejs yarn)
                   ^

1 file inspected, 1 offense detected, 1 offense auto-correctable


$ rubocop -A lib/capistrano/tasks/setup.rake
Inspecting 1 file
C

Offenses:

lib/capistrano/tasks/setup.rake:157:20: C: [Corrected] Layout/SpaceAroundOperators: Surrounding space missing for operator %.
        yum_install%w(nodejs yarn)
                   ^
lib/capistrano/tasks/setup.rake:157:20: C: [Corrected] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
        yum_install %w(nodejs yarn)
                   ^
lib/capistrano/tasks/setup.rake:157:23: C: [Corrected] Style/NestedParenthesizedCalls: Add parentheses to nested method call nodejs yarn.
        yum_install%w(nodejs yarn)
                      ^^^^^^^^^^^

1 file inspected, 3 offenses detected, 3 offenses corrected

The problem is that all these fixes will yield a clearly wrong result:

$ git diff -U-0 -- lib/capistrano/tasks/setup.rake 
diff --git a/lib/capistrano/tasks/setup.rake b/lib/capistrano/tasks/setup.rake
index 6f98919..2cb9253 100644
--- a/lib/capistrano/tasks/setup.rake
+++ b/lib/capistrano/tasks/setup.rake
@@ -157 +157 @@ namespace :setup do
-        yum_install %w(nodejs yarn)
+        yum_install % w(nodejs(yarn))

So my point is that we would need a bugfix release as fast as possible. My question is therefore on how I can help pushing for a new bugfix release now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants