Fix rubocop offenses on generated files

10 views
Skip to first unread message

Nicolás Alonso

unread,
Oct 23, 2019, 5:52:49 AM10/23/19
to rspec
**Is your feature request related to a problem? Please describe.**
After a scaffold with `rails g scaffold Post name short_description large_description:text position:integer` then i run `rubocop --parallel` and found a lot of offenses.

I have identified:
- Layout/EmptyLinesAroundBlockBody
- Layout/EmptyLines 
- Style/BlockDelimiters
- Layout/SpaceInsideHashLiteralBraces
- Style/HashSyntax
- Layout/IndentFirstArgument
- Layout/IndentFirstArrayElement
- Style/StringLiterals
- FrozenStringLiteralComment


**Describe the solution you'd like**
I would like that the generated files don't have rubocop offenses

**Describe alternatives you've considered**
I have considered turning off some crops but i think is not the way.

I have some time to do this, if you are ok i'll start in the order that i have mentioned the offenses.
Which branch should be my base? I think that some offenses can be from version 3 and other ones like `Style/HashSyntax` needs to be from master

**Additional context**
rails: 5.2.3
ruby: 2.6.5
rspec-rails 4.0.0.pre



Philipp Pirozhkov

unread,
Oct 23, 2019, 6:21:17 AM10/23/19
to rs...@googlegroups.com
Hey Nicolás

Thanks for reporting this.

Since RuboCop configuration varies from project to project, it would be impossible to come up with a template that would fit all the style combinations.
Do you think it makes sense to adjust the template in rspec-rails (I suggest it's coming from it) to appease the default RuboCop/RuboCop-RSpec configurations?

If one's project's RuboCop configuration is non-default, I believe it would be possible to override the templates in your project. This makes most sense if you actively use scaffolds.

Also, there's an option in `rubocop` to `--auto-correct` all the offences. I've seen people using scripts to also pass a list of files in the git working tree to `rubocop` and reduce its auto-correction to only this set of files.

- Phil

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/748e8a6c-7496-4914-b43e-1cca47bb0be0%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages