-
Notifications
You must be signed in to change notification settings - Fork 71
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
add file-types flag #192
base: main
Are you sure you want to change the base?
add file-types flag #192
Conversation
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.
- Add unit tests for your changes
- Fix issues identified in failed jobs: golangci-lint and goreportcard
Done. Pipeline's green. Let me know if there's anything else I need to do. @kehoecj |
@gurukiran07 Please resolve conflicts then I think you're good to go |
Done. |
Will make the requested changes when I get some time today. |
@gurukiran07 Please resolve conflicts and I'll work on getting this merged today |
@kehoecj Done. Fixed the conflicts. Some basic testing:
|
cmd/validator/validator.go
Outdated
for _, t := range filetype.FileTypes { | ||
validTypes = append(validTypes, t.Name) | ||
} | ||
|
||
validExcludeTypes := misc.ArrToMap(validTypes...) | ||
|
||
for _, t := range strings.Split(*fileTypesPtr, ",") { | ||
delete(validExcludeTypes, t) | ||
} | ||
|
||
excludeFileTypes := make([]string, 0, len(validExcludeTypes)) | ||
|
||
for fileType := range validExcludeTypes { | ||
excludeFileTypes = append(excludeFileTypes, fileType) | ||
} |
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.
This looks complicated
Isn't something that could be used in Go standard "slice" package
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.
I couldn't anything useful in slices packages that can be used here. Would adding comments make it more readable? @ccoVeille
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.
Agreed - I think this can be simplified a bit
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.
Refactored it to use slices.DeleteFunc
.
@ccoVeille @kehoecj
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.
Thanks, as you can see the code is now way clearer
Co-authored-by: ccoVeille <[email protected]>
@@ -162,6 +168,10 @@ Supported formats: standard, json, junit (default: "standard")`, | |||
} | |||
} | |||
|
|||
if err := buildExcludeFileTypesFromFileTypes(excludeFileTypesPtr, fileTypesPtr); err != nil { |
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.
BTW @kehoecj is there a way to validate the behavior of exclusive exclusion (cannot use filter + exclusion) for types in the tests?
Or the code needs to be refactored a lot?
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.
This should be possible to validate in testing.
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.
Then I think it should be part of the PR
Co-authored-by: Clayton Kehoe <[email protected]>
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.
Do you think you could add the tests I'm talking about here
Yeah I can. Will work on it when I get some time. |
closes #174
Added file-types flag to validator.
file-types
andexclude-file-types
are mutually exclusive. iffile-type
is set then builds a list of files that can be excluded and sets that value toexclude-file-types
flag.Some rudimentary tests:
with
--file-types=yaml
with
--exclude-file-types
and--file-types