-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactor to simplify scanresults model #214
Conversation
a998764
to
6248152
Compare
* disallow `None` for fields that are containers. Use empty container instead. * Change converter from OpossumFileModel accordingly * Equality of OpossumFileModel in tests needs to respect that None might change to [] or {}
6248152
to
0acbf7d
Compare
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.
Nice PR showcasing how good it is to decouple the working entities from the models directly associated to the file
The only one thing I would like to discuss is whether we should keep the change transparent for the end file, i.e. restore the None
s when converting back to the OpossumModel
?
That would also mean we would avoid changing the tests
I did double check OpossumUI and from loading the data into OpossumUI there is no difference whether the entry is not part of the json at all or whether it is simply and empty dict/list.
However IMHO I would prefer keeping the .opossum
files un-mutetated while processing.
I think the main issue here is that we cannot distinguish whether the input was missing the field or had an empty container. Thus "keeping ... unmutated" is impossible in principle. We need to make an a priori arbitrary choice whether we want to write |
* rename ScanResults.get_attribution_key to clarify that it is private and can modify the internal state * move _assert_equal_or_both_falsy into the only file that uses it * rename tests for internal opossum model and make generation of attribution_to_id explicit
Agreed, however all files we have seen up to now adhered to the principle of just leaving empty fields out. So this is a break in procedure. |
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.
Discussed non vs empty list and agreed to keep empty list
Summary of changes
OpossumProvider
to allow construction ofOpossum
wherereview_results=None
ScanResults
were the logic around the attribution keys assumedattribution_to_id
to be adefault_dict
and would break otherwise.ScanResults
that were eitherlist | None
ordict | None
to disallowNone
and use an empty container instead. This removes some null checks throughout the codebase and requires some adaption of the tests. Mainly to the round-trip ofOpossumFileModel
due to the normalization of the fields.Context and reason for change
This PR aims to simplify the internal OpossumModel by making the types on the fields stricter. This makes the subsequent implementation of merging of opossums simpler.