@@ -121,17 +121,9 @@ func findFiles(profiles []*cover.Profile, prefix string) (map[string]fileInfo, e
121121 return result , nil
122122}
123123
124- //nolint:maintidx // relax
125- func findFileCreator () func (file , prefix string ) (string , string , bool ) { // coverage-ignore
124+ func findFileCreator () func (file , prefix string ) (string , string , bool ) {
126125 cache := make (map [string ]* build.Package )
127- files := []string (nil )
128-
129- findRelative := func (file , prefix string ) (string , string , bool ) {
130- noPrefixName := stripPrefix (file , prefix )
131- _ , err := os .Stat (noPrefixName )
132-
133- return noPrefixName , noPrefixName , err == nil
134- }
126+ files := listAllFiles ("." )
135127
136128 findBuildImport := func (file string ) (string , string , bool ) {
137129 dir , file := filepath .Split (file )
@@ -156,22 +148,14 @@ func findFileCreator() func(file, prefix string) (string, string, bool) { // cov
156148 }
157149
158150 findWalk := func (file , prefix string ) (string , string , bool ) {
159- if files == nil {
160- files = listAllFiles ("./" )
161- }
162-
163151 noPrefixName := stripPrefix (file , prefix )
164152 f , found := hasFile (files , noPrefixName )
165153
166154 return path .NormalizeForOS (f ), noPrefixName , found
167155 }
168156
169157 return func (file , prefix string ) (string , string , bool ) {
170- if fPath , fNoPrefix , found := findRelative (file , prefix ); found {
171- return fPath , fNoPrefix , found
172- }
173-
174- if fPath , fNoPrefix , found := findWalk (file , prefix ); found {
158+ if fPath , fNoPrefix , found := findWalk (file , prefix ); found { // coverage-ignore
175159 return fPath , fNoPrefix , found
176160 }
177161
@@ -184,7 +168,7 @@ func findFileCreator() func(file, prefix string) (string, string, bool) { // cov
184168}
185169
186170func listAllFiles (rootDir string ) []string {
187- var files []string
171+ files := make ( []string , 0 )
188172
189173 //nolint:errcheck // error ignored because there is fallback mechanism for finding files
190174 filepath .Walk (rootDir , func (file string , info os.FileInfo , err error ) error {
0 commit comments