nolintlint: allow to fix //nolint lines (#1583)

This commit is contained in:
Andrew Shannon Brown 2021-03-12 20:11:05 -08:00 committed by GitHub
parent d28c66672e
commit e1a734e559
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 345 additions and 132 deletions

View file

@ -291,6 +291,17 @@ func TestNolintUnused(t *testing.T) {
ExpectedNoLintLinter: "varcheck",
}
// the issue below is another nolintlint issue that would be generated for the test file
nolintlintIssueVarcheckUnusedOK := result.Issue{
Pos: token.Position{
Filename: fileName,
Line: 5,
},
FromLinter: golinters.NolintlintName,
ExpectNoLint: true,
ExpectedNoLintLinter: "varcheck",
}
t.Run("when an issue does not occur, it is not removed from the nolintlint issues", func(t *testing.T) {
p := createProcessor(t, log, []string{"nolintlint", "varcheck"})
defer p.Finish()
@ -298,6 +309,13 @@ func TestNolintUnused(t *testing.T) {
processAssertSame(t, p, nolintlintIssueVarcheck)
})
t.Run("when an issue does not occur but nolintlint is nolinted, it is removed from the nolintlint issues", func(t *testing.T) {
p := createProcessor(t, log, []string{"nolintlint", "varcheck"})
defer p.Finish()
processAssertEmpty(t, p, nolintlintIssueVarcheckUnusedOK)
})
t.Run("when an issue occurs, it is removed from the nolintlint issues", func(t *testing.T) {
p := createProcessor(t, log, []string{"nolintlint", "varcheck"})
defer p.Finish()