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

Rails/DynamicFindBy cop is causing bad formatting on safe auto-correct #379

Closed
ZachWileman opened this issue Oct 22, 2020 · 0 comments · Fixed by #465
Closed

Rails/DynamicFindBy cop is causing bad formatting on safe auto-correct #379

ZachWileman opened this issue Oct 22, 2020 · 0 comments · Fixed by #465

Comments

@ZachWileman
Copy link

ZachWileman commented Oct 22, 2020

When trying to run safe auto-correct to resolve issues in my Rails project, I see a large number of incorrect formats occurring. When disabling the Rails/DynamicFindBy cop, this issue seems to go away.

Here's a link to the Rubocop configuration that I'm using: https://gist.github.com/zdw27f/9a935a27e55180ff66cc3b94ca107b86
.rubocop.yml < rubocop-rails.yml < rubocop-core.yml

Here's an example of running bin/rubocop -a that shows what the formatting looks like w/ and w/o the DynamicFindBy cop: https://gist.github.com/zdw27f/1e430dcfb255e73694ff90af05b78217


Expected behavior

I expect this code to get formatted to look like this.

Actual behavior

Currently, this code gets formatted into this when the Rails/DynamicFindBy cop is enabled.

Steps to reproduce the problem

Create a Rails project that uses the Rubocop configuration I've mentioned above, and then copy the example code into a controller file (not necessarily sure if it has to be a controller, that's just where I found the issue), and then run bin/rubocop -a and see how it affects the file.

RuboCop version

EDIT: Upgraded to rubocop-ast-1.0.0 and got the same results.

$ rubocop -V
1.0.0 (using Parser 2.7.2.0, rubocop-ast 1.0.0, running on ruby 2.7.0 x86_64-darwin18)
  - rubocop-performance 1.8.1
  - rubocop-rails 2.8.1
koic added a commit to koic/rubocop-rails that referenced this issue Apr 26, 2021
Fixes rubocop#379.

This PR marks `Rails/DynamicFindBy` as unsafe.
@koic koic closed this as completed in #465 Apr 26, 2021
koic added a commit that referenced this issue Apr 26, 2021
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