@@ -16,14 +16,15 @@ type ExclusionPaths struct {
16
16
pathPatterns []* regexp.Regexp
17
17
pathExceptPatterns []* regexp.Regexp
18
18
19
- warnUnused bool
20
- skippedPathCounter map [* regexp.Regexp ]int
19
+ warnUnused bool
20
+ excludedPathCounter map [* regexp.Regexp ]int
21
+ excludedPathExceptCounter map [* regexp.Regexp ]int
21
22
22
23
log logutils.Log
23
24
}
24
25
25
26
func NewExclusionPaths (log logutils.Log , cfg * config.LinterExclusions ) (* ExclusionPaths , error ) {
26
- var counter = make (map [* regexp.Regexp ]int )
27
+ excludedPathCounter : = make (map [* regexp.Regexp ]int )
27
28
28
29
var pathPatterns []* regexp.Regexp
29
30
for _ , p := range cfg .Paths {
@@ -35,9 +36,11 @@ func NewExclusionPaths(log logutils.Log, cfg *config.LinterExclusions) (*Exclusi
35
36
}
36
37
37
38
pathPatterns = append (pathPatterns , patternRe )
38
- counter [patternRe ] = 0
39
+ excludedPathCounter [patternRe ] = 0
39
40
}
40
41
42
+ excludedPathExceptCounter := make (map [* regexp.Regexp ]int )
43
+
41
44
var pathExceptPatterns []* regexp.Regexp
42
45
for _ , p := range cfg .PathsExcept {
43
46
p = fsutils .NormalizePathInRegex (p )
@@ -48,14 +51,16 @@ func NewExclusionPaths(log logutils.Log, cfg *config.LinterExclusions) (*Exclusi
48
51
}
49
52
50
53
pathExceptPatterns = append (pathExceptPatterns , patternRe )
54
+ excludedPathExceptCounter [patternRe ] = 0
51
55
}
52
56
53
57
return & ExclusionPaths {
54
- pathPatterns : pathPatterns ,
55
- pathExceptPatterns : pathExceptPatterns ,
56
- warnUnused : cfg .WarnUnused ,
57
- skippedPathCounter : counter ,
58
- log : log .Child (logutils .DebugKeyExclusionPaths ),
58
+ pathPatterns : pathPatterns ,
59
+ pathExceptPatterns : pathExceptPatterns ,
60
+ warnUnused : cfg .WarnUnused ,
61
+ excludedPathCounter : excludedPathCounter ,
62
+ excludedPathExceptCounter : excludedPathExceptCounter ,
63
+ log : log .Child (logutils .DebugKeyExclusionPaths ),
59
64
}, nil
60
65
}
61
66
@@ -72,19 +77,25 @@ func (p *ExclusionPaths) Process(issues []result.Issue) ([]result.Issue, error)
72
77
}
73
78
74
79
func (p * ExclusionPaths ) Finish () {
75
- for pattern , count := range p .skippedPathCounter {
80
+ for pattern , count := range p .excludedPathCounter {
76
81
if p .warnUnused && count == 0 {
77
- p .log .Warnf ("Skipped %d issues by pattern %q" , count , pattern )
82
+ p .log .Warnf ("The pattern %q match %d issues " , pattern , count )
78
83
} else {
79
84
p .log .Infof ("Skipped %d issues by pattern %q" , count , pattern )
80
85
}
81
86
}
87
+
88
+ for pattern , count := range p .excludedPathExceptCounter {
89
+ if p .warnUnused && count == 0 {
90
+ p .log .Warnf ("The pattern %q match %d issues" , pattern , count )
91
+ }
92
+ }
82
93
}
83
94
84
95
func (p * ExclusionPaths ) shouldPassIssue (issue * result.Issue ) bool {
85
96
for _ , pattern := range p .pathPatterns {
86
97
if pattern .MatchString (issue .RelativePath ) {
87
- p .skippedPathCounter [pattern ] += 1
98
+ p .excludedPathCounter [pattern ] += 1
88
99
return false
89
100
}
90
101
}
@@ -99,6 +110,7 @@ func (p *ExclusionPaths) shouldPassIssue(issue *result.Issue) bool {
99
110
continue
100
111
}
101
112
113
+ p .excludedPathExceptCounter [pattern ] += 1
102
114
matched = true
103
115
}
104
116
0 commit comments