-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Add globs (**/*) feature to excludes #16
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ivan.Makeev <[email protected]>
Signed-off-by: Ivan.Makeev <[email protected]>
Signed-off-by: Ivan.Makeev <[email protected]>
Signed-off-by: Ivan.Makeev <[email protected]>
Signed-off-by: Ivan.Makeev <[email protected]>
Signed-off-by: Ivan.Makeev <[email protected]>
Signed-off-by: Ivan.Makeev <[email protected]>
name: "plain string with mask", | ||
args: args{ | ||
str: "test-string.delimited.by.dots", | ||
pattern: "*.by.dots", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, then the pattern will fit any module without restrictions?
Do we want to add regexp only for parsing the file path? Or for the whole line?
If only for the path, then it is reasonable, if for the string, then in my opinion, it will introduce unnecessary errors and unprovable behavior.
…le-name Signed-off-by: Ivan.Makeev <[email protected]>
|
||
func toRegexp(pattern string) string { | ||
// code from https://github.com/guillermo/doubleglob/blob/main/double_glob.go | ||
replaces := regexp.MustCompile(`(\.)|(\*\*/)|(\*)|([^/\*.]+)|(/)`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing, why do we use groups here? As far as I can see, we just match whether this regexp fits our string or not.
for _, fileName := range files { | ||
name, _ := strings.CutPrefix(fileName, m.GetPath()) | ||
name = m.GetName() + ":" + name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we create a name including the module name so that it can be compared with the list of exceptions. The proposed change below does not do this. As a result, we will compare files with exceptions from other modules.
@@ -66,7 +66,7 @@ func (o *NoCyrillic) Run(m *module.Module) (errors.LintRuleErrorsList, error) { | |||
for _, fileName := range files { | |||
name, _ := strings.CutPrefix(fileName, m.GetPath()) | |||
name = m.GetName() + ":" + name | |||
if slices.Contains(o.cfg.NoCyrillicFileExcludes, name) { | |||
if fsutils.StringMatchAnyMask(name, o.cfg.NoCyrillicFileExcludes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name will look like this: upmeter:/hooks/.venv/dir/file.py
We compare it with an exception like upmeter:/hooks/. venv/**/*
It looks like it should work. It would not be bad to make a test for this solution.
For now this work only for
license / copyright-excludes
andnocyrillic / no-cyrillic-file-excludes
section