From 019c876acc4649d505c7af78b048a82d569a40f3 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Mon, 22 Apr 2024 15:48:34 -0400 Subject: [PATCH] Apply PR suggestion --- lib/ruby_lsp/global_state.rb | 2 +- test/global_state_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ruby_lsp/global_state.rb b/lib/ruby_lsp/global_state.rb index 491c04e04..69a69d132 100644 --- a/lib/ruby_lsp/global_state.rb +++ b/lib/ruby_lsp/global_state.rb @@ -62,7 +62,7 @@ def apply_options(options) @formatter = detect_formatter if @formatter == "auto" specified_linters = options.dig(:initializationOptions, :linters) - @linters = specified_linters ? specified_linters : detect_linters + @linters = specified_linters || detect_linters encodings = options.dig(:capabilities, :general, :positionEncodings) @encoding = if !encodings || encodings.empty? diff --git a/test/global_state_test.rb b/test/global_state_test.rb index a110c5dac..77898a76c 100644 --- a/test/global_state_test.rb +++ b/test/global_state_test.rb @@ -122,6 +122,16 @@ def test_linter_auto_detection assert_equal(["rubocop"], state.instance_variable_get(:@linters)) end + def test_specifying_empty_linters + stub_dependencies("rubocop" => "1.2.3") + state = GlobalState.new + state.apply_options({ + initializationOptions: { linters: [] }, + }) + + assert_empty(state.instance_variable_get(:@linters)) + end + private def stub_dependencies(dependencies)