Skip to content

Commit

Permalink
Fix an error when ocurring cop error
Browse files Browse the repository at this point in the history
Follow rubocop#8908.

This PR fixes the following error when ocurring cop error.

```console
% bundle exec rubocop
(snip)

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Layout/ExtraSpacing cop was inspecting
/Users/koic/src/github.com/koic/rubocop-issues/43/example.rb.
undefined method `config_store' for nil:NilClass
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/version.rb:35:in
`extension_versions'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/version.rb:21:in
`version'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli/command/execute_runner.rb:62:in
`display_error_summary'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli/command/execute_runner.rb:27:in
`execute_runner'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli/command/execute_runner.rb:17:in
`run'
```

It suppresses unexpected `undefined method `config_store' for nil:NilClass`.
  • Loading branch information
koic committed Oct 21, 2020
1 parent e0713ad commit 98e1021
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rubocop/version.rb
Expand Up @@ -18,6 +18,8 @@ def self.version(debug: false, env: nil)
rubocop_ast_version: RuboCop::AST::Version::STRING,
ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION,
ruby_platform: RUBY_PLATFORM)
return verbose_version unless env

extension_versions = extension_versions(env)
return verbose_version if extension_versions.empty?

Expand Down

0 comments on commit 98e1021

Please sign in to comment.