Return a mapping of scoring elements and a license clarity score computed at the codebase level. The license clarity score is a value from 0-100 calculated by combining the weighted values determined for each of the scoring elements: Declared license: - When true, indicate
(codebase)
| 81 | |
| 82 | |
| 83 | def compute_license_score(codebase): |
| 84 | """ |
| 85 | Return a mapping of scoring elements and a license clarity score computed at |
| 86 | the codebase level. |
| 87 | |
| 88 | The license clarity score is a value from 0-100 calculated by combining the |
| 89 | weighted values determined for each of the scoring elements: |
| 90 | |
| 91 | Declared license: |
| 92 | - When true, indicates that the software package licensing is documented at |
| 93 | top-level or well-known locations in the software project, typically in a |
| 94 | package manifest, NOTICE, LICENSE, COPYING or README file. |
| 95 | - Scoring Weight = 40 |
| 96 | |
| 97 | Identification precision: |
| 98 | - Indicates how well the license statement(s) of the software identify known |
| 99 | licenses that can be designated by precise keys (identifiers) as provided in |
| 100 | a publicly available license list, such as the ScanCode LicenseDB, the SPDX |
| 101 | license list, the OSI license list, or a URL pointing to a specific license |
| 102 | text in a project or organization website. |
| 103 | - Scoring Weight = 40 |
| 104 | |
| 105 | License texts: |
| 106 | - License texts are provided to support the declared license expression in |
| 107 | files such as a package manifest, NOTICE, LICENSE, COPYING or README. |
| 108 | - Scoring Weight = 10 |
| 109 | |
| 110 | Declared copyright: |
| 111 | - When true, indicates that the software package copyright is documented at |
| 112 | top-level or well-known locations in the software project, typically in a |
| 113 | package manifest, NOTICE, LICENSE, COPYING or README file. |
| 114 | - Scoring Weight = 10 |
| 115 | |
| 116 | Ambiguous compound licensing |
| 117 | - When true, indicates that the software has a license declaration that |
| 118 | makes it difficult to construct a reliable license expression, such as in |
| 119 | the case of multiple licenses where the conjunctive versus disjunctive |
| 120 | relationship is not well defined. |
| 121 | - Scoring Weight = -10 |
| 122 | |
| 123 | Conflicting license categories |
| 124 | - When true, indicates the declared license expression of the software is in |
| 125 | the permissive category, but that other potentially conflicting categories, |
| 126 | such as copyleft and proprietary, have been detected in lower level code. |
| 127 | - Scoring Weight = -20 |
| 128 | """ |
| 129 | |
| 130 | scoring_elements = ScoringElements() |
| 131 | license_detections = get_field_values_from_codebase_resources( |
| 132 | codebase=codebase, |
| 133 | field_name='license_detections', |
| 134 | key_files_only=True, |
| 135 | ) |
| 136 | license_match_mappings = get_matches_from_detection_mappings(license_detections) |
| 137 | license_matches = LicenseMatchFromResult.from_dicts(license_match_mappings) |
| 138 | declared_license_expressions = get_field_values_from_codebase_resources( |
| 139 | codebase=codebase, |
| 140 | field_name='detected_license_expression', |
no test coverage detected