fix #521: explain //nolint usage in README

Also, add more tests for block-wise
usage of //nolint.
This commit is contained in:
Denis Isaev 2019-06-09 16:12:37 +03:00 committed by Isaev Denis
parent ad9de15a58
commit 7db400b2d2
5 changed files with 112 additions and 14 deletions

View file

@ -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",
})
}