-
Notifications
You must be signed in to change notification settings - Fork 109
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
Conversation
|
||
problems := findProblemsInTheConfig(jsonBytes, &c) | ||
if len(problems) != 0 { | ||
return nil, errors.New(strings.Join(problems, "\n")) |
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.
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 { |
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 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.
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.
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 )
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.
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 { |
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.
Fair enough, the name seems reasonable then.
#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