Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
  • Loading branch information
AyanSinhaMahapatra committed Aug 28, 2024
1 parent 6d93bba commit 02157f0
Show file tree
Hide file tree
Showing 23 changed files with 155 additions and 29 deletions.
10 changes: 10 additions & 0 deletions src/licensedcode/data/rules/cclrc_1.RULE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
license_expression: cclrc
is_license_notice: yes
referenced_filenames:
- External_License/CCLRC_CDAT_License.txt
---

* This software may be distributed under the terms of the
* {{CCLRC Licence}} for CCLRC Software
* <CDATDIR>/External_License/CCLRC_CDAT_License.txt
7 changes: 7 additions & 0 deletions src/licensedcode/data/rules/cclrc_2.RULE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
license_expression: cclrc
is_license_notice: yes
---

* This software may be distributed under the terms of the
* {{CCLRC Licence}} for CCLRC Software
1 change: 1 addition & 0 deletions src/licensedcode/data/rules/mit_1182.RULE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
license_expression: mit
is_license_reference: yes
is_required_phrase: yes
relevance: 100
---

Expand Down
2 changes: 1 addition & 1 deletion src/licensedcode/data/rules/mit_334.RULE
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ referenced_filenames:
- LICENSE
---

This software is released under the MIT software license.
This software is released under the {{MIT software license}}.
This license, including disclaimer, is available in the 'LICENSE' file.
2 changes: 1 addition & 1 deletion src/licensedcode/data/rules/mit_337.RULE
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ ignorable_urls:
- http://www.opensource.org/licenses/mit-license.php
---

This is the http://www.opensource.org/licenses/mit-license.php MIT Software License
This is the http://www.opensource.org/licenses/mit-license.php {{MIT Software License}}
which is OSI-certified, and GPL-compatible.
2 changes: 1 addition & 1 deletion src/licensedcode/data/rules/mit_392.RULE
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ ignorable_urls:
- http://www.opensource.org/licenses/mit-license.php
---

"Distributed under the MIT software license, see the accompanying file COPYING or
"Distributed under the {{MIT software license}}, see the accompanying file COPYING or
http://www.opensource.org/licenses/mit-license.php.
2 changes: 1 addition & 1 deletion src/licensedcode/data/rules/mit_396.RULE
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ referenced_filenames:
- COPYING
---

// Distributed under the MIT software license, see the accompanying
// Distributed under the {{MIT software license}}, see the accompanying
// file COPYING
6 changes: 3 additions & 3 deletions src/licensedcode/data/rules/mit_397.RULE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ relevance: 100
referenced_filenames:
- COPYING
ignorable_urls:
- http://www.opensource.org/licenses/mit-license.php
- https://www.opensource.org/licenses/mit-license.php
---

// Distributed under the MIT software license, see the accompanying
// file COPYING or shttp://www.opensource.org/{{licenses/mit}}-license.php.
// Distributed under the {{MIT software license}}, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
4 changes: 0 additions & 4 deletions src/licensedcode/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,6 @@ def validate(self, licensing=None, thorough=False):
is_false_positive = self.is_false_positive

has_license_flags = any(self.license_flag_values)
has_no_license_flags = len([l for l in self.license_flag_values if l]) == 0
has_many_license_flags = len([l for l in self.license_flag_values if l]) > 1

license_expression = self.license_expression
Expand Down Expand Up @@ -1888,9 +1887,6 @@ def validate(self, licensing=None, thorough=False):

if not (0 <= self.relevance <= 100):
yield 'Invalid rule relevance. Should be between 0 and 100.'

if has_no_license_flags:
yield 'Invalid rule no is_license_* flags present.'

if has_many_license_flags:
yield 'Invalid rule is_license_* flags. Only one allowed.'
Expand Down
7 changes: 1 addition & 6 deletions src/licensedcode/required_phrases.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ def get_required_phrase_spans(text):
>>> x = get_required_phrase_spans(text)
>>> assert x == [Span(4, 6)], x
>>> text = 'This is enclosed in {{double curly braces}}'
>>> # 0 1 2 3 4 5 6
>>> x = get_required_phrase_spans(text)
>>> assert x == ['double', 'curly', 'braces'], x
>>> text = 'This is {{enclosed}} a {{double curly braces}} or not'
>>> # 0 1 2 SW 3 4 5 6 7
>>> x = get_required_phrase_spans(text)
Expand Down Expand Up @@ -114,7 +109,7 @@ def get_required_phrase_texts(text):
>>> text = 'This is enclosed in {{double curly braces}}'
>>> # 0 1 2 3 4 5 6
>>> x = get_required_phrase_texts(text=text)
>>> assert x == ['double', 'curly', 'braces'], x
>>> assert x == ['double curly braces'], x
"""
return [
required_phrase.text
Expand Down
30 changes: 27 additions & 3 deletions tests/formattedcode/data/common/manifests-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ headers:
system_environment:
operating_system: linux
cpu_architecture: 64
platform: Linux-5.15.0-116-generic-x86_64-with-glibc2.35
platform_version: '#126-Ubuntu SMP Mon Jul 1 10:14:24 UTC 2024'
python_version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]
platform: Linux-5.15.0-119-generic-x86_64-with-glibc2.35
platform_version: '#129-Ubuntu SMP Fri Aug 2 19:25:20 UTC 2024'
python_version: 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
spdx_license_list_version: '3.24'
files_count: 4
summary:
Expand Down Expand Up @@ -1601,6 +1601,8 @@ license_rule_references:
is_license_tag: yes
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1626,6 +1628,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1651,6 +1655,8 @@ license_rule_references:
is_license_tag: yes
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1677,6 +1683,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1703,6 +1711,8 @@ license_rule_references:
is_license_tag: yes
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1728,6 +1738,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand Down Expand Up @@ -1765,6 +1777,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1790,6 +1804,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: yes
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand Down Expand Up @@ -1818,6 +1834,8 @@ license_rule_references:
is_license_tag: yes
is_license_intro: no
is_license_clue: no
is_required_phrase: yes
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1843,6 +1861,8 @@ license_rule_references:
is_license_tag: yes
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1868,6 +1888,8 @@ license_rule_references:
is_license_tag: yes
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -1893,6 +1915,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand Down
22 changes: 17 additions & 5 deletions tests/formattedcode/data/yaml/package-and-licenses-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ headers:
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.
output_format_version: 3.1.0
output_format_version: 3.2.0
message:
errors: []
warnings: []
extra_data:
system_environment:
operating_system: linux
cpu_architecture: 64
platform: Linux-5.15.0-112-generic-x86_64-with-glibc2.35
platform_version: '#122-Ubuntu SMP Thu May 23 07:48:21 UTC 2024'
python_version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
spdx_license_list_version: '3.23'
platform: Linux-5.15.0-119-generic-x86_64-with-glibc2.35
platform_version: '#129-Ubuntu SMP Fri Aug 2 19:25:20 UTC 2024'
python_version: 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
spdx_license_list_version: '3.24'
files_count: 4
summary:
declared_license_expression: apache-2.0
Expand Down Expand Up @@ -626,6 +626,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: yes
Expand Down Expand Up @@ -854,6 +856,8 @@ license_rule_references:
is_license_tag: yes
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -879,6 +883,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand All @@ -904,6 +910,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: yes
is_builtin: yes
is_from_license: no
Expand All @@ -929,6 +937,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: yes
Expand Down Expand Up @@ -972,6 +982,8 @@ license_rule_references:
is_license_tag: no
is_license_intro: no
is_license_clue: no
is_required_phrase: no
skip_collecting_required_phrases: no
is_continuous: no
is_builtin: yes
is_from_license: no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@
"is_license_tag": true,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": true,
"is_from_license": false,
Expand Down Expand Up @@ -297,6 +299,8 @@
"is_license_tag": false,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": false,
"is_from_license": true,
Expand Down Expand Up @@ -324,6 +328,8 @@
"is_license_tag": false,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": false,
"is_from_license": true,
Expand Down Expand Up @@ -351,6 +357,8 @@
"is_license_tag": false,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": false,
"is_from_license": true,
Expand Down Expand Up @@ -378,6 +386,8 @@
"is_license_tag": false,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": false,
"is_from_license": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
"is_license_tag": false,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": false,
"is_from_license": true,
Expand Down Expand Up @@ -144,6 +146,8 @@
"is_license_tag": false,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": false,
"is_from_license": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
"is_license_tag": false,
"is_license_intro": false,
"is_license_clue": false,
"is_required_phrase": false,
"skip_collecting_required_phrases": false,
"is_continuous": false,
"is_builtin": false,
"is_from_license": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
license_expressions:
- mit
- cclrc
Loading

0 comments on commit 02157f0

Please sign in to comment.