11package processors
22
33import (
4- "errors"
54 "go/ast"
65 "go/parser"
76 "go/token"
@@ -99,19 +98,15 @@ func (p *Nolint) Process(issues []result.Issue) ([]result.Issue, error) {
9998 return filterIssuesErr (issues , p .shouldPassIssue )
10099}
101100
102- func (p * Nolint ) getOrCreateFileData (issue * result.Issue ) ( * fileData , error ) {
101+ func (p * Nolint ) getOrCreateFileData (issue * result.Issue ) * fileData {
103102 fd := p .cache [issue .FilePath ()]
104103 if fd != nil {
105- return fd , nil
104+ return fd
106105 }
107106
108107 fd = & fileData {}
109108 p .cache [issue .FilePath ()] = fd
110109
111- if issue .FilePath () == "" {
112- return nil , errors .New ("no file path for issue" )
113- }
114-
115110 // TODO: migrate this parsing to go/analysis facts
116111 // or cache them somehow per file.
117112
@@ -120,12 +115,14 @@ func (p *Nolint) getOrCreateFileData(issue *result.Issue) (*fileData, error) {
120115 f , err := parser .ParseFile (fset , issue .FilePath (), nil , parser .ParseComments )
121116 if err != nil {
122117 // Don't report error because it's already must be reporter by typecheck or go/analysis.
123- return fd , nil
118+ return fd
124119 }
125120
126121 fd .ignoredRanges = p .buildIgnoredRangesForFile (f , fset , issue .FilePath ())
122+
127123 nolintDebugf ("file %s: built nolint ranges are %+v" , issue .FilePath (), fd .ignoredRanges )
128- return fd , nil
124+
125+ return fd
129126}
130127
131128func (p * Nolint ) buildIgnoredRangesForFile (f * ast.File , fset * token.FileSet , filePath string ) []ignoredRange {
@@ -161,10 +158,7 @@ func (p *Nolint) shouldPassIssue(issue *result.Issue) (bool, error) {
161158 nolintDebugf ("checking that lint issue was used for %s: %v" , issue .ExpectedNoLintLinter , issue )
162159 }
163160
164- fd , err := p .getOrCreateFileData (issue )
165- if err != nil {
166- return false , err
167- }
161+ fd := p .getOrCreateFileData (issue )
168162
169163 for _ , ir := range fd .ignoredRanges {
170164 if ir .doesMatch (issue ) {
0 commit comments