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

disallow duplicate entries in config.json #616

Merged
merged 2 commits into from
Jul 24, 2021

Conversation

christopher-henderson
Copy link
Member

@christopher-henderson christopher-henderson commented Jun 26, 2021

#613 providing me with quite a painful experience of trying to figuring out why deleting and modifying those particular entries in config.json did not have the desired affect. That is, changing the entries would fail the test, but deleting them would not, which was quite surprising. It turns out it was because they were duplicates of entries already declared further up in the document.

This change disallows duplicate entries in the integration test JSON as I just don't see a usecase for it and it can cause some confusing results that waste your time.

This PR resolves #615


problems := findProblemsInTheConfig(jsonBytes, &c)
if len(problems) != 0 {
return nil, errors.New(strings.Join(problems, "\n"))
Copy link
Member Author

Choose a reason for hiding this comment

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

Example output is:

the lint 'e_cert_sig_alg_not_match_tbs_sig_alg' was declared 2 times and appeared on line numbers [296 759]
the lint 'e_ocsp_id_pkix_ocsp_nocheck_ext_not_included_server_auth' was declared 2 times and appeared on line numbers [450 762]

return &c, nil
}

// findProblemsInTheConfig tries keep the configuration honest with regard
// to aspects such as duplicate entries with in the Expected field.
func findProblemsInTheConfig(configBytes []byte, c *config) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have thoughts about other config problems you may try to find with this function in the future? Otherwise, findDuplicateConfigEntries might be a more precise name for the function.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was thinking of other things like not being able to declare a result set for a lint that doesn't exist (which also happened in #613 )

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, the name seems reasonable then.

return &c, nil
}

// findProblemsInTheConfig tries keep the configuration honest with regard
// to aspects such as duplicate entries with in the Expected field.
func findProblemsInTheConfig(configBytes []byte, c *config) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, the name seems reasonable then.

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.

Disallow duplicate entries in the test corpus config
2 participants