Skip to content

Commit

Permalink
tests: add delete last line
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jan 2, 2025
1 parent c860f67 commit cd971d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/golinters/internal/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ func ExtractDiagnosticFromPatch(

func toDiagnostic(ft *token.File, change Change, adjLine int) analysis.Diagnostic {
from := change.From + adjLine
if from > ft.LineCount() {
from = ft.LineCount()
}
// if from > ft.LineCount() {

Check failure on line 255 in pkg/golinters/internal/diff.go

View workflow job for this annotation

GitHub Actions / golangci-lint

commentedOutCode: may want to remove commented-out code (gocritic)
// from = ft.LineCount()
// }

start := ft.LineStart(from)

Expand Down
7 changes: 7 additions & 0 deletions pkg/golinters/internal/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ func Test_parse(t *testing.T) {
log logutils.Log
expected []Change
}{
{
diff: "delete_last_line.diff",
expected: []Change{{
From: 10,
To: 10,
}},
},
{
diff: "delete_only_first_lines.diff",
expected: []Change{{
Expand Down
9 changes: 9 additions & 0 deletions pkg/golinters/internal/testdata/delete_last_line.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git i/main.go w/main.go
index ef3cbb7..52a7925 100644
--- i/main.go
+++ w/main.go
@@ -7,4 +7,3 @@ import (
func main() {
fmt.Println("hello world")
}
-

0 comments on commit cd971d2

Please sign in to comment.