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

Redo the Rubocop config #564

Merged
merged 6 commits into from
Nov 25, 2023
Merged

Redo the Rubocop config #564

merged 6 commits into from
Nov 25, 2023

Conversation

Splines
Copy link
Member

@Splines Splines commented Nov 15, 2023

Related:

See the new .rubocop.yml from this PR.

Automatically Generated Configuration. And some useful commands.

bundle exec rubocop --autocorrect (maybe also use option: --disable-uncorrectable)

rubocop --auto-gen-config --no-exclude-limit
[work through .rubocop_todo.yml]
rubocop --regenerate-todo

Some stats using the new config at commit e768bfc:

$ bundle install

# First: Safe autocorrects
$ bundle exec rubocop --autocorrect 
704 files inspected, 7952 offenses detected, 6814 offenses corrected, 721 more offenses can be corrected with `rubocop -A`

# Second: Unsafe autocorrects
$ bundle exec rubocop -A
704 files inspected, 1350 offenses detected, 938 offenses corrected

# Then: generate todo rubocop file
$ rubocop --auto-gen-config --no-exclude-limit
704 files inspected, 413 offenses detected
Created .rubocop_todo.yml.

This newly created todo file "only" contains 37 offenses that couldn't be autocorrected (although for some we get the comment they can be using unsafe autocorrection, but we've done that in the step beforehand?! -> don't know why this is the case). This file can be found here, maybe we want to disable some of the cops from there already...

(Note: of course one also has to watch our carefully when running rubocop with unsafe autocorrects as this could possibly modify the code in a way that is semantic and not just syntactic. A strategy for a future PR could therefore consist of running the safe autocorrects first and commit, then do a separate commit for just unsafe autocorrects. This will ease the review process. Finally, we have the rubocop todo file that we can either directly try to work off, or do it from time to time, e.g. in another PR).

Many cops were explicitly enabled. We don't necessarily need to do that
since the defaults of RuboCop are always included. So we just specify
where we deviate from RuboCops default values.
This has as consequence that whenever we upgrade RuboCop, we should run
checks on the whole codebase to see if new cops somehow don't work with
our code. We can then discuss if we maybe want to explicitly disable a new
cop.
@Splines Splines self-assigned this Nov 15, 2023

This comment was marked as off-topic.

.rubocop.yml Outdated Show resolved Hide resolved
@Splines Splines marked this pull request as ready for review November 21, 2023 15:55
@Splines
Copy link
Member Author

Splines commented Nov 23, 2023

@fosterfarrell9 Apart from the comment you gave, do you think we can merge?

@Splines Splines merged commit 5469dc1 into mampf-next Nov 25, 2023
6 of 7 checks passed
@Splines Splines deleted the feature/redo-rubocop-config branch November 25, 2023 16:52
@Splines Splines mentioned this pull request Dec 19, 2023
1 task
Splines added a commit that referenced this pull request Jan 6, 2024
* Shorten RuboCop config

Many cops were explicitly enabled. We don't necessarily need to do that
since the defaults of RuboCop are always included. So we just specify
where we deviate from RuboCops default values.

* Add comment regarding "NewCops"

* Add "NewCops: enable"

This has as consequence that whenever we upgrade RuboCop, we should run
checks on the whole codebase to see if new cops somehow don't work with
our code. We can then discuss if we maybe want to explicitly disable a new
cop.

* Update RuboCop related packages in Gemfile

* Add WordArray & EmptyMethod enforced styles

* Sort RuboCop keys alphabetically & improve file comment
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 this pull request may close these issues.

2 participants