-
Notifications
You must be signed in to change notification settings - Fork 103
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 validation for duplicate xml elements #402
Conversation
A few nits, but looks basically what I would have done, so good job. |
b330dfe
to
441c1b3
Compare
Formatting fixed. A test case failed, apparently the "bad file" test already had a test file that had these problems, now the asserts need to be fixed. I will see to that soon. |
AppStream license syntax allows constructs of form "LICENSE1 AND LICENSE2". It is possible to confuse this with writing multiple license xml elements in a metainfo file. In order to spot this type of error, duplicate detection is added for xml elements metadata_license and project_license.
441c1b3
to
f883383
Compare
Tests added. In absence of further comments about which elements should be tested for duplicates, I left the scope as it was initially: only the license fields. |
Travis CI build failed, but to me that looks like an unrelated issue, as if something is generated without strict ordering, but is checked against fixed expectation:
|
Agreed! Could I be cheeky and ask you to add the fix for that to this branch please? It should just be reordering the expected lines in asb-self-test.c. Thanks! |
Apparently, write ordering of some field schanged at some point, but the test case was not updated. Updating to allow Travis CI to pass.
That error is now fixed, but another one was hidden behind it:
|
Okay, I can look at that later. Thanks for the fixes! |
Draft fix of #401
As an example, duplicate checking for two elements is added. Using this simple system, checking all elements requires replicating the code for each checked field. Solution with less replication would require a new data structure and passing it around: instead of enumerated problems like
AS_APP_PROBLEM_DUPLICATE_PROJECT_LICENSE
, some kind of generic duplicate problem entry that takes element name as input.Posting this draft for review, because I am really new to this codebase and cannot say what would be best way to proceed:
project_license
duplicates, as that is what was reported in Validation should not accept multiple project_license elements #401 and there the root of the problem is that even if a project may be under multiple licenses, there can only be one license field and separate syntax for encoding everything in there must be used.Comments welcome.