Skip to content

Commit 278b9ce

Browse files
committed
improve rule detection test and rename some filenames
Signed-off-by: Alok Kumar <[email protected]>
1 parent 1cc9385 commit 278b9ce

File tree

7 files changed

+102
-108
lines changed

7 files changed

+102
-108
lines changed

src/licensedcode/detection.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,14 +1101,6 @@ def is_correct_detection(license_matches):
11011101
)
11021102

11031103

1104-
def has_extra_phrases(license_matches):
1105-
"""
1106-
Return True if any of the matches in `license_matches` list of LicenseMatch
1107-
have the `extra-phrase` marker in their matches rule.
1108-
"""
1109-
return any(match.rule.extra_phrase_spans for match in license_matches)
1110-
1111-
11121104
def is_match_coverage_less_than_threshold(license_matches, threshold, any_matches=True):
11131105
"""
11141106
Return True if any of the matches in ``license_matches`` List of LicenseMatch

tests/licensedcode/data/plugin_license/extra-words/scan-extra-words-3-seq-license.expected.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
{
22
"license_detections": [
33
{
4-
"identifier": "bsd_new-f757f201-d182-a694-093b-6c34d20e9f8e",
4+
"identifier": "bsd_new-4b08a4bf-cc63-bee9-d78c-bec80b3f58f4",
55
"license_expression": "bsd-new",
66
"license_expression_spdx": "BSD-3-Clause",
77
"detection_count": 1,
88
"detection_log": [
9-
"extra-words"
9+
"extra-words-permitted-in-rule"
1010
],
1111
"reference_matches": [
1212
{
1313
"license_expression": "bsd-new",
1414
"license_expression_spdx": "BSD-3-Clause",
15-
"from_file": "scan-extra-words-3-seq-license/LICENSE",
16-
"start_line": 1,
17-
"end_line": 31,
15+
"from_file": "scan-extra-words-3-seq-license-with-copyright/LICENSE",
16+
"start_line": 7,
17+
"end_line": 32,
1818
"matcher": "3-seq",
19-
"score": 92.67,
20-
"matched_length": 215,
19+
"score": 100,
20+
"matched_length": 212,
2121
"match_coverage": 100.0,
2222
"rule_relevance": 100,
23-
"rule_identifier": "bsd-new_578.RULE",
24-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_578.RULE",
25-
"matched_text": "Software License Agreement (BSD License)\r\n\r\nCopyright (c) 2009-2015, Kevin Decker <[email protected]>\r\n\r\nAll rights reserved.\r\n\r\nRedistribution and use of this software in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n* Redistributions of source code must retain the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer.\r\n\r\n* Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer in the documentation and/or other\r\n materials provided with the distribution.\r\n\r\n* Neither the name of Kevin Decker nor the names of its\r\n contributors may be used to endorse or promote products\r\n derived from this software without specific prior\r\n written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR\r\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\r\nIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\r\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
26-
"matched_text_diagnostics": "Software License Agreement (BSD License)\r\n\r\n[Copyright] ([c]) [2009]-[2015], [Kevin] [Decker] <[kpdecker]@[gmail].[com]>\r\n\r\n[All] [rights] [reserved].\r\n\r\nRedistribution and use [of] [this] [software] in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n* Redistributions of source code must retain the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer.\r\n\r\n* Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer in the documentation and/or other\r\n materials provided with the distribution.\r\n\r\n* Neither the name of [Kevin] [Decker] nor the names of its\r\n contributors may be used to endorse or promote products\r\n derived from this software without specific prior\r\n written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR\r\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\r\nIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\r\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
23+
"rule_identifier": "bsd-new_newlib3.RULE",
24+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_newlib3.RULE",
25+
"matched_text": "Redistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions are\r\nmet:\r\n\r\n * Redistributions of source code must retain the above copyright\r\n notice, this list of conditions and the following disclaimer.\r\n * Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the following\r\n disclaimer in the documentation and/or other materials provided\r\n with the distribution.\r\n * Neither the name of the Hiroshima University nor the names of\r\n its contributors may be used to endorse or promote products\r\n derived from this software without specific prior written\r\n permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
26+
"matched_text_diagnostics": "Redistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions are\r\nmet:\r\n\r\n * Redistributions of source code must retain the above copyright\r\n notice, this list of conditions and the following disclaimer.\r\n * Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the following\r\n disclaimer in the documentation and/or other materials provided\r\n with the distribution.\r\n * Neither the name of the [Hiroshima] University nor the names of\r\n its contributors may be used to endorse or promote products\r\n derived from this software without specific prior written\r\n permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
2727
}
2828
]
2929
}
@@ -42,28 +42,28 @@
4242
{
4343
"license_expression": "bsd-new",
4444
"license_expression_spdx": "BSD-3-Clause",
45-
"from_file": "scan-extra-words-3-seq-license/LICENSE",
46-
"start_line": 1,
47-
"end_line": 31,
45+
"from_file": "scan-extra-words-3-seq-license-with-copyright/LICENSE",
46+
"start_line": 7,
47+
"end_line": 32,
4848
"matcher": "3-seq",
49-
"score": 92.67,
50-
"matched_length": 215,
49+
"score": 100,
50+
"matched_length": 212,
5151
"match_coverage": 100.0,
5252
"rule_relevance": 100,
53-
"rule_identifier": "bsd-new_578.RULE",
54-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_578.RULE",
55-
"matched_text": "Software License Agreement (BSD License)\r\n\r\nCopyright (c) 2009-2015, Kevin Decker <[email protected]>\r\n\r\nAll rights reserved.\r\n\r\nRedistribution and use of this software in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n* Redistributions of source code must retain the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer.\r\n\r\n* Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer in the documentation and/or other\r\n materials provided with the distribution.\r\n\r\n* Neither the name of Kevin Decker nor the names of its\r\n contributors may be used to endorse or promote products\r\n derived from this software without specific prior\r\n written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR\r\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\r\nIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\r\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
56-
"matched_text_diagnostics": "Software License Agreement (BSD License)\r\n\r\n[Copyright] ([c]) [2009]-[2015], [Kevin] [Decker] <[kpdecker]@[gmail].[com]>\r\n\r\n[All] [rights] [reserved].\r\n\r\nRedistribution and use [of] [this] [software] in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n* Redistributions of source code must retain the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer.\r\n\r\n* Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the\r\n following disclaimer in the documentation and/or other\r\n materials provided with the distribution.\r\n\r\n* Neither the name of [Kevin] [Decker] nor the names of its\r\n contributors may be used to endorse or promote products\r\n derived from this software without specific prior\r\n written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR\r\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\r\nIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\r\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
53+
"rule_identifier": "bsd-new_newlib3.RULE",
54+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_newlib3.RULE",
55+
"matched_text": "Redistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions are\r\nmet:\r\n\r\n * Redistributions of source code must retain the above copyright\r\n notice, this list of conditions and the following disclaimer.\r\n * Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the following\r\n disclaimer in the documentation and/or other materials provided\r\n with the distribution.\r\n * Neither the name of the Hiroshima University nor the names of\r\n its contributors may be used to endorse or promote products\r\n derived from this software without specific prior written\r\n permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
56+
"matched_text_diagnostics": "Redistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions are\r\nmet:\r\n\r\n * Redistributions of source code must retain the above copyright\r\n notice, this list of conditions and the following disclaimer.\r\n * Redistributions in binary form must reproduce the above\r\n copyright notice, this list of conditions and the following\r\n disclaimer in the documentation and/or other materials provided\r\n with the distribution.\r\n * Neither the name of the [Hiroshima] University nor the names of\r\n its contributors may be used to endorse or promote products\r\n derived from this software without specific prior written\r\n permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
5757
}
5858
],
5959
"detection_log": [
60-
"extra-words"
60+
"extra-words-permitted-in-rule"
6161
],
62-
"identifier": "bsd_new-f757f201-d182-a694-093b-6c34d20e9f8e"
62+
"identifier": "bsd_new-4b08a4bf-cc63-bee9-d78c-bec80b3f58f4"
6363
}
6464
],
6565
"license_clues": [],
66-
"percentage_of_license_text": 92.67,
66+
"percentage_of_license_text": 87.24,
6767
"scan_errors": []
6868
}
6969
]

0 commit comments

Comments
 (0)