From 3d19dbbe73f7dc254244513a7549fc92ec1c061d Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 29 Oct 2018 17:43:05 -0700 Subject: [PATCH] Refactor license score computation #1180 * make the main loop simpler with configured scoring elements * add tests to license score computation * add support for future additional scoring elements Signed-off-by: Philippe Ombredanne --- src/summarycode/score.py | 297 ++++++++++----- .../data/score/basic-expected.json | 261 +++++++++++++ tests/summarycode/data/score/basic/README.md | 36 ++ tests/summarycode/data/score/basic/index.js | 74 ++++ .../summarycode/data/score/basic/package.json | 30 ++ .../score/consistent_licenses-expected.json | 253 +++++++++++++ .../data/score/consistent_licenses/README.md | 16 + .../score/consistent_licenses/package.json | 30 ++ .../score/consistent_licenses/src/index.js | 1 + .../consistent_licenses_not-expected.json | 253 +++++++++++++ .../score/consistent_licenses_not/README.md | 16 + .../consistent_licenses_not/package.json | 30 ++ .../consistent_licenses_not/src/index.js | 1 + ...consistent_licenses_not_spdx-expected.json | 253 +++++++++++++ .../consistent_licenses_not_spdx/README.md | 24 ++ .../consistent_licenses_not_spdx/package.json | 29 ++ .../consistent_licenses_not_spdx/src/index.js | 8 + .../data/score/file_coverage-expected.json | 357 ++++++++++++++++++ .../data/score/file_coverage/README.md | 16 + .../data/score/file_coverage/package.json | 30 ++ .../data/score/file_coverage/src/index.js | 2 + .../data/score/file_coverage/src/index2.js | 1 + .../data/score/file_coverage/src/test.java | 2 + .../data/score/full_text-expected.json | 317 ++++++++++++++++ .../data/score/full_text/README.md | 16 + .../data/score/full_text/package.json | 30 ++ .../data/score/full_text/src/COPYING.md | 18 + .../data/score/full_text/src/index.js | 1 + .../full_text_in_key_files-expected.json | 317 ++++++++++++++++ .../score/full_text_in_key_files/COPYING.md | 18 + .../score/full_text_in_key_files/README.md | 16 + .../score/full_text_in_key_files/package.json | 30 ++ .../score/full_text_in_key_files/src/index.js | 1 + .../data/score/single_file-expected.json | 91 +++++ .../data/score/single_file/README.md | 1 + .../data/score/spdx_licenses-expected.json | 317 ++++++++++++++++ .../data/score/spdx_licenses/README.md | 16 + .../data/score/spdx_licenses/package.json | 30 ++ .../data/score/spdx_licenses/src/index.js | 1 + .../data/score/spdx_licenses/src/index2.js | 1 + .../score/spdx_licenses_not-expected.json | 317 ++++++++++++++++ .../data/score/spdx_licenses_not/README.md | 16 + .../data/score/spdx_licenses_not/package.json | 30 ++ .../data/score/spdx_licenses_not/src/index.js | 1 + .../score/spdx_licenses_not/src/index2.js | 1 + .../data/score/top_declared-expected.json | 189 ++++++++++ .../data/score/top_declared/README.md | 16 + .../data/score/top_declared/index.js | 54 +++ .../data/score/top_declared/package.json | 30 ++ .../data/score/top_declared_not-expected.json | 159 ++++++++ .../data/score/top_declared_not/README.md | 16 + .../data/score/top_declared_not/index.js | 54 +++ .../data/score/top_declared_not/package.json | 29 ++ tests/summarycode/test_score.py | 106 ++++++ 54 files changed, 4159 insertions(+), 100 deletions(-) create mode 100644 tests/summarycode/data/score/basic-expected.json create mode 100644 tests/summarycode/data/score/basic/README.md create mode 100644 tests/summarycode/data/score/basic/index.js create mode 100644 tests/summarycode/data/score/basic/package.json create mode 100644 tests/summarycode/data/score/consistent_licenses-expected.json create mode 100644 tests/summarycode/data/score/consistent_licenses/README.md create mode 100644 tests/summarycode/data/score/consistent_licenses/package.json create mode 100644 tests/summarycode/data/score/consistent_licenses/src/index.js create mode 100644 tests/summarycode/data/score/consistent_licenses_not-expected.json create mode 100644 tests/summarycode/data/score/consistent_licenses_not/README.md create mode 100644 tests/summarycode/data/score/consistent_licenses_not/package.json create mode 100644 tests/summarycode/data/score/consistent_licenses_not/src/index.js create mode 100644 tests/summarycode/data/score/consistent_licenses_not_spdx-expected.json create mode 100644 tests/summarycode/data/score/consistent_licenses_not_spdx/README.md create mode 100644 tests/summarycode/data/score/consistent_licenses_not_spdx/package.json create mode 100644 tests/summarycode/data/score/consistent_licenses_not_spdx/src/index.js create mode 100644 tests/summarycode/data/score/file_coverage-expected.json create mode 100644 tests/summarycode/data/score/file_coverage/README.md create mode 100644 tests/summarycode/data/score/file_coverage/package.json create mode 100644 tests/summarycode/data/score/file_coverage/src/index.js create mode 100644 tests/summarycode/data/score/file_coverage/src/index2.js create mode 100644 tests/summarycode/data/score/file_coverage/src/test.java create mode 100644 tests/summarycode/data/score/full_text-expected.json create mode 100644 tests/summarycode/data/score/full_text/README.md create mode 100644 tests/summarycode/data/score/full_text/package.json create mode 100644 tests/summarycode/data/score/full_text/src/COPYING.md create mode 100644 tests/summarycode/data/score/full_text/src/index.js create mode 100644 tests/summarycode/data/score/full_text_in_key_files-expected.json create mode 100644 tests/summarycode/data/score/full_text_in_key_files/COPYING.md create mode 100644 tests/summarycode/data/score/full_text_in_key_files/README.md create mode 100644 tests/summarycode/data/score/full_text_in_key_files/package.json create mode 100644 tests/summarycode/data/score/full_text_in_key_files/src/index.js create mode 100644 tests/summarycode/data/score/single_file-expected.json create mode 100644 tests/summarycode/data/score/single_file/README.md create mode 100644 tests/summarycode/data/score/spdx_licenses-expected.json create mode 100644 tests/summarycode/data/score/spdx_licenses/README.md create mode 100644 tests/summarycode/data/score/spdx_licenses/package.json create mode 100644 tests/summarycode/data/score/spdx_licenses/src/index.js create mode 100644 tests/summarycode/data/score/spdx_licenses/src/index2.js create mode 100644 tests/summarycode/data/score/spdx_licenses_not-expected.json create mode 100644 tests/summarycode/data/score/spdx_licenses_not/README.md create mode 100644 tests/summarycode/data/score/spdx_licenses_not/package.json create mode 100644 tests/summarycode/data/score/spdx_licenses_not/src/index.js create mode 100644 tests/summarycode/data/score/spdx_licenses_not/src/index2.js create mode 100644 tests/summarycode/data/score/top_declared-expected.json create mode 100644 tests/summarycode/data/score/top_declared/README.md create mode 100644 tests/summarycode/data/score/top_declared/index.js create mode 100644 tests/summarycode/data/score/top_declared/package.json create mode 100644 tests/summarycode/data/score/top_declared_not-expected.json create mode 100644 tests/summarycode/data/score/top_declared_not/README.md create mode 100644 tests/summarycode/data/score/top_declared_not/index.js create mode 100644 tests/summarycode/data/score/top_declared_not/package.json create mode 100644 tests/summarycode/test_score.py diff --git a/src/summarycode/score.py b/src/summarycode/score.py index 53dd8a0925c..77829ff2358 100644 --- a/src/summarycode/score.py +++ b/src/summarycode/score.py @@ -37,6 +37,7 @@ from scancode import POST_SCAN_GROUP from summarycode import facet + # Tracing flags TRACE = False @@ -70,7 +71,7 @@ class LicenseClarityScore(PostScanPlugin): """ Compute a License clarity score at the codebase level. """ - codebase_attributes = dict(license_score=attr.ib(default=attr.Factory(OrderedDict))) + codebase_attributes = dict(license_clarity_score=attr.ib(default=attr.Factory(OrderedDict))) sort_order = 110 options = [ @@ -90,7 +91,7 @@ def process_codebase(self, codebase, license_clarity_score, **kwargs): if TRACE: logger_debug('LicenseClarityScore:process_codebase') scoring_elements = compute_license_score(codebase, **kwargs) - codebase.attributes.license_score.update(scoring_elements) + codebase.attributes.license_clarity_score.update(scoring_elements) def compute_license_score(codebase, min_score=MIN_GOOD_LICENSE_SCORE, **kwargs): @@ -102,87 +103,28 @@ def compute_license_score(codebase, min_score=MIN_GOOD_LICENSE_SCORE, **kwargs): score = 0 scoring_elements = OrderedDict(score=score) - # FIXME: separate the compute of each score element from applying the weights - - ############################################################################ - top_level_declared_licenses_weight = 30 - has_top_level_declared_licenses = get_top_level_declared_licenses(codebase, min_score) - scoring_elements['has_top_level_declared_licenses'] = bool(has_top_level_declared_licenses) - if has_top_level_declared_licenses: - score += top_level_declared_licenses_weight - if TRACE: - logger_debug( - 'compute_license_score:has_top_level_declared_licenses:', - has_top_level_declared_licenses, 'score:', score) - - ############################################################################ - file_level_license_and_copyright_weight = 25 - file_level_license_and_copyright_coverage = 0 - files_with_lic_copyr, files_count = get_other_licenses_and_copyrights_counts(codebase, min_score) - if TRACE: - logger_debug('compute_license_score:files_with_lic_copyr:', - files_with_lic_copyr, 'files_count:', files_count) - - scoring_elements['file_level_license_and_copyright_coverage'] = 0 - - - if files_count: - file_level_license_and_copyright_coverage = files_with_lic_copyr / files_count - score += int(file_level_license_and_copyright_coverage * file_level_license_and_copyright_weight) - scoring_elements['file_level_license_and_copyright_coverage'] = file_level_license_and_copyright_coverage - if TRACE: - logger_debug('compute_license_score:file_level_license_and_copyright_coverage:', - file_level_license_and_copyright_coverage, 'score:', score) + kwargs.update(dict(min_score=min_score)) - ############################################################################ - license_consistency_weight = 15 - has_consistent_key_and_file_level_license = False - key_files_license_keys, other_files_license_keys = get_unique_licenses(codebase, min_score) - - if key_files_license_keys and key_files_license_keys == other_files_license_keys: - has_consistent_key_and_file_level_license = True - - scoring_elements['has_consistent_key_and_file_level_license'] = has_consistent_key_and_file_level_license - - if has_consistent_key_and_file_level_license: - score += license_consistency_weight - if TRACE: - logger_debug( - 'compute_license_score:has_consistent_key_and_file_level_license:', - has_consistent_key_and_file_level_license, 'score:', score) - - - ############################################################################ - spdx_standard_licenses_weight = 15 - has_all_spdx_licenses = all(has_spdx_licenses(res) for res in codebase.walk() if res.is_file) - - scoring_elements['has_all_spdx_licenses'] = has_all_spdx_licenses + for element in SCORING_ELEMENTS: + element_score = element.scorer(codebase, **kwargs) + if element.is_binary: + scoring_elements[element.name] = bool(element_score) + element_score = 1 if element_score else 0 + else: + scoring_elements[element.name] = round(element_score, 2) - if has_all_spdx_licenses: - score += spdx_standard_licenses_weight + score += int(element_score * element.weight) if TRACE: logger_debug( - 'compute_license_score:', - 'has_all_spdx_licenses:', - has_all_spdx_licenses, 'score:', score) - - ############################################################################ - license_texts_weight = 15 - - all_keys = key_files_license_keys & other_files_license_keys - keys_with_license_text = get_detected_license_keys_with_full_text(codebase, min_score) - - has_all_license_texts = all_keys == keys_with_license_text - scoring_elements['has_all_license_texts'] = has_all_license_texts - - if has_all_license_texts: - score += license_texts_weight + 'compute_license_score: element:', element, 'element_score: ', + element_score, ' new score:', score) scoring_elements['score'] = score return scoring_elements -def get_top_level_declared_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE): +def get_declared_licenses_in_key_files(codebase, min_score=MIN_GOOD_LICENSE_SCORE, + **kwargs): """ A project has specific key file(s) at the top level of its code hierarchy such as LICENSE, NOTICE or similar (and/or a package manifest) containing @@ -193,7 +135,7 @@ def get_top_level_declared_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE): Note: this ignores facets. """ - key_files = (res for res in codebase.walk(topdown=True) if is_key_file(res)) + key_files = (res for res in codebase.walk(topdown=True) if res.is_key_file) detected_good_licenses = [] for resource in key_files: @@ -229,19 +171,6 @@ def get_top_level_declared_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE): return detected_good_licenses -def is_key_file(resource): - """ - Return True if a Resource is considered as a "key file". - """ - return ( - resource.is_file - and resource.is_top_level - and (resource.is_readme - or resource.is_legal - or resource.is_manifest) - ) - - def is_core_facet(resource, core_facet=facet.FACET_CORE): """ Return True if the resource is in the core facet. @@ -256,7 +185,8 @@ def is_core_facet(resource, core_facet=facet.FACET_CORE): def has_good_licenses(resource, min_score=MIN_GOOD_LICENSE_SCORE): """ - Return True if a Resource licenses are all detected with a score above min_score. + Return True if a Resource licenses are all detected with a score above + min_score and is generally a "good license" detection-wise. """ if not resource.licenses: return False @@ -265,8 +195,15 @@ def has_good_licenses(resource, min_score=MIN_GOOD_LICENSE_SCORE): return False for detected_license in resource.licenses: + # the license score must be above some threshold if detected_license['score'] < min_score: return False + + # and not an "unknown" license + if is_unknown_license(detected_license['key']): + return False + + return True @@ -274,16 +211,50 @@ def has_spdx_licenses(resource): """ Return True if a Resource licenses are all known SPDX licenses. """ - if resource.scan_errors: - return False - for detected_license in resource.licenses: if not detected_license.get('spdx_license_key'): return False return True -def get_unique_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE): +def is_unknown_license(lic_key): + """ + Return True if a license key is for some lesser known or unknown license. + """ + return lic_key.startswith(('unknown', 'other-',)) + + +def has_unkown_licenses(resource): + """ + Return True if some Resource licenses are unknown. + """ + return not any(is_unknown_license(lic) for lic in resource.licenses) + + +def is_using_only_spdx_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE, + **kwargs): + """ + Return True if all file-level detected licenses are SPDX licenses. + """ + return all(has_spdx_licenses(res) for res in codebase.walk() if res.is_file) + + +def has_consistent_key_and_file_level_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE, + **kwargs): + """ + Return True if the file-level licenses are consistent with top level key + files licenses. + """ + scoring_element = False + key_files_license_keys, other_files_license_keys = get_unique_licenses(codebase, min_score) + + if key_files_license_keys and key_files_license_keys == other_files_license_keys: + scoring_element = True + + return scoring_element + + +def get_unique_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE, **kwargs): """ Return a tuple of two sets of license keys found in the codebase with at least min_score: - the set license found in key files @@ -298,10 +269,11 @@ def get_unique_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE): # FIXME: consider only text, source-like files for now if not resource.is_file: continue - if not (is_key_file(resource) or is_core_facet(resource)): + if not (resource.is_key_file or is_core_facet(resource)): + # we only cover core code or tope level, key filess continue - if is_key_file(resource): + if resource.is_key_file: license_keys = key_license_keys else: license_keys = other_license_keys @@ -314,7 +286,8 @@ def get_unique_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE): return key_license_keys, other_license_keys -def get_detected_license_keys_with_full_text(codebase, min_score=MIN_GOOD_LICENSE_SCORE): +def get_detected_license_keys_with_full_text(codebase, min_score=MIN_GOOD_LICENSE_SCORE, + key_files_only=False, **kwargs): """ Return a set of license keys for which at least one detection includes the full license text. @@ -328,6 +301,9 @@ def get_detected_license_keys_with_full_text(codebase, min_score=MIN_GOOD_LICENS if not resource.is_file: continue + if key_files_only and not resource.is_key_file: + continue + for detected_license in resource.licenses: if detected_license['score'] < min_score: continue @@ -338,7 +314,63 @@ def get_detected_license_keys_with_full_text(codebase, min_score=MIN_GOOD_LICENS return license_keys -def get_other_licenses_and_copyrights_counts(codebase, min_score=MIN_GOOD_LICENSE_SCORE): +def has_full_text_in_key_files_for_all_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE, **kwargs): + """ + Return True if the full text of all licenses is preset in the codebase key, top level files. + """ + return _has_full_text(codebase, min_score, key_files_only=True, **kwargs) + + +def has_full_text_for_all_licenses(codebase, min_score=MIN_GOOD_LICENSE_SCORE, **kwargs): + """ + Return True if the full text of all licenses is preset in the codebase. + """ + return _has_full_text(codebase, min_score, key_files_only=False, **kwargs) + + +def _has_full_text(codebase, min_score=MIN_GOOD_LICENSE_SCORE, key_files_only=False, **kwargs): + """ + Return True if the full text of all licenses is preset in the codebase. + Consider only key files if key_files_only is True. + """ + + key_files_license_keys, other_files_license_keys = get_unique_licenses( + codebase, min_score, **kwargs) + + if TRACE: + logger_debug('_has_full_text: key_files_license_keys:', key_files_license_keys, + 'other_files_license_keys:', other_files_license_keys) + + all_keys = key_files_license_keys & other_files_license_keys + keys_with_license_text = get_detected_license_keys_with_full_text( + codebase, min_score, key_files_only, **kwargs) + + if TRACE: + logger_debug('_has_full_text: keys_with_license_text:', keys_with_license_text) + + return all_keys and (all_keys == keys_with_license_text) + + +def get_file_level_license_and_copyright_coverage( + codebase, min_score=MIN_GOOD_LICENSE_SCORE, **kwargs): + """ + Return a + """ + scoring_element = 0 + covered_files, files_count = get_other_licenses_and_copyrights_counts(codebase, min_score) + if TRACE: + logger_debug('compute_license_score:covered_files:', + covered_files, 'files_count:', files_count) + + if files_count: + scoring_element = covered_files / files_count + if TRACE: + logger_debug('compute_license_score:scoring_element:', scoring_element) + return scoring_element + + +def get_other_licenses_and_copyrights_counts( + codebase, min_score=MIN_GOOD_LICENSE_SCORE, **kwargs): """ Return a tuple of (count of files with a license/copyright, total count of files). @@ -361,23 +393,88 @@ def get_other_licenses_and_copyrights_counts(codebase, min_score=MIN_GOOD_LICENS files_with_good_license_and_copyright_count = 0 for resource in codebase.walk(): - # FIXME: consider only text, source-like files for now - if is_key_file(resource) or not resource.is_file: + # consider non-key files + if resource.is_key_file or not resource.is_file: continue + + # ... in the core facet if not is_core_facet(resource): continue total_files_count += 1 + # ... without scan errors if resource.scan_errors: continue - if not (resource.licenses or resource.copyrights): + # ... with both a license and a copyright + if not (resource.licenses and resource.copyrights): continue + # ... where the license is a "good one" if not has_good_licenses(resource, min_score): continue files_with_good_license_and_copyright_count += 1 return files_with_good_license_and_copyright_count, total_files_count + + +@attr.s +class ScoringElement(object): + is_binary = attr.ib() + name = attr.ib() + scorer = attr.ib() + weight = attr.ib() + + +top_declared = ScoringElement( + is_binary=True, + name='has_declared_license_in_key_files', + scorer=get_declared_licenses_in_key_files, + weight=30) + +unkown = ScoringElement( + is_binary=True, + name='has_unkown_licenses', + scorer=has_unkown_licenses, + weight=15) + +full_text = ScoringElement( + is_binary=True, + name='has_full_text_for_all_licenses', + scorer=has_full_text_for_all_licenses, + weight=15) + +full_text_in_key_files = ScoringElement( + is_binary=True, + name='has_full_text_for_all_licenses', + scorer=has_full_text_in_key_files_for_all_licenses, + weight=15) + +file_coverage = ScoringElement( + is_binary=False, + name='file_level_license_and_copyright_coverage', + scorer=get_file_level_license_and_copyright_coverage, + weight=25) + +consistent_licenses = ScoringElement( + is_binary=True, + name='has_consistent_key_and_file_level_licenses', + scorer=has_consistent_key_and_file_level_licenses, + weight=15) + +spdx_licenses = ScoringElement( + is_binary=True, + name='is_using_only_spdx_licenses', + scorer=is_using_only_spdx_licenses, + weight=15) + + +SCORING_ELEMENTS = [ + top_declared, + file_coverage, + consistent_licenses, + spdx_licenses, + full_text +] diff --git a/tests/summarycode/data/score/basic-expected.json b/tests/summarycode/data/score/basic-expected.json new file mode 100644 index 00000000000..2e0b7897002 --- /dev/null +++ b/tests/summarycode/data/score/basic-expected.json @@ -0,0 +1,261 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 3, + "license_clarity_score": { + "score": 100, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 1.0, + "has_consistent_key_and_file_level_licenses": true, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": true + }, + "files": [ + { + "path": "basic", + "type": "directory", + "name": "basic", + "base_name": "basic", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 3, + "dirs_count": 0, + "size_count": 4258, + "scan_errors": [] + }, + { + "path": "basic/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 1320, + "date": "2018-10-29", + "sha1": "00f197776bbbca2726c6f1ccf258b6f08e6d3455", + "md5": "c284e8c75f00df967ea1c26065937335", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 19, + "end_line": 36, + "matched_rule": { + "identifier": "mit.LICENSE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "basic/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 2109, + "date": "2018-10-29", + "sha1": "1ef59e75d33ed8b7b43548fd55843d894db4b910", + "md5": "1385905becfdfd8d777342fcb1242d83", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 2, + "end_line": 19, + "matched_rule": { + "identifier": "mit.LICENSE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [ + { + "value": "nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "copyrights": [ + { + "value": "Copyright (c) 2007 nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "basic/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/basic/README.md b/tests/summarycode/data/score/basic/README.md new file mode 100644 index 00000000000..55f0759acfe --- /dev/null +++ b/tests/summarycode/data/score/basic/README.md @@ -0,0 +1,36 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` + + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/summarycode/data/score/basic/index.js b/tests/summarycode/data/score/basic/index.js new file mode 100644 index 00000000000..b6127d64177 --- /dev/null +++ b/tests/summarycode/data/score/basic/index.js @@ -0,0 +1,74 @@ +Copyright (c) 2007 nexB Inc. All right reserved +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module.exports = { + extends: [ + 'airbnb', + 'prettier', + 'prettier/flowtype', + 'prettier/react', + 'plugin:flowtype/recommended', + ], + parser: 'babel-eslint', + plugins: ['prettier', 'flowtype', 'react-functional-set-state'], + env: { + browser: true, + node: true, + jest: true, + }, + rules: { + 'no-undef-init': 1, + 'react/sort-comp': [ + 1, + { + order: [ + 'type-annotations', + 'static-methods', + 'lifecycle', + 'everything-else', + 'render', + ], + groups: { + rendering: ['/^render.+$/', 'render'], + }, + }, + ], + 'react/jsx-filename-extension': [ + 1, + { + extensions: ['.js'], + }, + ], + 'react-functional-set-state/no-this-state-props': 2, + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: true, + }, + ], + 'prettier/prettier': [ + 'error', + { + trailingComma: 'all', + singleQuote: true, + }, + ], + }, +}; diff --git a/tests/summarycode/data/score/basic/package.json b/tests/summarycode/data/score/basic/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/basic/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/consistent_licenses-expected.json b/tests/summarycode/data/score/consistent_licenses-expected.json new file mode 100644 index 00000000000..11b45ff1c43 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses-expected.json @@ -0,0 +1,253 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 3, + "license_clarity_score": { + "score": 60, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": true, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "consistent_licenses", + "type": "directory", + "name": "consistent_licenses", + "base_name": "consistent_licenses", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 3, + "dirs_count": 1, + "size_count": 1156, + "scan_errors": [] + }, + { + "path": "consistent_licenses/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "consistent_licenses/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "consistent_licenses/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 1, + "dirs_count": 0, + "size_count": 32, + "scan_errors": [] + }, + { + "path": "consistent_licenses/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 32, + "date": "2018-10-29", + "sha1": "4c9f2b0ba719d3e0d974753e4b6c828d6dfd2283", + "md5": "6ec41034e04432ee375d0e14fba596f4", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: mit", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/consistent_licenses/README.md b/tests/summarycode/data/score/consistent_licenses/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/consistent_licenses/package.json b/tests/summarycode/data/score/consistent_licenses/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/consistent_licenses/src/index.js b/tests/summarycode/data/score/consistent_licenses/src/index.js new file mode 100644 index 00000000000..8096cb46020 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses/src/index.js @@ -0,0 +1 @@ +// SPDX-License-Identifier: MIT diff --git a/tests/summarycode/data/score/consistent_licenses_not-expected.json b/tests/summarycode/data/score/consistent_licenses_not-expected.json new file mode 100644 index 00000000000..dbddbc7166c --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not-expected.json @@ -0,0 +1,253 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 3, + "license_clarity_score": { + "score": 45, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": false, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "consistent_licenses_not", + "type": "directory", + "name": "consistent_licenses_not", + "base_name": "consistent_licenses_not", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 3, + "dirs_count": 1, + "size_count": 1163, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 1, + "dirs_count": 0, + "size_count": 39, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 39, + "date": "2018-10-29", + "sha1": "783b61aa72c2dbc2e0406395dc4a0db19dbe9aa5", + "md5": "4f8ec6e05e980b2ef6a75510c6499cca", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "apache-2.0", + "score": 100.0, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": false, + "owner": "Apache Software Foundation", + "homepage_url": "http://www.apache.org/licenses/", + "text_url": "http://www.apache.org/licenses/LICENSE-2.0", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "apache-2.0" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/consistent_licenses_not/README.md b/tests/summarycode/data/score/consistent_licenses_not/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/consistent_licenses_not/package.json b/tests/summarycode/data/score/consistent_licenses_not/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/consistent_licenses_not/src/index.js b/tests/summarycode/data/score/consistent_licenses_not/src/index.js new file mode 100644 index 00000000000..cdc649ac064 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not/src/index.js @@ -0,0 +1 @@ +// SPDX-License-Identifier: Apache-2.0 diff --git a/tests/summarycode/data/score/consistent_licenses_not_spdx-expected.json b/tests/summarycode/data/score/consistent_licenses_not_spdx-expected.json new file mode 100644 index 00000000000..356b787baf3 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not_spdx-expected.json @@ -0,0 +1,253 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 3, + "license_clarity_score": { + "score": 60, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": true, + "is_using_only_spdx_licenses": false, + "has_full_text_for_all_licenses": true + }, + "files": [ + { + "path": "consistent_licenses_not_spdx", + "type": "directory", + "name": "consistent_licenses_not_spdx", + "base_name": "consistent_licenses_not_spdx", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 3, + "dirs_count": 1, + "size_count": 2150, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not_spdx/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 818, + "date": "2018-10-29", + "sha1": "e09dc519fe47e80fe5a979ff3fca08fc54bbf2a0", + "md5": "c757317fb2353180b339900b4b3d65f0", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit-xfig", + "score": 90.0, + "name": "MIT Xfig Variant", + "short_name": "MIT Xfig Variant", + "category": "Permissive", + "is_exception": false, + "owner": "Xfig Project", + "homepage_url": "http://www.xfig.org", + "text_url": "", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit-xfig", + "spdx_license_key": "", + "spdx_url": "", + "start_line": 17, + "end_line": 24, + "matched_rule": { + "identifier": "mit-xfig_1.RULE", + "license_expression": "mit-xfig", + "licenses": [ + "mit-xfig" + ], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "mit-xfig" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not_spdx/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 809, + "date": "2018-10-29", + "sha1": "c07fce758705b949299768f7a404a51ce31ead7a", + "md5": "6670be3f86bde3893f575303b9b33b24", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not_spdx/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 1, + "dirs_count": 0, + "size_count": 523, + "scan_errors": [] + }, + { + "path": "consistent_licenses_not_spdx/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 523, + "date": "2018-10-29", + "sha1": "c4f9a6573aec2765d3047b1c35018906b1878829", + "md5": "647e0d4966b3e27d15f56d6e7dcfab78", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit-xfig", + "score": 90.0, + "name": "MIT Xfig Variant", + "short_name": "MIT Xfig Variant", + "category": "Permissive", + "is_exception": false, + "owner": "Xfig Project", + "homepage_url": "http://www.xfig.org", + "text_url": "", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit-xfig", + "spdx_license_key": "", + "spdx_url": "", + "start_line": 1, + "end_line": 8, + "matched_rule": { + "identifier": "mit-xfig_1.RULE", + "license_expression": "mit-xfig", + "licenses": [ + "mit-xfig" + ], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "mit-xfig" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/consistent_licenses_not_spdx/README.md b/tests/summarycode/data/score/consistent_licenses_not_spdx/README.md new file mode 100644 index 00000000000..3c77f85f71c --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not_spdx/README.md @@ -0,0 +1,24 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` +Any party obtaining a copy of these files is granted, free of charge, a +full and unrestricted irrevocable, world-wide, paid up, royalty-free, +nonexclusive right and license to deal in this software and +documentation files (the "Software"), including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons who receive copies +from any such party to do so, with the only requirement being that this +copyright notice remain intact. diff --git a/tests/summarycode/data/score/consistent_licenses_not_spdx/package.json b/tests/summarycode/data/score/consistent_licenses_not_spdx/package.json new file mode 100644 index 00000000000..000d0fd9f00 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not_spdx/package.json @@ -0,0 +1,29 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/consistent_licenses_not_spdx/src/index.js b/tests/summarycode/data/score/consistent_licenses_not_spdx/src/index.js new file mode 100644 index 00000000000..9309ed09d42 --- /dev/null +++ b/tests/summarycode/data/score/consistent_licenses_not_spdx/src/index.js @@ -0,0 +1,8 @@ +Any party obtaining a copy of these files is granted, free of charge, a +full and unrestricted irrevocable, world-wide, paid up, royalty-free, +nonexclusive right and license to deal in this software and +documentation files (the "Software"), including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons who receive copies +from any such party to do so, with the only requirement being that this +copyright notice remain intact. diff --git a/tests/summarycode/data/score/file_coverage-expected.json b/tests/summarycode/data/score/file_coverage-expected.json new file mode 100644 index 00000000000..057ad3869a3 --- /dev/null +++ b/tests/summarycode/data/score/file_coverage-expected.json @@ -0,0 +1,357 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 5, + "license_clarity_score": { + "score": 68, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.33, + "has_consistent_key_and_file_level_licenses": true, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "file_coverage", + "type": "directory", + "name": "file_coverage", + "base_name": "file_coverage", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 5, + "dirs_count": 1, + "size_count": 1309, + "scan_errors": [] + }, + { + "path": "file_coverage/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "file_coverage/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "file_coverage/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 3, + "dirs_count": 0, + "size_count": 185, + "scan_errors": [] + }, + { + "path": "file_coverage/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 80, + "date": "2018-10-29", + "sha1": "1a7d7f3d183f25d76b1feb463536af0d3fc910dd", + "md5": "f0720dc66980838af42ffd077dc4ff8b", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: mit", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [ + { + "value": "nexB Inc.", + "start_line": 2, + "end_line": 2 + } + ], + "copyrights": [ + { + "value": "Copyright (c) 2007 nexB Inc.", + "start_line": 2, + "end_line": 2 + } + ], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "file_coverage/src/index2.js", + "type": "file", + "name": "index2.js", + "base_name": "index2", + "extension": ".js", + "size": 48, + "date": "2018-10-29", + "sha1": "1d3832cc4eb434502ef83b10f0db4ff2bfea461f", + "md5": "375540922bb49a362b660bd696e48fdd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [ + { + "value": "nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "copyrights": [ + { + "value": "Copyright (c) 2007 nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "file_coverage/src/test.java", + "type": "file", + "name": "test.java", + "base_name": "test", + "extension": ".java", + "size": 57, + "date": "2018-10-29", + "sha1": "da6b19af59bff9c997305550c52b98c3eb746e93", + "md5": "746ece6b838c1fcab25fb842f810cd9f", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "Java", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [ + { + "value": "nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "copyrights": [ + { + "value": "Copyright (c) 2007 nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/file_coverage/README.md b/tests/summarycode/data/score/file_coverage/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/file_coverage/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/file_coverage/package.json b/tests/summarycode/data/score/file_coverage/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/file_coverage/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/file_coverage/src/index.js b/tests/summarycode/data/score/file_coverage/src/index.js new file mode 100644 index 00000000000..e36391653db --- /dev/null +++ b/tests/summarycode/data/score/file_coverage/src/index.js @@ -0,0 +1,2 @@ +// SPDX-License-Identifier: MIT +Copyright (c) 2007 nexB Inc. All right reserved diff --git a/tests/summarycode/data/score/file_coverage/src/index2.js b/tests/summarycode/data/score/file_coverage/src/index2.js new file mode 100644 index 00000000000..9b060ddea40 --- /dev/null +++ b/tests/summarycode/data/score/file_coverage/src/index2.js @@ -0,0 +1 @@ +Copyright (c) 2007 nexB Inc. All right reserved diff --git a/tests/summarycode/data/score/file_coverage/src/test.java b/tests/summarycode/data/score/file_coverage/src/test.java new file mode 100644 index 00000000000..e917773f323 --- /dev/null +++ b/tests/summarycode/data/score/file_coverage/src/test.java @@ -0,0 +1,2 @@ +Copyright (c) 2007 nexB Inc. All right reserved +// empty diff --git a/tests/summarycode/data/score/full_text-expected.json b/tests/summarycode/data/score/full_text-expected.json new file mode 100644 index 00000000000..f9b073041b8 --- /dev/null +++ b/tests/summarycode/data/score/full_text-expected.json @@ -0,0 +1,317 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 4, + "license_clarity_score": { + "score": 75, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": true, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": true + }, + "files": [ + { + "path": "full_text", + "type": "directory", + "name": "full_text", + "base_name": "full_text", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 4, + "dirs_count": 1, + "size_count": 2179, + "scan_errors": [] + }, + { + "path": "full_text/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "full_text/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "full_text/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 2, + "dirs_count": 0, + "size_count": 1055, + "scan_errors": [] + }, + { + "path": "full_text/src/COPYING.md", + "type": "file", + "name": "COPYING.md", + "base_name": "COPYING", + "extension": ".md", + "size": 1023, + "date": "2018-10-29", + "sha1": "df156c6a0a89ed2a3bd4a473c68cf85907509ca0", + "md5": "657a566233888513e1f07ba13e2f47f1", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 18, + "matched_rule": { + "identifier": "mit.LICENSE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": true, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "full_text/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 32, + "date": "2018-10-29", + "sha1": "4c9f2b0ba719d3e0d974753e4b6c828d6dfd2283", + "md5": "6ec41034e04432ee375d0e14fba596f4", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: mit", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/full_text/README.md b/tests/summarycode/data/score/full_text/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/full_text/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/full_text/package.json b/tests/summarycode/data/score/full_text/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/full_text/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/full_text/src/COPYING.md b/tests/summarycode/data/score/full_text/src/COPYING.md new file mode 100644 index 00000000000..1bf98523e33 --- /dev/null +++ b/tests/summarycode/data/score/full_text/src/COPYING.md @@ -0,0 +1,18 @@ +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/summarycode/data/score/full_text/src/index.js b/tests/summarycode/data/score/full_text/src/index.js new file mode 100644 index 00000000000..8096cb46020 --- /dev/null +++ b/tests/summarycode/data/score/full_text/src/index.js @@ -0,0 +1 @@ +// SPDX-License-Identifier: MIT diff --git a/tests/summarycode/data/score/full_text_in_key_files-expected.json b/tests/summarycode/data/score/full_text_in_key_files-expected.json new file mode 100644 index 00000000000..19f9357d7b4 --- /dev/null +++ b/tests/summarycode/data/score/full_text_in_key_files-expected.json @@ -0,0 +1,317 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 4, + "license_clarity_score": { + "score": 75, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": true, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": true + }, + "files": [ + { + "path": "full_text_in_key_files", + "type": "directory", + "name": "full_text_in_key_files", + "base_name": "full_text_in_key_files", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 4, + "dirs_count": 1, + "size_count": 2179, + "scan_errors": [] + }, + { + "path": "full_text_in_key_files/COPYING.md", + "type": "file", + "name": "COPYING.md", + "base_name": "COPYING", + "extension": ".md", + "size": 1023, + "date": "2018-10-29", + "sha1": "df156c6a0a89ed2a3bd4a473c68cf85907509ca0", + "md5": "657a566233888513e1f07ba13e2f47f1", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 18, + "matched_rule": { + "identifier": "mit.LICENSE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": true, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "full_text_in_key_files/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "full_text_in_key_files/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "full_text_in_key_files/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 1, + "dirs_count": 0, + "size_count": 32, + "scan_errors": [] + }, + { + "path": "full_text_in_key_files/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 32, + "date": "2018-10-29", + "sha1": "4c9f2b0ba719d3e0d974753e4b6c828d6dfd2283", + "md5": "6ec41034e04432ee375d0e14fba596f4", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: mit", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/full_text_in_key_files/COPYING.md b/tests/summarycode/data/score/full_text_in_key_files/COPYING.md new file mode 100644 index 00000000000..1bf98523e33 --- /dev/null +++ b/tests/summarycode/data/score/full_text_in_key_files/COPYING.md @@ -0,0 +1,18 @@ +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/summarycode/data/score/full_text_in_key_files/README.md b/tests/summarycode/data/score/full_text_in_key_files/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/full_text_in_key_files/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/full_text_in_key_files/package.json b/tests/summarycode/data/score/full_text_in_key_files/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/full_text_in_key_files/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/full_text_in_key_files/src/index.js b/tests/summarycode/data/score/full_text_in_key_files/src/index.js new file mode 100644 index 00000000000..8096cb46020 --- /dev/null +++ b/tests/summarycode/data/score/full_text_in_key_files/src/index.js @@ -0,0 +1 @@ +// SPDX-License-Identifier: MIT diff --git a/tests/summarycode/data/score/single_file-expected.json b/tests/summarycode/data/score/single_file-expected.json new file mode 100644 index 00000000000..931c1d49862 --- /dev/null +++ b/tests/summarycode/data/score/single_file-expected.json @@ -0,0 +1,91 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 1, + "license_clarity_score": { + "score": 15, + "has_declared_license_in_key_files": false, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": false, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "single_file", + "type": "directory", + "name": "single_file", + "base_name": "single_file", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 1, + "dirs_count": 0, + "size_count": 11, + "scan_errors": [] + }, + { + "path": "single_file/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 11, + "date": "2018-10-29", + "sha1": "fc7cfc3571c2ff947a562c5f48cfcacba7aeb858", + "md5": "32296806c95d11fb5ae0ab083c1390c9", + "mime_type": "text/plain", + "file_type": "ASCII text, with no line terminators", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/single_file/README.md b/tests/summarycode/data/score/single_file/README.md new file mode 100644 index 00000000000..afc50e40cf0 --- /dev/null +++ b/tests/summarycode/data/score/single_file/README.md @@ -0,0 +1 @@ +Some readme \ No newline at end of file diff --git a/tests/summarycode/data/score/spdx_licenses-expected.json b/tests/summarycode/data/score/spdx_licenses-expected.json new file mode 100644 index 00000000000..1f30613aaec --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses-expected.json @@ -0,0 +1,317 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 4, + "license_clarity_score": { + "score": 60, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": true, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "spdx_licenses", + "type": "directory", + "name": "spdx_licenses", + "base_name": "spdx_licenses", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 4, + "dirs_count": 1, + "size_count": 1186, + "scan_errors": [] + }, + { + "path": "spdx_licenses/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "spdx_licenses/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "spdx_licenses/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 2, + "dirs_count": 0, + "size_count": 62, + "scan_errors": [] + }, + { + "path": "spdx_licenses/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 32, + "date": "2018-10-29", + "sha1": "4c9f2b0ba719d3e0d974753e4b6c828d6dfd2283", + "md5": "6ec41034e04432ee375d0e14fba596f4", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: mit", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "spdx_licenses/src/index2.js", + "type": "file", + "name": "index2.js", + "base_name": "index2", + "extension": ".js", + "size": 30, + "date": "2018-10-29", + "sha1": "d13739705c669be4eba590bb6b684f5dbfcbfb4d", + "md5": "21b5727747a414065e1e5534827fef02", + "mime_type": "text/plain", + "file_type": "ASCII text, with no line terminators", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "apache-2.0", + "score": 50.0, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": false, + "owner": "Apache Software Foundation", + "homepage_url": "http://www.apache.org/licenses/", + "text_url": "http://www.apache.org/licenses/LICENSE-2.0", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx_license_id_apache-2.0_for_apache-2.0.RULE", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "apache-2.0" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/spdx_licenses/README.md b/tests/summarycode/data/score/spdx_licenses/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/spdx_licenses/package.json b/tests/summarycode/data/score/spdx_licenses/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/spdx_licenses/src/index.js b/tests/summarycode/data/score/spdx_licenses/src/index.js new file mode 100644 index 00000000000..8096cb46020 --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses/src/index.js @@ -0,0 +1 @@ +// SPDX-License-Identifier: MIT diff --git a/tests/summarycode/data/score/spdx_licenses/src/index2.js b/tests/summarycode/data/score/spdx_licenses/src/index2.js new file mode 100644 index 00000000000..33307f1c2c5 --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses/src/index2.js @@ -0,0 +1 @@ +//based on Apache 2.0 License. \ No newline at end of file diff --git a/tests/summarycode/data/score/spdx_licenses_not-expected.json b/tests/summarycode/data/score/spdx_licenses_not-expected.json new file mode 100644 index 00000000000..340f6dc1fd0 --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses_not-expected.json @@ -0,0 +1,317 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 4, + "license_clarity_score": { + "score": 30, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": false, + "is_using_only_spdx_licenses": false, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "spdx_licenses_not", + "type": "directory", + "name": "spdx_licenses_not", + "base_name": "spdx_licenses_not", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 4, + "dirs_count": 1, + "size_count": 1254, + "scan_errors": [] + }, + { + "path": "spdx_licenses_not/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "spdx_licenses_not/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "spdx_licenses_not/src", + "type": "directory", + "name": "src", + "base_name": "src", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 2, + "dirs_count": 0, + "size_count": 130, + "scan_errors": [] + }, + { + "path": "spdx_licenses_not/src/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 32, + "date": "2018-10-29", + "sha1": "4c9f2b0ba719d3e0d974753e4b6c828d6dfd2283", + "md5": "6ec41034e04432ee375d0e14fba596f4", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 100.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: mit", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "spdx_licenses_not/src/index2.js", + "type": "file", + "name": "index2.js", + "base_name": "index2", + "extension": ".js", + "size": 98, + "date": "2018-10-29", + "sha1": "3e219659f4f4ca3387a682b5108034428fe385d9", + "md5": "b0974427598854f8fc3f4f89c2680ec3", + "mime_type": "text/plain", + "file_type": "ASCII text, with no line terminators", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [ + { + "key": "other-permissive", + "score": 94.0, + "name": "Other Permissive Licenses", + "short_name": "Other Permissive Licenses", + "category": "Permissive", + "is_exception": false, + "owner": "nexB", + "homepage_url": "", + "text_url": "", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:other-permissive", + "spdx_license_key": "", + "spdx_url": "", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "other-permissive_10.RULE", + "license_expression": "other-permissive", + "licenses": [ + "other-permissive" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false + } + } + ], + "license_expressions": [ + "other-permissive" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/spdx_licenses_not/README.md b/tests/summarycode/data/score/spdx_licenses_not/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses_not/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/spdx_licenses_not/package.json b/tests/summarycode/data/score/spdx_licenses_not/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses_not/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/spdx_licenses_not/src/index.js b/tests/summarycode/data/score/spdx_licenses_not/src/index.js new file mode 100644 index 00000000000..8096cb46020 --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses_not/src/index.js @@ -0,0 +1 @@ +// SPDX-License-Identifier: MIT diff --git a/tests/summarycode/data/score/spdx_licenses_not/src/index2.js b/tests/summarycode/data/score/spdx_licenses_not/src/index2.js new file mode 100644 index 00000000000..921ac89f376 --- /dev/null +++ b/tests/summarycode/data/score/spdx_licenses_not/src/index2.js @@ -0,0 +1 @@ +//This project is made available under its own **Blueprint License**, based on Apache 2.0 License. \ No newline at end of file diff --git a/tests/summarycode/data/score/top_declared-expected.json b/tests/summarycode/data/score/top_declared-expected.json new file mode 100644 index 00000000000..2e12e7789ef --- /dev/null +++ b/tests/summarycode/data/score/top_declared-expected.json @@ -0,0 +1,189 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 3, + "license_clarity_score": { + "score": 45, + "has_declared_license_in_key_files": true, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": false, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "top_declared", + "type": "directory", + "name": "top_declared", + "base_name": "top_declared", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 3, + "dirs_count": 0, + "size_count": 2161, + "scan_errors": [] + }, + { + "path": "top_declared/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "top_declared/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 1037, + "date": "2017-08-21", + "sha1": "53771edd1e0765de7400174e42ca2e8e5840055f", + "md5": "ec9dc4294f83d24294f07e6a0676c338", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "top_declared/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "date": "2017-08-29", + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "mit", + "score": 99.0, + "name": "MIT License", + "short_name": "MIT License", + "category": "Permissive", + "is_exception": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:mit", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_34.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true + } + } + ], + "license_expressions": [ + "mit" + ], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/top_declared/README.md b/tests/summarycode/data/score/top_declared/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/top_declared/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/top_declared/index.js b/tests/summarycode/data/score/top_declared/index.js new file mode 100644 index 00000000000..c98f2d67c87 --- /dev/null +++ b/tests/summarycode/data/score/top_declared/index.js @@ -0,0 +1,54 @@ +module.exports = { + extends: [ + 'airbnb', + 'prettier', + 'prettier/flowtype', + 'prettier/react', + 'plugin:flowtype/recommended', + ], + parser: 'babel-eslint', + plugins: ['prettier', 'flowtype', 'react-functional-set-state'], + env: { + browser: true, + node: true, + jest: true, + }, + rules: { + 'no-undef-init': 1, + 'react/sort-comp': [ + 1, + { + order: [ + 'type-annotations', + 'static-methods', + 'lifecycle', + 'everything-else', + 'render', + ], + groups: { + rendering: ['/^render.+$/', 'render'], + }, + }, + ], + 'react/jsx-filename-extension': [ + 1, + { + extensions: ['.js'], + }, + ], + 'react-functional-set-state/no-this-state-props': 2, + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: true, + }, + ], + 'prettier/prettier': [ + 'error', + { + trailingComma: 'all', + singleQuote: true, + }, + ], + }, +}; diff --git a/tests/summarycode/data/score/top_declared/package.json b/tests/summarycode/data/score/top_declared/package.json new file mode 100644 index 00000000000..f54d82ed9fa --- /dev/null +++ b/tests/summarycode/data/score/top_declared/package.json @@ -0,0 +1,30 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "license": "MIT", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/data/score/top_declared_not-expected.json b/tests/summarycode/data/score/top_declared_not-expected.json new file mode 100644 index 00000000000..168edf89d9b --- /dev/null +++ b/tests/summarycode/data/score/top_declared_not-expected.json @@ -0,0 +1,159 @@ +{ + "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "scancode_options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score": true + }, + "files_count": 3, + "license_clarity_score": { + "score": 15, + "has_declared_license_in_key_files": false, + "file_level_license_and_copyright_coverage": 0.0, + "has_consistent_key_and_file_level_licenses": false, + "is_using_only_spdx_licenses": true, + "has_full_text_for_all_licenses": false + }, + "files": [ + { + "path": "top_declared_not", + "type": "directory", + "name": "top_declared_not", + "base_name": "top_declared_not", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 3, + "dirs_count": 0, + "size_count": 2141, + "scan_errors": [] + }, + { + "path": "top_declared_not/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "date": "2017-07-05", + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "top_declared_not/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 1037, + "date": "2017-08-21", + "sha1": "53771edd1e0765de7400174e42ca2e8e5840055f", + "md5": "ec9dc4294f83d24294f07e6a0676c338", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "top_declared_not/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 809, + "date": "2018-10-29", + "sha1": "c07fce758705b949299768f7a404a51ce31ead7a", + "md5": "6670be3f86bde3893f575303b9b33b24", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "holders": [], + "copyrights": [], + "authors": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": true, + "is_key_file": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score/top_declared_not/README.md b/tests/summarycode/data/score/top_declared_not/README.md new file mode 100644 index 00000000000..5609113f254 --- /dev/null +++ b/tests/summarycode/data/score/top_declared_not/README.md @@ -0,0 +1,16 @@ +# @invisionag/eslint-config-ivx + +# Usage + +Install the peer dependencies as development dependencies: +- `eslint^3.19.0` +- `prettier^1.5.2` + +Install `@invisionag/eslint-config-ivx` as a development dependency. + +In your `.eslintrc.js`: +```js +module.exports = { + extends: '@invisionag/ivx', +}; +``` diff --git a/tests/summarycode/data/score/top_declared_not/index.js b/tests/summarycode/data/score/top_declared_not/index.js new file mode 100644 index 00000000000..c98f2d67c87 --- /dev/null +++ b/tests/summarycode/data/score/top_declared_not/index.js @@ -0,0 +1,54 @@ +module.exports = { + extends: [ + 'airbnb', + 'prettier', + 'prettier/flowtype', + 'prettier/react', + 'plugin:flowtype/recommended', + ], + parser: 'babel-eslint', + plugins: ['prettier', 'flowtype', 'react-functional-set-state'], + env: { + browser: true, + node: true, + jest: true, + }, + rules: { + 'no-undef-init': 1, + 'react/sort-comp': [ + 1, + { + order: [ + 'type-annotations', + 'static-methods', + 'lifecycle', + 'everything-else', + 'render', + ], + groups: { + rendering: ['/^render.+$/', 'render'], + }, + }, + ], + 'react/jsx-filename-extension': [ + 1, + { + extensions: ['.js'], + }, + ], + 'react-functional-set-state/no-this-state-props': 2, + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: true, + }, + ], + 'prettier/prettier': [ + 'error', + { + trailingComma: 'all', + singleQuote: true, + }, + ], + }, +}; diff --git a/tests/summarycode/data/score/top_declared_not/package.json b/tests/summarycode/data/score/top_declared_not/package.json new file mode 100644 index 00000000000..000d0fd9f00 --- /dev/null +++ b/tests/summarycode/data/score/top_declared_not/package.json @@ -0,0 +1,29 @@ +{ + "name": "@invisionag/eslint-config-ivx", + "version": "0.0.10", + "main": "index.js", + "repository": "https://github.com/ivx/eslint-config-ivx.git", + "author": "Alexander Plavinski ", + "scripts": { + "test": "eslint ." + }, + "peerDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + }, + "dependencies": { + "babel-eslint": "^7.2.3", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-prettier": "^2.3.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-prettier": "^2.2.0", + "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react-functional-set-state": "^1.0.1" + }, + "devDependencies": { + "eslint": "^4.5.0", + "prettier": "^1.6.0" + } +} diff --git a/tests/summarycode/test_score.py b/tests/summarycode/test_score.py new file mode 100644 index 00000000000..13dbe6f7545 --- /dev/null +++ b/tests/summarycode/test_score.py @@ -0,0 +1,106 @@ +# +# Copyright (c) 2018 nexB Inc. and others. All rights reserved. +# http://nexb.com and https://github.com/nexB/scancode-toolkit/ +# The ScanCode software is licensed under the Apache License version 2.0. +# Data generated with ScanCode require an acknowledgment. +# ScanCode is a trademark of nexB Inc. +# +# You may not use this software except in compliance with the License. +# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# +# When you publish or redistribute any data created with ScanCode or any ScanCode +# derivative work, you must accompany this data with the following acknowledgment: +# +# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES +# OR CONDITIONS OF ANY KIND, either express or implied. No content created from +# ScanCode should be considered or used as legal advice. Consult an Attorney +# for any legal advice. +# ScanCode is a free software code scanning tool from nexB Inc. and others. +# Visit https://github.com/nexB/scancode-toolkit/ for support and download. + +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + +import os +import click +click.disable_unicode_literals_warning = True + +from commoncode.testcase import FileDrivenTesting +from commoncode.text import python_safe_name + +from scancode.cli_test_utils import check_json_scan +from scancode.cli_test_utils import run_scan_click + +""" +Data-driven Score test utilities. +""" + +test_env = FileDrivenTesting() +test_env.test_data_dir = os.path.join(os.path.dirname(__file__), 'data') + + +def make_test_function(test_name, test_dir, expected_file, regen=False): + """ + Build and return a test function closing on tests arguments and the function + name. Create only a single function for multiple tests (e.g. copyrights and + holders together). + """ + + def closure_test_function(*args, **kwargs): + result_file = test_env.get_temp_file('json') + args = ['--license', + '--copyright', + '--info', + '--classify', + '--license-clarity-score', + test_dir, '--json', result_file] + run_scan_click(args) + run_scan_click(args) + check_json_scan(test_env.get_test_loc(expected_file), result_file, regen=regen) + + test_name = 'test_license_clarity_score_%(test_name)s' % locals() + test_name = python_safe_name(test_name) + if isinstance(test_name, unicode): + test_name = test_name.encode('utf-8') + + closure_test_function.__name__ = test_name + closure_test_function.funcname = test_name + + return closure_test_function, test_name + + +def build_tests(test_base_dir, clazz, regen=False): + """ + Dynamically build test methods from a sequence of CopyrightTest and attach + these method to the clazz test class. + """ + test_dirs = test_env.get_test_loc(test_base_dir) + for td in os.listdir(test_dirs): + td_loc = os.path.join(test_dirs, td) + if not os.path.isdir(td_loc): + continue + expected_file_loc = td_loc.rstrip('/\\') + '-expected.json' + if regen and not os.path.exists(expected_file_loc): + with open(expected_file_loc, 'wb') as o: + o.write('') + method, name = make_test_function( + test_name=td, + test_dir=td_loc, + expected_file=expected_file_loc, + regen=regen) + + # attach that method to our test class + setattr(clazz, name, method) + + +class TestLicenseScore(FileDrivenTesting): + # test functions are attached to this class at module import time + pass + + +build_tests(test_base_dir='score', clazz=TestLicenseScore, regen=False)