From 98e1021703846c094afcfd1cd2db928f42053886 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Wed, 21 Oct 2020 15:43:11 +0900 Subject: [PATCH] Fix an error when ocurring cop error Follow #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`. --- lib/rubocop/version.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rubocop/version.rb b/lib/rubocop/version.rb index f9dc4311bcc..4458c627488 100644 --- a/lib/rubocop/version.rb +++ b/lib/rubocop/version.rb @@ -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?