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
undefined method `to_sym' for nil:NilClass in some Rails cop #127
Comments
I cannot reproduce this issue. Is something set in .rubocop.yml? |
No I can reproduce it in docker environment:
|
Thanks for the reproduction step with Docker environment. I can reproduce it. |
I can reproduce the bug only if the .rubocop.yml exists. $ ls -A
dummy.rb
$ rubocop -r rubocop-rails --only Rails/FilePath dummy.rb --cache false
# => display the error
$ touch .rubocop.yml
$ rubocop -r rubocop-rails --only Rails/FilePath dummy.rb --cache false
# => no error And I can avoid the error with $ ls -A
dummy.rb
$ rubocop -r rubocop-rails --only Rails/FilePath dummy.rb --cache false
# => display the error
$ rubocop -r rubocop-rails --only Rails/FilePath dummy.rb --cache false --force-default-config
# => no error I can also reproduce the error with |
I confess I'm swimming in a sea of confusion, but I wonder if I've stumbled across something relevant to this thread. |
I try to add default value to Rails/FilePath:
EnforcedStyle: "slashes" |
When the config file path is same as the default config file, use `ConfigLoader.default_configuration` instead of create a new config. Because some plugins add their default config values to `ConfigLoader.default_configuration`. So the Cops of the plugins expect that default config values exists. Fix rubocop/rubocop-rails#127
I found my situation caused by Test environment:
Without
With
|
When the config file path is same as the default config file, use `ConfigLoader.default_configuration` instead of create a new config. Because some plugins add their default config values to `ConfigLoader.default_configuration`. So the Cops of the plugins expect that default config values exists. Fix rubocop/rubocop-rails#127 Co-authored-by: Bozhidar Batsov <bozhidar@batsov.com>
rubocop -r rubocop-rails --only Rails/FilePath dummy.rb -d
shows following error:It seems other Rails cops supporting EnfocedStyle cause same error too.
I cannot reproduce without rubocop-rails.
Expected behavior
No errors.
Actual behavior
Error occurred with some Rails cops.
Steps to reproduce the problem
RuboCop version
Include the output of
rubocop -V
orbundle exec rubocop -V
if using Bundler. Here's an example:The text was updated successfully, but these errors were encountered: