Skip to content

Commit

Permalink
* fix golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan.Makeev <ivan.makeev@flant.com>
  • Loading branch information
Ranger-X committed Nov 21, 2024
1 parent 0dc5cb3 commit d0aaa7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
4 changes: 2 additions & 2 deletions internal/fsutils/fsutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func EvalSymlinks(path string) (string, error) {
}

// code from https://github.com/guillermo/doubleglob/blob/main/double_glob.go
var replaces = regexp.MustCompile(`(\.)|(\*\*\/)|(\*)|([^\/\*]+)|(\/)`)
var replaces = regexp.MustCompile(`(\.)|(\*\*/)|(\*)|([^/\*]+)|(/)`)

func toRegexp(pattern string) string {
pat := replaces.ReplaceAllStringFunc(pattern, func(s string) string {
Expand Down Expand Up @@ -132,4 +132,4 @@ func FileNameMatchAnyMask(name string, patterns []string) bool {
}

return false
}
}
17 changes: 2 additions & 15 deletions pkg/linters/license/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,14 @@ func (o *Copyright) Run(m *module.Module) (errors.LintRuleErrorsList, error) {

result.Merge(OssModuleRule(m.GetName(), m.GetPath()))

var copyrightExcludes = make([]string, 0)

// prepare excludes by removing module name prefix
for _, exclude := range o.cfg.CopyrightExcludes {
replaced := strings.Replace(exclude, m.GetName() + ":", "", 1)
// if length of replaced is equal to length of exclude - exclude is not for this module. So do not add it to result list
if len(replaced) == len(exclude) {
continue
}
copyrightExcludes = append(copyrightExcludes, replaced)
}

for _, fileName := range files {
name, _ := strings.CutPrefix(fileName, m.GetPath())
name = m.GetName() + ":" + name

if fsutils.FileNameMatchAnyMask(name, copyrightExcludes) {
if fsutils.FileNameMatchAnyMask(name, o.cfg.CopyrightExcludes) {
continue
}

name = m.GetName() + ":" + name

ok, er := checkFileCopyright(fileName)
if !ok {
path, _ := strings.CutPrefix(fileName, m.GetPath())
Expand Down

0 comments on commit d0aaa7c

Please sign in to comment.