Skip to content

Commit

Permalink
Apply PR suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Apr 22, 2024
1 parent ce0a80f commit 019c876
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ruby_lsp/global_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
10 changes: 10 additions & 0 deletions test/global_state_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 019c876

Please sign in to comment.