@@ -115,7 +115,6 @@ func (p *Nolint) shouldPassIssue(i *result.Issue) (bool, error) {
115115 if i .FromLinter == linter {
116116 return false , nil
117117 }
118- // TODO: check linter name
119118 }
120119 }
121120
@@ -127,20 +126,30 @@ func extractFileComments(fset *token.FileSet, comments ...*ast.CommentGroup) fil
127126 for _ , g := range comments {
128127 for _ , c := range g .List {
129128 text := strings .TrimLeft (c .Text , "/ " )
130- if strings .HasPrefix (text , "nolint" ) {
131- var linters []string
132- if strings .HasPrefix (text , "nolint:" ) {
133- text = strings .Split (text , " " )[0 ] // allow arbitrary text after this comment
134- for _ , linter := range strings .Split (strings .TrimPrefix (text , "nolint:" ), "," ) {
135- linters = append (linters , strings .TrimSpace (linter ))
136- }
137- }
138- pos := fset .Position (g .Pos ())
129+ if ! strings .HasPrefix (text , "nolint" ) {
130+ continue
131+ }
132+
133+ pos := fset .Position (g .Pos ())
134+ if ! strings .HasPrefix (text , "nolint:" ) { // ignore all linters
139135 ret = append (ret , comment {
140- linters : linters ,
141- line : pos .Line ,
136+ line : pos .Line ,
142137 })
138+ continue
139+ }
140+
141+ // ignore specific linters
142+ var linters []string
143+ text = strings .Split (text , "//" )[0 ] // allow another comment after this comment
144+ linterItems := strings .Split (strings .TrimPrefix (text , "nolint:" ), "," )
145+ for _ , linter := range linterItems {
146+ linterName := strings .TrimSpace (linter ) // TODO: validate it here
147+ linters = append (linters , linterName )
143148 }
149+ ret = append (ret , comment {
150+ linters : linters ,
151+ line : pos .Line ,
152+ })
144153 }
145154 }
146155
0 commit comments