Skip to content

Commit 9bf9fe6

Browse files
committed
feat(spdx-utils)!: Check for equals digits in simple license mappings
Tolerate differences in trailing zeros. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 5b9731a commit 9bf9fe6

File tree

2 files changed

+18
-39
lines changed

2 files changed

+18
-39
lines changed

utils/spdx/src/main/resources/simple-license-mapping.yml

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,8 @@
2222
# Sort the entries below via IntelliJ's "Edit" -> "Sort Lines".
2323
---
2424

25-
# Ambiguous mappings (mapping reason not obvious without additional information)
26-
ALv2: Apache-2.0
27-
ASL: Apache-2.0
28-
Apache-style: Apache-2.0
29-
Apache: Apache-2.0
30-
BSD-like: BSD-3-Clause
31-
BSD-style: BSD-3-Clause
32-
BSD: BSD-3-Clause
33-
GPL: GPL-2.0-or-later
34-
MPL: MPL-2.0
35-
afl: AFL-3.0
36-
agpl: AGPL-3.0-or-later
37-
apache-license: Apache-2.0
38-
bsd-license: BSD-3-Clause
39-
bsd-licensed: BSD-3-Clause
40-
cddl: CDDL-1.0
41-
efl: EFL-2.0
42-
epl: EPL-1.0
43-
eupl: EUPL-1.0
44-
fdl: GFDL-1.3-or-later
45-
gfdl: GFDL-1.3-or-later
46-
gpl-license: GPL-2.0-or-later
47-
psf: PSF-2.0
48-
psfl: PSF-2.0
49-
python: Python-2.0
50-
51-
# Non-ambiguous mappings
5225
AFLv2.1: AFL-2.1
26+
ALv2: Apache-2.0
5327
APACHEv2: Apache-2.0
5428
APL2: Apache-2.0
5529
APLv2.0: Apache-2.0
@@ -59,11 +33,7 @@ Apache2: Apache-2.0
5933
BSD-3: BSD-3-Clause
6034
BSD2: BSD-2-Clause
6135
BSD3: BSD-3-Clause
62-
Boost: BSL-1.0
6336
Bouncy: MIT
64-
CC0: CC0-1.0
65-
CPL: CPL-1.0
66-
CeCILL: CECILL-1.1
6737
EDL-1.0: BSD-3-Clause
6838
FreeBSD: BSD-2-Clause-Views
6939
GPL-2: GPL-2.0-only
@@ -74,31 +44,24 @@ GPLv3+: GPL-3.0-or-later
7444
GPLv3: GPL-3.0-only
7545
ISCL: ISC
7646
LGPL-3: LGPL-3.0-only
77-
LGPL2: LGPL-2.1-only
7847
LGPL3: LGPL-3.0-only
79-
LGPL: LGPL-2.0-or-later
80-
LGPLv2: LGPL-2.1-only
8148
LGPLv3+: LGPL-3.0-or-later
8249
LGPLv3: LGPL-3.0-only
8350
MIT-like: MIT
8451
MIT-style: MIT
8552
MPLv2.0: MPL-2.0
8653
MPLv2: MPL-2.0
87-
ODBL: ODbL-1.0
8854
PSF2: PSF-2.0
8955
UNLICENSED: Unlicense
9056
Unlicence: Unlicense
91-
Vovida: VSL-1.0
9257
afl-2: AFL-2.0
9358
afl2.0: AFL-2.0
9459
afl2.1: AFL-2.1
9560
afl2: AFL-2.0
9661
bouncy-license: MIT
9762
bsl1.0: BSL-1.0
98-
bsl: BSL-1.0
9963
cddl1.0: CDDL-1.0
10064
cddl1.1: CDDL-1.1
101-
cpal: CPAL-1.0
10265
epl1.0: EPL-1.0
10366
epl2.0: EPL-2.0
10467
eupl1.0: EUPL-1.0
@@ -113,4 +76,3 @@ mpl2.0: MPL-2.0
11376
mpl2: MPL-2.0
11477
w3cl: W3C
11578
wtf: WTFPL
116-
zope: ZPL-2.1

utils/spdx/src/test/kotlin/SpdxSimpleLicenseMappingTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ class SpdxSimpleLicenseMappingTest : WordSpec({
5757
if (license.id.endsWith("-only")) key should containADigit()
5858
}
5959
}
60+
61+
"contain equal digits omitting trailing zeros" {
62+
val exceptions = mapOf(
63+
// See https://www.eclipse.org/org/documents/edl-v10.php.
64+
"EDL-1.0" to SpdxLicense.BSD_3_CLAUSE,
65+
// See https://spdx.org/licenses/BSD-2-Clause-Views.html.
66+
"FreeBSD" to SpdxLicense.BSD_2_CLAUSE_VIEWS
67+
)
68+
69+
SpdxSimpleLicenseMapping.simpleLicenseMapping.filterNot {
70+
it in exceptions.entries
71+
}.forAll { (key, license) ->
72+
val digitsInKey = key.filter { it.isDigit() }.dropLastWhile { it == '0' }
73+
val digitsInLicense = license.id.filter { it.isDigit() }.dropLastWhile { it == '0' }
74+
digitsInKey shouldBe digitsInLicense
75+
}
76+
}
6077
}
6178

6279
"The simple expression mapping" should {

0 commit comments

Comments
 (0)