From 02889309574c081c0db9201246e7fc9365c73881 Mon Sep 17 00:00:00 2001 From: Arjen van der Ende Date: Tue, 30 Nov 2021 11:15:27 +0100 Subject: [PATCH] fix: normalize path for exclude-rules --- .golangci.example.yml | 2 ++ pkg/result/processors/exclude_rules.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.golangci.example.yml b/.golangci.example.yml index 2457f27c0324..279468e47421 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -830,6 +830,8 @@ issues: # Exclude known linters from partially hard-vendored code, # which is impossible to exclude via "nolint" comments. + # "/" will be replaced by current OS file path separator to properly work + # on Windows. - path: internal/hmac/ text: "weak cryptographic primitive" linters: diff --git a/pkg/result/processors/exclude_rules.go b/pkg/result/processors/exclude_rules.go index d4d6569f4ce3..e9f474b98c54 100644 --- a/pkg/result/processors/exclude_rules.go +++ b/pkg/result/processors/exclude_rules.go @@ -44,7 +44,8 @@ func createRules(rules []ExcludeRule, prefix string) []excludeRule { parsedRule.source = regexp.MustCompile(prefix + rule.Source) } if rule.Path != "" { - parsedRule.path = regexp.MustCompile(rule.Path) + path := normalizePathInRegex(rule.Path) + parsedRule.path = regexp.MustCompile(path) } parsedRules = append(parsedRules, parsedRule) }