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
Load config from ~/rubocop/
and $XDG_CONFIG_HOME
#6682
Conversation
3e798b9
to
1596be3
Compare
In which context would I went here to see if there was an issue for XDG support already. My take on it would be this:
Then existing users of the dotfile would not see any breakages, but XDG-focused users could move their existing file to the correct location and have it load automatically. |
@Mange Gotcha, I did it the other way round. You are right, I will change the implementation. Thanks! |
3ed5a1b
to
2591f97
Compare
.rubocop.yml
from $XDG_CONFIG_HOME
~/rubocop/
and $XDG_CONFIG_HOME
~/rubocop/
and $XDG_CONFIG_HOME
~/rubocop/
and $XDG_CONFIG_HOME
58d8c61
to
e25c915
Compare
@Mange Fixed. I made some changes, this is the order being checked now:
|
I cannot find any references to a Is it from some other specification, or is it a mistake? Are you mixing up XDG_CONFIG_HOME with HOME? Normal config path according to the specification would be |
e25c915
to
38ced5b
Compare
@Mange That was indeed a mistake. I changed it to |
I think this looks good now overall. I hope the maintainers agree. |
@@ -31,17 +31,26 @@ def find_files_upwards(filename, start_dir, use_home: false) | |||
private | |||
|
|||
def traverse_files_upwards(filename, start_dir, use_home) | |||
traverse_file(filename, start_dir).each { |f| yield(f.to_s) } | |||
return unless use_home && (ENV.key?('HOME') || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me that we're mixing different concerns in this method. Ideally the file traversal should be separate from checks for which directory contains the config file.
@@ -15,6 +15,7 @@ class ConfigNotFoundError < Error | |||
# directories are inspected. | |||
class ConfigLoader | |||
DOTFILE = '.rubocop.yml'.freeze | |||
CONFIGFILE = 'rubocop/config.yml'.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this should be .rubocop
, not rubocop
. Usually config dirs are "hidden". I'd also name the constant CONFIG_FILE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files in XDG_CONFIG_HOME should not be hidden according to specs. The most common convention is appname/config
.
I left a few small comments. Generally I'm fine with the proposed solution. |
I'm closing this PR due to no recent activity. Feel free to re-open it if you ever come back to it. |
I re-opened this in #6895. |
Users now have an additional place they can have their own config file, if they prefer to not have dotfiles inside their home directory. Based on initial work by @tejasbubane in #6682.
if
$HOME
not setSpec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.8.html
Closes: #6662
[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.