-
Notifications
You must be signed in to change notification settings - Fork 224
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
Ignores .rubycritic.yml file #303
Comments
I think this is just a simple typo in your config caused by a typo in the example config from the README. I had some issues until I updated the I've submitted a pull request to address this: #315 |
Fixes: Ignores .rubycritic.yml file whitesmith#303 whitesmith#303. Update the documentation to indicate that the key in the .rubycritic.yml configuration file which controls the output format is 'formats' rather than 'format'. Fix a bug in RubyCritic::Cli::Options#to_h which prevents a setting in the YAML configuration file from being used when the setting is an Array (as is the case for the output formats). Modify RubyCritic::CLI::Options::File#formats to return an array of symbols instead of an array of strings, to be consistent with how RubyCritic::CLI::Options::Argv#parse returns the array. Also modify it so it can accept a single output format or a list of formats. The documentation indicates that either is acceptable but the code assumed the input was always an array. Signed-off-by: Christopher Voltz <[email protected]>
It would be nice if RubyCritic would give an error message if the configuration file was incorrect, rather than just silently ignoring mistakes. Fixing or removing the line doesn't get RubyCritic to use the other settings so the problem is more then just a single key being wrong. I looked into the issue some more and it looks like
However, fixing the entry in the
That problem is caused by the code assuming rubycritic/lib/rubycritic/cli/options/file.rb Lines 80 to 82 in 987d142
So either the sample configuration file needs to show
or
Unfortunately, even that is not enough to fix this problem because there is also a bug in rubycritic/lib/rubycritic/cli/options.rb Lines 23 to 30 in a6ddc92
argv_option[:formats] is an empty array when it isn't specified on the CLI but any empty array isn't nil so the empty array from the CLI options (argv_option ) overwrites the setting in the configuration file (file_hash ) even when it is specified. This can be fixed with an extra check to see if the argument is an empty array:
Note that Finally, it appears that the formats must be symbols in the array, rather then strings. If we look at rubycritic/lib/rubycritic/cli/options/argv.rb Lines 40 to 51 in 723c26f
So, we need to make another change to
Created pull request #316 to fix the problems. |
Fixes: Ignores .rubycritic.yml file #303 #303. Update the documentation to indicate that the key in the .rubycritic.yml configuration file which controls the output format is 'formats' rather than 'format'. Fix a bug in RubyCritic::Cli::Options#to_h which prevents a setting in the YAML configuration file from being used when the setting is an Array (as is the case for the output formats). Modify RubyCritic::CLI::Options::File#formats to return an array of symbols instead of an array of strings, to be consistent with how RubyCritic::CLI::Options::Argv#parse returns the array. Also modify it so it can accept a single output format or a list of formats. The documentation indicates that either is acceptable but the code assumed the input was always an array. Signed-off-by: Christopher Voltz <[email protected]>
I tried testing with the example
.rubycritic.yml
configuration file:Changes in the configuration file (e.g.,
no_browser
,path
, andpaths
), don't affect the settings rubycritic actually uses when it runs. It appears to always use the default settings (i.e., as if the.rubycritic.yml
wasn't present) unless command line arguments are specified (then the CLI setting is used). When rubycritic runs, it does read the configuration file. It just appears to ignore the settings.Also, it looks like the documented
format
option for the config file has changed toformats
but the documentation hasn't been updated to match (seeRubyCritic::Cli::Options::File::formats
).The text was updated successfully, but these errors were encountered: