mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
fix #521: explain //nolint usage in README
Also, add more tests for block-wise usage of //nolint.
This commit is contained in:
parent
ad9de15a58
commit
7db400b2d2
5 changed files with 112 additions and 14 deletions
|
@ -37,6 +37,7 @@ func newTestNolintProcessor(log logutils.Log) *Nolint {
|
|||
filepath.Join("testdata", "nolint.go"),
|
||||
filepath.Join("testdata", "nolint2.go"),
|
||||
filepath.Join("testdata", "nolint_bad_names.go"),
|
||||
filepath.Join("testdata", "nolint_whole_file.go"),
|
||||
)
|
||||
return NewNolint(cache, log, lintersdb.NewManager(nil))
|
||||
}
|
||||
|
@ -123,6 +124,11 @@ func TestNolint(t *testing.T) {
|
|||
for i := 15; i <= 18; i++ {
|
||||
processAssertSame(t, p, newNolint2FileIssue(i))
|
||||
}
|
||||
|
||||
// variables block exclude
|
||||
for i := 55; i <= 56; i++ {
|
||||
processAssertSame(t, p, newNolint2FileIssue(i))
|
||||
}
|
||||
}
|
||||
|
||||
func TestNolintInvalidLinterName(t *testing.T) {
|
||||
|
@ -226,3 +232,25 @@ func TestIgnoredRangeMatches(t *testing.T) {
|
|||
assert.Equal(t, testcase.expected, ir.doesMatch(&testcase.issue), testcase.doc)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNolintWholeFile(t *testing.T) {
|
||||
fileName := filepath.Join("testdata", "nolint_whole_file.go")
|
||||
|
||||
p := newTestNolintProcessor(nil)
|
||||
defer p.Finish()
|
||||
|
||||
processAssertEmpty(t, p, result.Issue{
|
||||
Pos: token.Position{
|
||||
Filename: fileName,
|
||||
Line: 4,
|
||||
},
|
||||
FromLinter: "unparam",
|
||||
})
|
||||
processAssertSame(t, p, result.Issue{
|
||||
Pos: token.Position{
|
||||
Filename: fileName,
|
||||
Line: 4,
|
||||
},
|
||||
FromLinter: "deadcode",
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue