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

Performance/StringIdentifierArgument autocorrect broke rack-unreloader autoload method #346

Closed
davekaro opened this issue Mar 12, 2023 · 0 comments · Fixed by #349
Closed
Labels
bug Something isn't working

Comments

@davekaro
Copy link

Expected behavior

Running rubocop with Performance/StringIdentifierArgument enabled on a file that uses https://github.com/jeremyevans/rack-unreloader should not autocorrect the parameters to Unreloader.autoload to symbols.

Actual behavior

The Performance/StringIdentifierArgument turns the string path argument to Unreloader.autoload to a symbol, which causes exception:

<internal:dir>:220:in `glob': no implicit conversion of Symbol into String (TypeError)
	from /Users/dave/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rack-unreloader-2.1.0/lib/rack/unreloader.rb:31:in `block in expand_paths'

Steps to reproduce the problem

I started with https://github.com/jeremyevans/roda-sequel-stack/, followed the README to setup my app:

git clone https://github.com/jeremyevans/roda-sequel-stack.git my_app
cd my_app
rake "setup[MyApp]"

Then I added the standard gem, which enables the Performance/StringIdentifierArgument cop, and noticed the incorrect autocorrect.

RuboCop version

$ bundle exec rubocop -V
1.44.1 (using Parser 3.2.1.1, rubocop-ast 1.27.0, running on ruby 3.2.1) [arm64-darwin22]
@koic koic added the bug Something isn't working label Mar 15, 2023
koic added a commit to koic/rubocop-performance that referenced this issue Mar 15, 2023
…ierArgument`

Fixes rubocop#346.

This PR fixes a false positive for `Performance/StringIdentifierArgument`
when using a command method with receiver. It makes that cop to allow
some command methods that don't normally specify a receiver.
@koic koic closed this as completed in #349 Mar 17, 2023
koic added a commit that referenced this issue Mar 17, 2023
…e_string_identifier_argument

[Fix #346] Fix a false positive for `Performance/StringIdentifierArgument`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants