-
Notifications
You must be signed in to change notification settings - Fork 70
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
Reject redundant entries in supported_applications.txt #438
Conversation
Raise a test failure if the same application appears more than once in supported_applications.txt. This is to prevent the situation that #432 is fixing from reoccurring.
unique := make(map[string]bool) | ||
for _, app := range apps { | ||
if unique[app] { | ||
return fmt.Errorf("application %q appears multiple times in supported_applications.txt", app) |
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.
[Optional] Would it make sense to list all duplicates?
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 guess by resolving this you were saying that reporting one duplicate at a time is fine. Well, it was optional anyway. For the record, I was suggesting something like:
func rejectDuplicates(apps []string) error {
seen := make(map[string]bool)
var dups []string
for _, app := range apps {
if seen[app] {
dups = append(dups, app)
}
seen[app] = true
}
if len(dups) > 0 {
return fmt.Errorf("applications %q appear multiple times in supported_applications.txt", dups)
}
return 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.
LGTM
unique := make(map[string]bool) | ||
for _, app := range apps { | ||
if unique[app] { | ||
return fmt.Errorf("application %q appears multiple times in supported_applications.txt", app) |
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 guess by resolving this you were saying that reporting one duplicate at a time is fine. Well, it was optional anyway. For the record, I was suggesting something like:
func rejectDuplicates(apps []string) error {
seen := make(map[string]bool)
var dups []string
for _, app := range apps {
if seen[app] {
dups = append(dups, app)
}
seen[app] = true
}
if len(dups) > 0 {
return fmt.Errorf("applications %q appear multiple times in supported_applications.txt", dups)
}
return nil
}
yes, I both think that reporting one duplicate at a time is fine and that the code for reporting all duplicates is more complex and not worth it. So I'll go ahead and proceed with the current approach. |
Raise a test failure if the same application appears more than once in supported_applications.txt. This is to prevent the situation that #432 is fixing from reoccurring.