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
[Fix #3904] Build config & sync cop descriptions #6600
[Fix #3904] Build config & sync cop descriptions #6600
Conversation
5af24fe
to
8fb2d70
Compare
cf6c269
to
1018a4c
Compare
Why do you even load and dump it? I'd just merge the data from the config with whatever we get from the source file without actually regenerating the file itself. |
0ecd7b5
to
98b769a
Compare
This is here for me to check diffs as I play around with the code. This commit will eventually be squashed.
98b769a
to
dfc0f63
Compare
@garettarrowood What's the state here? |
@bbatsov - Perhaps there is a technique to go about this that has escaped me so far. I'm open to suggestions :). |
Perhaps I could cycle through the file twice. The first time removing all the Descriptions. Then cycle through it again and add the ones from the cop files themselves. It seems inefficient, and a lot of extra file operations than would be necessary. But I can give it a go again with that idea. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it. |
This PR addresses #3904. It deduplicates
Cop
descriptions by loading the config and replacing itsDescription
s with the ones held inyard
. That makes the source code the single source of truth for descriptions. This was heavily inspired by @backus 's implementation inrubocop-rspec
. (Thank you sir!)There are a lot of consequences of loading and dumping
YAML
. Here are some of the changes you will find inconfig/default.yml
that are noteworthy but (imo) seem ok.*
and#
. They are not replaced inVersionAdded
andVersionChanged
settings.CacheRootDirectory: ~
are replaced withCacheRootDirectory:
. I don't like this, but it's still valid yaml. It seems to boil down to aesthetic, though.Metrics/LineLength
setting enforced in the repo already. So comments will appear uniform in the file.But. There is a deal breaking change here. All comments are stripped from the config. I looked around for a solution and only found ones involving adding comments in one line at a time. While searching for alternative yaml parsers besides
YAML
/Pysch
, I found this blog post which suggests the only comment preserving YAML parser is ruamel, which is for Python.Possible solutions:
AllowSymlinksInCacheRootDirectoryDescription
and give it the associated comment as a value to save.File
, instead of loading the config itself.Last note: I believe it is to our benefit to load config, make a change, and the dump it back out. After syncing descriptions, we could explore syncing any/all other values. Procedurally updating our configuration feels like a step in the right direction.
Thoughts and ideas?
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.