Skip to content

Commit

Permalink
fix(credo): calculate accurate span from trigger (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanberg committed Apr 20, 2024
1 parent c21cda6 commit 90cd35a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/next_ls/extensions/credo_extension.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,17 @@ defmodule NextLS.CredoExtension do
{{:credo, path} = namespace, refs} = Map.pop(refs, ref)

for issue <- issues do
column = (issue.column || 1) - 1

diagnostic = %Diagnostic{
range: %Range{
start: %Position{
line: issue.line_no - 1,
character: (issue.column || 1) - 1
character: column
},
end: %Position{
line: issue.line_no - 1,
character: 999
character: column + String.length(issue.trigger)
}
},
severity: category_to_severity(issue.category),
Expand Down
6 changes: 3 additions & 3 deletions test/next_ls/extensions/credo_extension_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ defmodule NextLS.CredoExtensionTest do
},
"message" => "There should be no calls to `dbg/1`.",
"range" => %{
"end" => %{"character" => 999, "line" => 2},
"end" => %{"character" => 7, "line" => 2},
"start" => %{"character" => 4, "line" => 2}
},
"severity" => 2,
Expand Down Expand Up @@ -146,7 +146,7 @@ defmodule NextLS.CredoExtensionTest do
},
"message" => "There should be no calls to `dbg/1`.",
"range" => %{
"end" => %{"character" => 999, "line" => 2},
"end" => %{"character" => 7, "line" => 2},
"start" => %{"character" => 4, "line" => 2}
},
"severity" => 2,
Expand All @@ -163,7 +163,7 @@ defmodule NextLS.CredoExtensionTest do
},
"message" => "Modules should have a @moduledoc tag.",
"range" => %{
"end" => %{"character" => 999, "line" => 0},
"end" => %{"character" => 13, "line" => 0},
"start" => %{"character" => 10, "line" => 0}
},
"severity" => 3,
Expand Down

0 comments on commit 90cd35a

Please sign in to comment.