From d8bb5dc444326cd4cf34d55d7d36aa92f1701901 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Fri, 18 Feb 2022 18:53:06 -0800 Subject: [PATCH] Add tests for new license clarity scoring #2861 Signed-off-by: Jono Yang --- src/summarycode/score2.py | 5 + tests/scancode/data/help/help.txt | 74 ++-- .../data/score2/basic-expected.json | 328 ++++++++++++++ tests/summarycode/data/score2/basic/README.md | 37 ++ tests/summarycode/data/score2/basic/index.js | 74 ++++ .../data/score2/basic/package.json | 30 ++ ...consistent_licenses_copyleft-expected.json | 404 ++++++++++++++++++ .../inconsistent_licenses_copyleft/README.md | 37 ++ .../inconsistent_licenses_copyleft/index.js | 74 ++++ .../package.json | 30 ++ .../inconsistent_licenses_copyleft/util.js | 1 + .../no_license_or_copyright-expected.json | 181 ++++++++ .../score2/no_license_or_copyright/README.md | 16 + .../score2/no_license_or_copyright/index.js | 54 +++ .../no_license_or_copyright/package.json | 30 ++ .../data/score2/no_license_text-expected.json | 234 ++++++++++ .../data/score2/no_license_text/README.md | 18 + .../data/score2/no_license_text/index.js | 54 +++ .../data/score2/no_license_text/package.json | 30 ++ tests/summarycode/test_score2.py | 99 +++++ 20 files changed, 1775 insertions(+), 35 deletions(-) create mode 100644 tests/summarycode/data/score2/basic-expected.json create mode 100644 tests/summarycode/data/score2/basic/README.md create mode 100644 tests/summarycode/data/score2/basic/index.js create mode 100644 tests/summarycode/data/score2/basic/package.json create mode 100644 tests/summarycode/data/score2/inconsistent_licenses_copyleft-expected.json create mode 100644 tests/summarycode/data/score2/inconsistent_licenses_copyleft/README.md create mode 100644 tests/summarycode/data/score2/inconsistent_licenses_copyleft/index.js create mode 100644 tests/summarycode/data/score2/inconsistent_licenses_copyleft/package.json create mode 100644 tests/summarycode/data/score2/inconsistent_licenses_copyleft/util.js create mode 100644 tests/summarycode/data/score2/no_license_or_copyright-expected.json create mode 100644 tests/summarycode/data/score2/no_license_or_copyright/README.md create mode 100644 tests/summarycode/data/score2/no_license_or_copyright/index.js create mode 100644 tests/summarycode/data/score2/no_license_or_copyright/package.json create mode 100644 tests/summarycode/data/score2/no_license_text-expected.json create mode 100644 tests/summarycode/data/score2/no_license_text/README.md create mode 100644 tests/summarycode/data/score2/no_license_text/index.js create mode 100644 tests/summarycode/data/score2/no_license_text/package.json create mode 100644 tests/summarycode/test_score2.py diff --git a/src/summarycode/score2.py b/src/summarycode/score2.py index af6585f568..ea7e98d353 100644 --- a/src/summarycode/score2.py +++ b/src/summarycode/score2.py @@ -122,6 +122,9 @@ def compute_license_score(codebase): def check_ambiguous_license_expression(declared_license_expressions): + if not declared_license_expressions: + return False + unique_declared_license_expressions = set(declared_license_expressions) if len(unique_declared_license_expressions) == 1: return False @@ -331,6 +334,8 @@ def check_declared_licenses(declared_licenses): If so, return True. Otherwise, return False. """ + if not declared_licenses: + return False return all( is_good_license(declared_license) for declared_license diff --git a/tests/scancode/data/help/help.txt b/tests/scancode/data/help/help.txt index 350d7b25f6..ae661b4699 100644 --- a/tests/scancode/data/help/help.txt +++ b/tests/scancode/data/help/help.txt @@ -89,41 +89,45 @@ Options: . post-scan: - --consolidate Group resources by Packages or license and copyright - holder and return those groupings as a list of - consolidated packages and a list of consolidated - components. This requires the scan to have/be run - with the copyright, license, and package options - active - --filter-clues Filter redundant duplicated clues already contained - in detected license and copyright texts and notices. - --is-license-text Set the "is_license_text" flag to true for files that - contain mostly license texts and notices (e.g over - 90% of the content).[DEPRECATED] this is now built-in - in the --license-text option with a - "percentage_of_license_text" attribute. - --license-clarity-score Compute a summary license clarity score at the - codebase level. - --license-policy FILE Load a License Policy file and apply it to the scan - at the Resource level. - --licenses-reference Include a reference of all the licenses referenced in - this scan with the data details and full texts. - --mark-source Set the "is_source" to true for directories that - contain over 90% of source files as children and - descendants. Count the number of source files in a - directory as a new source_file_counts attribute - --summary Summarize license, copyright and other scans at the - codebase level. - --summary-by-facet Summarize license, copyright and other scans and - group the results by facet. - --summary-key-files Summarize license, copyright and other scans for key, - top-level files. Key files are top-level codebase - files such as COPYING, README and package manifests - as reported by the --classify option "is_legal", - "is_readme", "is_manifest" and "is_top_level" flags. - --summary-with-details Summarize license, copyright and other scans at the - codebase level, keeping intermediate details at the - file and directory level. + --consolidate Group resources by Packages or license and + copyright holder and return those groupings as a + list of consolidated packages and a list of + consolidated components. This requires the scan to + have/be run with the copyright, license, and + package options active + --filter-clues Filter redundant duplicated clues already contained + in detected license and copyright texts and + notices. + --is-license-text Set the "is_license_text" flag to true for files + that contain mostly license texts and notices (e.g + over 90% of the content).[DEPRECATED] this is now + built-in in the --license-text option with a + "percentage_of_license_text" attribute. + --license-clarity-score Compute a summary license clarity score at the + codebase level. + --license-clarity-score-2 Compute a summary license clarity score at the + codebase level. + --license-policy FILE Load a License Policy file and apply it to the scan + at the Resource level. + --licenses-reference Include a reference of all the licenses referenced + in this scan with the data details and full texts. + --mark-source Set the "is_source" to true for directories that + contain over 90% of source files as children and + descendants. Count the number of source files in a + directory as a new source_file_counts attribute + --summary Summarize license, copyright and other scans at the + codebase level. + --summary-by-facet Summarize license, copyright and other scans and + group the results by facet. + --summary-key-files Summarize license, copyright and other scans for + key, top-level files. Key files are top-level + codebase files such as COPYING, README and package + manifests as reported by the --classify option + "is_legal", "is_readme", "is_manifest" and + "is_top_level" flags. + --summary-with-details Summarize license, copyright and other scans at the + codebase level, keeping intermediate details at the + file and directory level. core: --timeout Stop an unfinished file scan after a timeout in diff --git a/tests/summarycode/data/score2/basic-expected.json b/tests/summarycode/data/score2/basic-expected.json new file mode 100644 index 0000000000..bb4717d38b --- /dev/null +++ b/tests/summarycode/data/score2/basic-expected.json @@ -0,0 +1,328 @@ +{ + "headers": [ + { + "tool_name": "scancode-toolkit", + "options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score-2": true + }, + "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.", + "output_format_version": "2.0.0", + "message": null, + "errors": [], + "extra_data": { + "spdx_license_list_version": "3.16", + "files_count": 3 + } + } + ], + "license_clarity_score": { + "score": 100, + "declared_license": true, + "precise_license_detection": true, + "has_license_text": true, + "declared_copyrights": true, + "conflicting_license_categories": false, + "ambigous_compound_licensing": false + }, + "files": [ + { + "path": "basic", + "type": "directory", + "name": "basic", + "base_name": "basic", + "extension": "", + "size": 0, + "sha1": null, + "md5": null, + "sha256": 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": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "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": 4286, + "scan_errors": [] + }, + { + "path": "basic/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 1348, + "sha1": "f4399249b905c17338eb06776a7205d6f643d396", + "md5": "d897358d498fd2dbb1efedfa297fc0f3", + "sha256": "63940bc96c0feeef3b22b96d7d6a4873cdb7f12151ce3362967afdc7f8ec6698", + "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, + "is_unknown": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 20, + "end_line": 37, + "matched_rule": { + "identifier": "mit.LICENSE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "referenced_filenames": [], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 161, + "matched_length": 161, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "mit" + ], + "percentage_of_license_text": 79.31, + "copyrights": [ + { + "copyright": "Copyright (c) Example, Inc.", + "start_line": 18, + "end_line": 18 + } + ], + "holders": [ + { + "holder": "Example, Inc.", + "start_line": 18, + "end_line": 18 + } + ], + "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, + "sha1": "1ef59e75d33ed8b7b43548fd55843d894db4b910", + "md5": "1385905becfdfd8d777342fcb1242d83", + "sha256": "1780e44cd2317e04461131b34ea6fa5b1da4a571123c9a391ddc3b865c456298", + "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, + "is_unknown": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "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" + ], + "referenced_filenames": [], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 161, + "matched_length": 161, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "mit" + ], + "percentage_of_license_text": 64.4, + "copyrights": [ + { + "copyright": "Copyright (c) 2007 nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "holders": [ + { + "holder": "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, + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "sha256": "d27968b827780212a965387f5ec3421ee59a0bf9166847629db0e716e6d2d9c3", + "mime_type": "application/json", + "file_type": "JSON data", + "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, + "is_unknown": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_30.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "referenced_filenames": [], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 2, + "matched_length": 2, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "mit" + ], + "percentage_of_license_text": 1.83, + "copyrights": [], + "holders": [], + "authors": [ + { + "author": "Alexander Plavinski ", + "start_line": 6, + "end_line": 6 + } + ], + "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/score2/basic/README.md b/tests/summarycode/data/score2/basic/README.md new file mode 100644 index 0000000000..f006181c3c --- /dev/null +++ b/tests/summarycode/data/score2/basic/README.md @@ -0,0 +1,37 @@ +# @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', +}; +``` + +Copyright (c) Example, Inc. + +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/score2/basic/index.js b/tests/summarycode/data/score2/basic/index.js new file mode 100644 index 0000000000..b6127d6417 --- /dev/null +++ b/tests/summarycode/data/score2/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/score2/basic/package.json b/tests/summarycode/data/score2/basic/package.json new file mode 100644 index 0000000000..f54d82ed9f --- /dev/null +++ b/tests/summarycode/data/score2/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/score2/inconsistent_licenses_copyleft-expected.json b/tests/summarycode/data/score2/inconsistent_licenses_copyleft-expected.json new file mode 100644 index 0000000000..f5c0012160 --- /dev/null +++ b/tests/summarycode/data/score2/inconsistent_licenses_copyleft-expected.json @@ -0,0 +1,404 @@ +{ + "headers": [ + { + "tool_name": "scancode-toolkit", + "options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score-2": true + }, + "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.", + "output_format_version": "2.0.0", + "message": null, + "errors": [], + "extra_data": { + "spdx_license_list_version": "3.16", + "files_count": 4 + } + } + ], + "license_clarity_score": { + "score": 80, + "declared_license": true, + "precise_license_detection": true, + "has_license_text": true, + "declared_copyrights": true, + "conflicting_license_categories": true, + "ambigous_compound_licensing": false + }, + "files": [ + { + "path": "inconsistent_licenses_copyleft", + "type": "directory", + "name": "inconsistent_licenses_copyleft", + "base_name": "inconsistent_licenses_copyleft", + "extension": "", + "size": 0, + "sha1": null, + "md5": null, + "sha256": 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": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "files_count": 4, + "dirs_count": 0, + "size_count": 4331, + "scan_errors": [] + }, + { + "path": "inconsistent_licenses_copyleft/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 1348, + "sha1": "f4399249b905c17338eb06776a7205d6f643d396", + "md5": "d897358d498fd2dbb1efedfa297fc0f3", + "sha256": "63940bc96c0feeef3b22b96d7d6a4873cdb7f12151ce3362967afdc7f8ec6698", + "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, + "is_unknown": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 20, + "end_line": 37, + "matched_rule": { + "identifier": "mit.LICENSE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "referenced_filenames": [], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 161, + "matched_length": 161, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "mit" + ], + "percentage_of_license_text": 79.31, + "copyrights": [ + { + "copyright": "Copyright (c) Example, Inc.", + "start_line": 18, + "end_line": 18 + } + ], + "holders": [ + { + "holder": "Example, Inc.", + "start_line": 18, + "end_line": 18 + } + ], + "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": "inconsistent_licenses_copyleft/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 2109, + "sha1": "1ef59e75d33ed8b7b43548fd55843d894db4b910", + "md5": "1385905becfdfd8d777342fcb1242d83", + "sha256": "1780e44cd2317e04461131b34ea6fa5b1da4a571123c9a391ddc3b865c456298", + "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, + "is_unknown": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "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" + ], + "referenced_filenames": [], + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 161, + "matched_length": 161, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "mit" + ], + "percentage_of_license_text": 64.4, + "copyrights": [ + { + "copyright": "Copyright (c) 2007 nexB Inc.", + "start_line": 1, + "end_line": 1 + } + ], + "holders": [ + { + "holder": "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": "inconsistent_licenses_copyleft/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "sha256": "d27968b827780212a965387f5ec3421ee59a0bf9166847629db0e716e6d2d9c3", + "mime_type": "application/json", + "file_type": "JSON data", + "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, + "is_unknown": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_30.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "referenced_filenames": [], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 2, + "matched_length": 2, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "mit" + ], + "percentage_of_license_text": 1.83, + "copyrights": [], + "holders": [], + "authors": [ + { + "author": "Alexander Plavinski ", + "start_line": 6, + "end_line": 6 + } + ], + "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": "inconsistent_licenses_copyleft/util.js", + "type": "file", + "name": "util.js", + "base_name": "util", + "extension": ".js", + "size": 45, + "sha1": "b5a76aa5d8949d6ddfc8ef41b0d4e459e3a32d0a", + "md5": "7226e442a172bcf25807246d7ef1eba1", + "sha256": "2daca237bc5b60e3b7ba984cccdd11927fccaa519ba6e0c0ff7dc812e19d8650", + "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": "gpl-2.0-plus", + "score": 100.0, + "name": "GNU General Public License 2.0 or later", + "short_name": "GPL 2.0 or later", + "category": "Copyleft", + "is_exception": false, + "is_unknown": false, + "owner": "Free Software Foundation (FSF)", + "homepage_url": "http://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html", + "text_url": "http://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html", + "reference_url": "https://scancode-licensedb.aboutcode.org/gpl-2.0-plus", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/gpl-2.0-plus.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/gpl-2.0-plus.yml", + "spdx_license_key": "GPL-2.0-or-later", + "spdx_url": "https://spdx.org/licenses/GPL-2.0-or-later", + "start_line": 1, + "end_line": 1, + "matched_rule": { + "identifier": "spdx-license-identifier: gpl-2.0-plus", + "license_expression": "gpl-2.0-plus", + "licenses": [ + "gpl-2.0-plus" + ], + "referenced_filenames": [], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "is_license_intro": false, + "has_unknown": false, + "matcher": "1-spdx-id", + "rule_length": 8, + "matched_length": 8, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "gpl-2.0-plus" + ], + "percentage_of_license_text": 100.0, + "copyrights": [], + "holders": [], + "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": [] + } + ] +} \ No newline at end of file diff --git a/tests/summarycode/data/score2/inconsistent_licenses_copyleft/README.md b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/README.md new file mode 100644 index 0000000000..f006181c3c --- /dev/null +++ b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/README.md @@ -0,0 +1,37 @@ +# @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', +}; +``` + +Copyright (c) Example, Inc. + +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/score2/inconsistent_licenses_copyleft/index.js b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/index.js new file mode 100644 index 0000000000..b6127d6417 --- /dev/null +++ b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/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/score2/inconsistent_licenses_copyleft/package.json b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/package.json new file mode 100644 index 0000000000..f54d82ed9f --- /dev/null +++ b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/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/score2/inconsistent_licenses_copyleft/util.js b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/util.js new file mode 100644 index 0000000000..0cb46d2c98 --- /dev/null +++ b/tests/summarycode/data/score2/inconsistent_licenses_copyleft/util.js @@ -0,0 +1 @@ +// SPDX-License-Identifier: GPL-2.0-or-later diff --git a/tests/summarycode/data/score2/no_license_or_copyright-expected.json b/tests/summarycode/data/score2/no_license_or_copyright-expected.json new file mode 100644 index 0000000000..0fb33bd217 --- /dev/null +++ b/tests/summarycode/data/score2/no_license_or_copyright-expected.json @@ -0,0 +1,181 @@ +{ + "headers": [ + { + "tool_name": "scancode-toolkit", + "options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score-2": true + }, + "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.", + "output_format_version": "2.0.0", + "message": null, + "errors": [], + "extra_data": { + "spdx_license_list_version": "3.16", + "files_count": 3 + } + } + ], + "license_clarity_score": { + "score": 0, + "declared_license": false, + "precise_license_detection": false, + "has_license_text": false, + "declared_copyrights": false, + "conflicting_license_categories": false, + "ambigous_compound_licensing": false + }, + "files": [ + { + "path": "no_license_or_copyright", + "type": "directory", + "name": "no_license_or_copyright", + "base_name": "no_license_or_copyright", + "extension": "", + "size": 0, + "sha1": null, + "md5": null, + "sha256": 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": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "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": 2158, + "scan_errors": [] + }, + { + "path": "no_license_or_copyright/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 295, + "sha1": "7d770c5ffdcf659c944a670225ab43db9f33d4a8", + "md5": "4b8955afbb3a8aa01933e99e331e4acf", + "sha256": "aac3e1032f4dffd347854cbe37d559223f2d61173caa649ca7cd0cfb11987334", + "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": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "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": "no_license_or_copyright/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 1037, + "sha1": "53771edd1e0765de7400174e42ca2e8e5840055f", + "md5": "ec9dc4294f83d24294f07e6a0676c338", + "sha256": "2b61833228890116dded1849a683d31d0273e0cf985a7bf0cc419aa7edefd839", + "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": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "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": "no_license_or_copyright/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 826, + "sha1": "adc72f5ee8e1dde3606dd3abbae6b16ae36147c8", + "md5": "bc23bb45c7f272127a346faa8b97da74", + "sha256": "a93777fcaee28dcc75e8b9187f5fae73ebc651d24f6825587c87553c5260a06d", + "mime_type": "application/json", + "file_type": "JSON data", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [ + { + "author": "Alexander Plavinski ", + "start_line": 6, + "end_line": 6 + } + ], + "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/score2/no_license_or_copyright/README.md b/tests/summarycode/data/score2/no_license_or_copyright/README.md new file mode 100644 index 0000000000..5609113f25 --- /dev/null +++ b/tests/summarycode/data/score2/no_license_or_copyright/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/score2/no_license_or_copyright/index.js b/tests/summarycode/data/score2/no_license_or_copyright/index.js new file mode 100644 index 0000000000..c98f2d67c8 --- /dev/null +++ b/tests/summarycode/data/score2/no_license_or_copyright/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/score2/no_license_or_copyright/package.json b/tests/summarycode/data/score2/no_license_or_copyright/package.json new file mode 100644 index 0000000000..a39b1f8f9f --- /dev/null +++ b/tests/summarycode/data/score2/no_license_or_copyright/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": "", + "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/score2/no_license_text-expected.json b/tests/summarycode/data/score2/no_license_text-expected.json new file mode 100644 index 0000000000..92e16f6004 --- /dev/null +++ b/tests/summarycode/data/score2/no_license_text-expected.json @@ -0,0 +1,234 @@ +{ + "headers": [ + { + "tool_name": "scancode-toolkit", + "options": { + "input": "", + "--classify": true, + "--copyright": true, + "--info": true, + "--json": "", + "--license": true, + "--license-clarity-score-2": true + }, + "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.", + "output_format_version": "2.0.0", + "message": null, + "errors": [], + "extra_data": { + "spdx_license_list_version": "3.16", + "files_count": 3 + } + } + ], + "license_clarity_score": { + "score": 90, + "declared_license": true, + "precise_license_detection": true, + "has_license_text": false, + "declared_copyrights": true, + "conflicting_license_categories": false, + "ambigous_compound_licensing": false + }, + "files": [ + { + "path": "no_license_text", + "type": "directory", + "name": "no_license_text", + "base_name": "no_license_text", + "extension": "", + "size": 0, + "sha1": null, + "md5": null, + "sha256": 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": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "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": 2190, + "scan_errors": [] + }, + { + "path": "no_license_text/README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 324, + "sha1": "5ddd71551f75d62539ba1c629268c05dea33df70", + "md5": "5e86afc76a17ee8be9cf19a6e0fd5226", + "sha256": "2ce5c5aee36b67f7a1ba28494ad150f9db7a6c2706830d071184e8d8e3ce29d4", + "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": [], + "percentage_of_license_text": 0, + "copyrights": [ + { + "copyright": "Copyright (c) Example, Inc.", + "start_line": 18, + "end_line": 18 + } + ], + "holders": [ + { + "holder": "Example, Inc.", + "start_line": 18, + "end_line": 18 + } + ], + "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": "no_license_text/index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 1037, + "sha1": "53771edd1e0765de7400174e42ca2e8e5840055f", + "md5": "ec9dc4294f83d24294f07e6a0676c338", + "sha256": "2b61833228890116dded1849a683d31d0273e0cf985a7bf0cc419aa7edefd839", + "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": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "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": "no_license_text/package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 829, + "sha1": "003103b742ebfb1e76e80d9fc05ab0b3046f2ab6", + "md5": "bd8911e2d8af0caa689f76b9975761fd", + "sha256": "d27968b827780212a965387f5ec3421ee59a0bf9166847629db0e716e6d2d9c3", + "mime_type": "application/json", + "file_type": "JSON data", + "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, + "is_unknown": false, + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "text_url": "http://opensource.org/licenses/mit-license.php", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "spdx_license_key": "MIT", + "spdx_url": "https://spdx.org/licenses/MIT", + "start_line": 7, + "end_line": 7, + "matched_rule": { + "identifier": "mit_30.RULE", + "license_expression": "mit", + "licenses": [ + "mit" + ], + "referenced_filenames": [], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 2, + "matched_length": 2, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "mit" + ], + "percentage_of_license_text": 1.83, + "copyrights": [], + "holders": [], + "authors": [ + { + "author": "Alexander Plavinski ", + "start_line": 6, + "end_line": 6 + } + ], + "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/score2/no_license_text/README.md b/tests/summarycode/data/score2/no_license_text/README.md new file mode 100644 index 0000000000..7d56e86b88 --- /dev/null +++ b/tests/summarycode/data/score2/no_license_text/README.md @@ -0,0 +1,18 @@ +# @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', +}; +``` + +Copyright (c) Example, Inc. diff --git a/tests/summarycode/data/score2/no_license_text/index.js b/tests/summarycode/data/score2/no_license_text/index.js new file mode 100644 index 0000000000..c98f2d67c8 --- /dev/null +++ b/tests/summarycode/data/score2/no_license_text/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/score2/no_license_text/package.json b/tests/summarycode/data/score2/no_license_text/package.json new file mode 100644 index 0000000000..f54d82ed9f --- /dev/null +++ b/tests/summarycode/data/score2/no_license_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/test_score2.py b/tests/summarycode/test_score2.py new file mode 100644 index 0000000000..81019192a4 --- /dev/null +++ b/tests/summarycode/test_score2.py @@ -0,0 +1,99 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# ScanCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/scancode-toolkit for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +import io +import os + +import click +import pytest + +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 + + +pytestmark = pytest.mark.scanslow + + +""" +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-2', + 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, + remove_file_date=True, + regen=regen, + ) + + test_name = 'test_license_clarity_score_%(test_name)s' % locals() + test_name = python_safe_name(test_name) + if isinstance(test_name, bytes): + test_name = test_name.decode('utf-8') + + closure_test_function.__name__ = 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 io.open(expected_file_loc, 'w') as o: + o.write(u'') + + 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='score2', clazz=TestLicenseScore, regen=False)