From e32e49cccb75f4e94e9e813a7bdde78bc77e8deb Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 20 Aug 2022 13:25:36 +0900 Subject: [PATCH] Add server mode status to `-V` option When YJIT (disabled by default) is enabled in Ruby, it is displayed as follows. ```console % ruby --yjit -ve 'RubyVM::YJIT.enabled?' ruby 3.2.0dev (2022-08-18T08:09:08Z master b0b9f7201a) +YJIT [x86_64-darwin19] ``` `+YJIT` is added when YJIT is enabled. This is a change inspired by it. Below is before and after `rubocop -V`. ## Before ```console % rubocop -V 1.35.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.2.0 x86_64-darwin19) - rubocop-performance 1.14.3 - rubocop-rake 0.6.0 - rubocop-rspec 2.11.1 ``` ## After It makes the `-V` format like `ruby --version`. ### No server mode The platform (`x86_64-darwin19`) display will change slightly. ```console % rubocop -V 1.35.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.2.0) [x86_64-darwin19] - rubocop-performance 1.14.3 - rubocop-rake 0.6.0 - rubocop-rspec 2.11.1 ``` ### Server mode `+server` is added when server is enabled. ```console % rubocop -V 1.35.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.2.0) +server [x86_64-darwin19] - rubocop-performance 1.14.3 - rubocop-rake 0.6.0 - rubocop-rspec 2.11.1 ``` This change has the following benefits: - Shorthand alternative to `rubocop --server-status` - We can check the enable or disable of server mode in the bug report template --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- CONTRIBUTING.md | 2 +- changelog/change_add_server_mode_to_version_option.md | 1 + lib/rubocop/version.rb | 3 ++- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog/change_add_server_mode_to_version_option.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0c843d86474..fa3077f98e6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example: ``` $ [bundle exec] rubocop -V -1.35.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux) +1.35.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2) [x86_64-linux] - rubocop-performance 1.9.1 - rubocop-rspec 2.0.0 ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 810ce40440f..98d1539b805 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ do so. ```console $ rubocop -V -1.35.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux) +1.35.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2) [x86_64-linux] - rubocop-performance 1.9.1 - rubocop-rspec 2.0.0 ``` diff --git a/changelog/change_add_server_mode_to_version_option.md b/changelog/change_add_server_mode_to_version_option.md new file mode 100644 index 00000000000..a52db1f1e22 --- /dev/null +++ b/changelog/change_add_server_mode_to_version_option.md @@ -0,0 +1 @@ +* [#10940](https://github.com/rubocop/rubocop/pull/10940): Add server mode status to `-V` option. ([@koic][]) diff --git a/lib/rubocop/version.rb b/lib/rubocop/version.rb index e68293c8ebc..fa11b12d60e 100644 --- a/lib/rubocop/version.rb +++ b/lib/rubocop/version.rb @@ -7,7 +7,7 @@ module Version MSG = '%s (using Parser %s, ' \ 'rubocop-ast %s, ' \ - 'running on %s %s %s)' + 'running on %s %s)%s [%s]' CANONICAL_FEATURE_NAMES = { 'Rspec' => 'RSpec', 'Graphql' => 'GraphQL', 'Md' => 'Markdown', 'Thread_safety' => 'ThreadSafety' }.freeze @@ -19,6 +19,7 @@ def self.version(debug: false, env: nil) verbose_version = format(MSG, version: STRING, parser_version: Parser::VERSION, rubocop_ast_version: RuboCop::AST::Version::STRING, ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION, + server: Server.running? ? ' +server' : '', ruby_platform: RUBY_PLATFORM) return verbose_version unless env