mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
Fix #106: fix transitive expanding of nolint: we could nolint more lines than needed
This commit is contained in:
parent
7495c4d13a
commit
9fa9e2b3f8
14 changed files with 103 additions and 52 deletions
|
@ -21,6 +21,12 @@ func newNolintFileIssue(line int, fromLinter string) result.Issue {
|
|||
}
|
||||
}
|
||||
|
||||
func newNolint2FileIssue(line int, fromLinter string) result.Issue {
|
||||
i := newNolintFileIssue(line, fromLinter)
|
||||
i.Pos.Filename = filepath.Join("testdata", "nolint2.go")
|
||||
return i
|
||||
}
|
||||
|
||||
func TestNolint(t *testing.T) {
|
||||
p := NewNolint(astcache.NewCache(logutils.NewStderrLog("")))
|
||||
|
||||
|
@ -76,6 +82,24 @@ func TestNolint(t *testing.T) {
|
|||
for i := 39; i <= 45; i++ {
|
||||
processAssertEmpty(t, p, newNolintFileIssue(i, "any"))
|
||||
}
|
||||
|
||||
// check bug with transitive expanding for next and next line
|
||||
for i := 1; i <= 8; i++ {
|
||||
processAssertSame(t, p, newNolint2FileIssue(i, "errcheck"))
|
||||
}
|
||||
for i := 9; i <= 10; i++ {
|
||||
processAssertEmpty(t, p, newNolint2FileIssue(i, "errcheck"))
|
||||
}
|
||||
|
||||
// check inline comment for function
|
||||
for i := 11; i <= 13; i++ {
|
||||
processAssertSame(t, p, newNolint2FileIssue(i, "errcheck"))
|
||||
}
|
||||
processAssertEmpty(t, p, newNolint2FileIssue(14, "errcheck"))
|
||||
for i := 15; i <= 18; i++ {
|
||||
processAssertSame(t, p, newNolint2FileIssue(i, "errcheck"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestIgnoredRangeMatches(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue