Skip to content
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

Merged
merged 10 commits into from
Mar 10, 2022

Conversation

martijnvans
Copy link
Contributor

@martijnvans martijnvans commented Mar 1, 2022

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.

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)
Copy link
Member

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?

Copy link
Member

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
}

integration_test/third_party_apps_test.go Outdated Show resolved Hide resolved
@martijnvans martijnvans marked this pull request as ready for review March 3, 2022 16:55
Copy link
Member

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit:

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)
Copy link
Member

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
}

@martijnvans
Copy link
Contributor Author

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.

@martijnvans martijnvans merged commit 2add76e into master Mar 10, 2022
@martijnvans martijnvans deleted the martijnvans-reject-duplicates branch March 10, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants