@@ -29,7 +29,12 @@ type Runner struct {
29
29
30
30
func NewRunner (cfg * config.Config , log logutils.Log , goenv * goutil.Env , es * lintersdb.EnabledSet ,
31
31
lineCache * fsutils.LineCache , dbManager * lintersdb.Manager , pkgs []* gopackages.Package ) (* Runner , error ) {
32
- skipFilesProcessor , err := processors .NewSkipFiles (cfg .Run .SkipFiles )
32
+ // Beware that some processors need to add the path prefix when working with paths
33
+ // because they get invoked before the path prefixer (exclude and severity rules)
34
+ // or process other paths (skip files).
35
+ files := fsutils .NewFiles (lineCache , cfg .Output .PathPrefix )
36
+
37
+ skipFilesProcessor , err := processors .NewSkipFiles (cfg .Run .SkipFiles , cfg .Output .PathPrefix )
33
38
if err != nil {
34
39
return nil , err
35
40
}
@@ -38,7 +43,7 @@ func NewRunner(cfg *config.Config, log logutils.Log, goenv *goutil.Env, es *lint
38
43
if cfg .Run .UseDefaultSkipDirs {
39
44
skipDirs = append (skipDirs , packages .StdExcludeDirRegexps ... )
40
45
}
41
- skipDirsProcessor , err := processors .NewSkipDirs (skipDirs , log .Child (logutils .DebugKeySkipDirs ), cfg .Run .Args )
46
+ skipDirsProcessor , err := processors .NewSkipDirs (skipDirs , log .Child (logutils .DebugKeySkipDirs ), cfg .Run .Args , cfg . Output . PathPrefix )
42
47
if err != nil {
43
48
return nil , err
44
49
}
@@ -82,7 +87,7 @@ func NewRunner(cfg *config.Config, log logutils.Log, goenv *goutil.Env, es *lint
82
87
processors .NewIdentifierMarker (),
83
88
84
89
getExcludeProcessor (& cfg .Issues ),
85
- getExcludeRulesProcessor (& cfg .Issues , log , lineCache ),
90
+ getExcludeRulesProcessor (& cfg .Issues , log , files ),
86
91
processors .NewNolint (log .Child (logutils .DebugKeyNolint ), dbManager , enabledLinters ),
87
92
88
93
processors .NewUniqByLine (cfg ),
@@ -92,7 +97,7 @@ func NewRunner(cfg *config.Config, log logutils.Log, goenv *goutil.Env, es *lint
92
97
processors .NewMaxFromLinter (cfg .Issues .MaxIssuesPerLinter , log .Child (logutils .DebugKeyMaxFromLinter ), cfg ),
93
98
processors .NewSourceCode (lineCache , log .Child (logutils .DebugKeySourceCode )),
94
99
processors .NewPathShortener (),
95
- getSeverityRulesProcessor (& cfg .Severity , log , lineCache ),
100
+ getSeverityRulesProcessor (& cfg .Severity , log , files ),
96
101
processors .NewPathPrefixer (cfg .Output .PathPrefix ),
97
102
processors .NewSortResults (cfg ),
98
103
},
@@ -259,7 +264,7 @@ func getExcludeProcessor(cfg *config.Issues) processors.Processor {
259
264
return excludeProcessor
260
265
}
261
266
262
- func getExcludeRulesProcessor (cfg * config.Issues , log logutils.Log , lineCache * fsutils.LineCache ) processors.Processor {
267
+ func getExcludeRulesProcessor (cfg * config.Issues , log logutils.Log , files * fsutils.Files ) processors.Processor {
263
268
var excludeRules []processors.ExcludeRule
264
269
for _ , r := range cfg .ExcludeRules {
265
270
excludeRules = append (excludeRules , processors.ExcludeRule {
@@ -287,21 +292,21 @@ func getExcludeRulesProcessor(cfg *config.Issues, log logutils.Log, lineCache *f
287
292
if cfg .ExcludeCaseSensitive {
288
293
excludeRulesProcessor = processors .NewExcludeRulesCaseSensitive (
289
294
excludeRules ,
290
- lineCache ,
295
+ files ,
291
296
log .Child (logutils .DebugKeyExcludeRules ),
292
297
)
293
298
} else {
294
299
excludeRulesProcessor = processors .NewExcludeRules (
295
300
excludeRules ,
296
- lineCache ,
301
+ files ,
297
302
log .Child (logutils .DebugKeyExcludeRules ),
298
303
)
299
304
}
300
305
301
306
return excludeRulesProcessor
302
307
}
303
308
304
- func getSeverityRulesProcessor (cfg * config.Severity , log logutils.Log , lineCache * fsutils.LineCache ) processors.Processor {
309
+ func getSeverityRulesProcessor (cfg * config.Severity , log logutils.Log , files * fsutils.Files ) processors.Processor {
305
310
var severityRules []processors.SeverityRule
306
311
for _ , r := range cfg .Rules {
307
312
severityRules = append (severityRules , processors.SeverityRule {
@@ -320,14 +325,14 @@ func getSeverityRulesProcessor(cfg *config.Severity, log logutils.Log, lineCache
320
325
severityRulesProcessor = processors .NewSeverityRulesCaseSensitive (
321
326
cfg .Default ,
322
327
severityRules ,
323
- lineCache ,
328
+ files ,
324
329
log .Child (logutils .DebugKeySeverityRules ),
325
330
)
326
331
} else {
327
332
severityRulesProcessor = processors .NewSeverityRules (
328
333
cfg .Default ,
329
334
severityRules ,
330
- lineCache ,
335
+ files ,
331
336
log .Child (logutils .DebugKeySeverityRules ),
332
337
)
333
338
}
0 commit comments