Add origin summary plugin - #1588
Conversation
* If a license or copyright is detected in 80% of files in a given directory, that license and copyright is summarized at the directory level Signed-off-by: Jono Yang <jyang@nexb.com>
* Register origin summary plugin Signed-off-by: Jono Yang <jyang@nexb.com>
* Define majority to be 50% or more of a directory Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Add new flags for summarized rows or if a row is a summary Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Group holders and licenses together when counting
* Check to see if copyrights or licenses is an attribute instead of requiring the copyright or license option to run the plugin
Signed-off-by: Jono Yang <jyang@nexb.com>
* Increase majority threshold to 0.75 Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* This is so we do not have to walk the codebase twice to find children that have been summarized
* We can instead just iterate through the list of RIDs and modify them
* Update tests due to previous methods of tagging summarized Resources being flawed
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Codecov Report
@@ Coverage Diff @@
## develop #1588 +/- ##
===========================================
+ Coverage 81.22% 81.29% +0.07%
===========================================
Files 126 126
Lines 15612 15655 +43
===========================================
+ Hits 12681 12727 +46
+ Misses 2931 2928 -3
Continue to review full report at Codecov.
|
* TODO: Think about how to structure data in results Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Make this a nested defaultdict instead of using a tuple for the key Signed-off-by: Jono Yang <jyang@nexb.com>
6053141 to
d070252
Compare
Signed-off-by: Jono Yang <jyang@nexb.com>
d070252 to
706e3da
Compare
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
1c9f6ee to
8303aee
Compare
Signed-off-by: Jono Yang <jyang@nexb.com>
* Update tests Signed-off-by: Jono Yang <jyang@nexb.com>
* Change summarized_directories codebase attribute to summaries Signed-off-by: Jono Yang <jyang@nexb.com>
* Change summary codebase attribute to be a list instead of an OrderedDict Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Pass files, directories, and special files through is_ignored Signed-off-by: Jono Yang <jyang@nexb.com>
* We now return consolidated components and consolidated packages in two top-level attributes Signed-off-by: Jono Yang <jyang@nexb.com>
* Replace references to codebase.get_root(0) with codebase.root Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Update some package parsers with path patterns to ignore
* Update tests for get_package_resource
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Update about.py with ignorable_path_patterns Signed-off-by: Jono Yang <jyang@nexb.com>
* Update about.py with ignorable_path_patterns Signed-off-by: Jono Yang <jyang@nexb.com>
…kit into origin-summary-plugin
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Do not combine license-holder components
* Add and update tests
* Update docs and comments
Signed-off-by: Jono Yang <jyang@nexb.com>
* Package parsers can define what resources to ignore when returning package files
* Resource and Codebase have been updated to support using this callable
* Update tests
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* If we are in a directory with no majority, we check the child directories if they have any majorities and return those
* This prevents us from reported the same majority thing as we come up the codebase
* Update tests
Signed-off-by: Jono Yang <jyang@nexb.com>
31074d2 to
75fefb6
Compare
* Add new test Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
* Use proper test data as it appears in the real world
* Reorder attributes on Consolidation
* Update comments
Signed-off-by: Jono Yang <jyang@nexb.com>
pombredanne
left a comment
There was a problem hiding this comment.
Thank you! See my comment inline. The only significant point is the names and order of the attributes on the Consolidation.
|
|
||
| # Nested ScanCode plugins | ||
| *build* | ||
| *dist* |
There was a problem hiding this comment.
should this be instead moved to plugins/scancode-consolidate-scan/.gitignore ?
I fear that this may be catching too many things
There was a problem hiding this comment.
I've added a .gitignore to scancode-consolidate-scan
| core_holders = attr.ib(default=attr.Factory(list)) | ||
| other_holders = attr.ib(default=attr.Factory(list)) | ||
| resources = attr.ib(default=attr.Factory(list)) | ||
|
|
There was a problem hiding this comment.
I think I might want instead somthing like this:
consolidated_license_expression = attr.ib(default=None)
consolidated_holders = attr.ib(default=attr.Factory(list))
consolidated_copyright = attr.ib(default=None)
core_license_expression = attr.ib(default=None)
core_holders = attr.ib(default=attr.Factory(list))
other_license_expression = attr.ib(default=None)
other_holders = attr.ib(default=attr.Factory(list))
....
|
|
||
| def consolidate_core_copyright(self): | ||
| # TODO: Verify and test that we are generating detectable copyrights | ||
| holders = list(self.core_holders) + list(self.other_holders) |
There was a problem hiding this comment.
This is one area where we would want to avoid duplicates (but we still want to have the core before the other)
|
|
||
| def consolidate_other_copyright(self): | ||
| # TODO: Verify and test that we are generating detectable copyrights | ||
| other_holders = list(self.other_holders) |
There was a problem hiding this comment.
Is wrapping in a list really needed there and elsewhere?
|
|
||
| discovered_license_expressions = [] | ||
| discovered_holders = [] | ||
| for package_resource in package_resources: |
There was a problem hiding this comment.
Side note: there is something called key files (from the --classify option) and they should be used when we have a package to craft the things that go in the core vs. other. That could be added later though
| if child.extra_data.get('in_package_component'): | ||
| continue | ||
| if child.is_file: | ||
| license_expression = combine_expressions(child.license_expressions) |
There was a problem hiding this comment.
We need to add a reminder to consider the license match coverage and/or score here in the near future. Otherwise we may end up creating consolidated things that have licenses that were weakly detected.
a1493a1 to
e6a5f99
Compare
* Remove plugin specific gitignore from project level gitignore
* Update tests
Signed-off-by: Jono Yang <jyang@nexb.com>
e6a5f99 to
aea1175
Compare
* Update tests Signed-off-by: Jono Yang <jyang@nexb.com>
* Update expected test results Signed-off-by: Jono Yang <jyang@nexb.com>
* Update expected test results Signed-off-by: Jono Yang <jyang@nexb.com>
|
LGTM. Thank you ++ |
This is a plugin that performs license and copyright holder summarization at the directory level. If a certain copyright holder and license expression shows up in 75% of files in a directory, then that copyright holder and license expression is brought to the directory level. The summarized clues are stored in a new field called
origin_summary, which is a mapping that contains three keys:license_expression,holders, andcount(the number of files with this particular license expression and copyright holders). There is another new field calledsummarized_to, which is a string that contains the path to the directory a Resource has been summarized to.