Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 8d53850

Browse files
authored
feat: include more data in diagnostic (#52)
1 parent fdeb381 commit 8d53850

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

lib/credo_language_server.ex

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ defmodule CredoLanguageServer do
2727
CodeActionContext,
2828
CodeActionOptions,
2929
CodeActionParams,
30+
CodeDescription,
3031
Diagnostic,
3132
DidOpenTextDocumentParams,
3233
InitializeParams,
@@ -384,13 +385,13 @@ defmodule CredoLanguageServer do
384385
},
385386
severity: category_to_severity(issue.category),
386387
data: %{check: issue.check, file: issue.filename},
387-
message: """
388-
#{issue.message}
389-
390-
## Explanation
391-
392-
#{CredoLanguageServer.Runtime.call(lsp.assigns.runtime, {issue.check, :explanations, []})[:check]}
393-
"""
388+
source: "credo",
389+
code: Macro.to_string(issue.check),
390+
code_description: %CodeDescription{
391+
href:
392+
"https://hexdocs.pm/credo/#{Macro.to_string(issue.check)}.html"
393+
},
394+
message: issue.message
394395
}
395396

396397
Diagnostics.put(

test/credo_language_server_test.exs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,17 @@ defmodule CredoLanguageServerTest do
147147
assert_notification "textDocument/publishDiagnostics",
148148
%{
149149
"uri" => ^uri,
150-
"diagnostics" => [%{"severity" => 3}]
150+
"diagnostics" => [
151+
%{
152+
"source" => "credo",
153+
"code" => "Credo.Check.Readability.ModuleDoc",
154+
"codeDescription" => %{
155+
"href" =>
156+
"https://hexdocs.pm/credo/Credo.Check.Readability.ModuleDoc.html"
157+
},
158+
"severity" => 3
159+
}
160+
]
151161
}
152162
end
153163

0 commit comments

Comments
 (0)