Debian Codegraph @

spdxexp/compare.go

raw symbols SCIP
1 package spdxexpscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/
2
3 // The compare methods determine if two ranges are greater than, less than or equal within the same license group.
4 // NOTE: Ranges are organized into groups (referred to as license groups) of the same base license (e.g. GPL).
5 // Groups have sub-groups of license versions (referred to as the range) where each member is considered
6 // to be the same version (e.g. {GPL-2.0, GPL-2.0-only}). The sub-groups are in ascending order within
7 // the license group, such that the first sub-group is considered to be less than the second sub-group,
8 // and so on. (e.g. {{GPL-1.0}, {GPL-2.0, GPL-2.0-only}} implies {GPL-1.0} < {GPL-2.0, GPL-2.0-only}).
9
10 // compareGT returns true if the first range is greater than the second range within the same license group; otherwise, false.
11 func compareGTscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/compareGT().(first *nodescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#, second *nodescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#) bool {
12 if !first.isLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#isLicense().() || !second.isLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#isLicense().() {
13 return false
14 }
15 firstRange := getLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/getLicenseRange().(*first.licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#license().())
16 secondRange := getLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/getLicenseRange().(*second.licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#license().())
17
18 if !sameLicenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/sameLicenseGroup().(firstRange, secondRange) {
19 return false
20 }
21 return firstRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.] > secondRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.]
22 }
23
24 // compareLT returns true if the first range is less than the second range within the same license group; otherwise, false.
25 func compareLTscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/compareLT().(first *nodescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#, second *nodescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#) bool {
26 if !first.isLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#isLicense().() || !second.isLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#isLicense().() {
27 return false
28 }
29 firstRange := getLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/getLicenseRange().(*first.licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#license().())
30 secondRange := getLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/getLicenseRange().(*second.licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#license().())
31
32 if !sameLicenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/sameLicenseGroup().(firstRange, secondRange) {
33 return false
34 }
35 return firstRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.] < secondRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.]
36 }
37
38 // compareEQ returns true if the first and second range are the same range within the same license group; otherwise, false.
39 func compareEQscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/compareEQ().(first *nodescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#, second *nodescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#) bool {
40 if !first.isLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#isLicense().() || !second.isLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#isLicense().() {
41 return false
42 }
43 if first.licscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#lic..licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseNodePartial#license. == second.licscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#lic..licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseNodePartial#license. {
44 return true
45 }
46
47 firstRange := getLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/getLicenseRange().(*first.licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#license().())
48 secondRange := getLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/getLicenseRange().(*second.licensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#license().())
49
50 if !sameLicenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/sameLicenseGroup().(firstRange, secondRange) {
51 return false
52 }
53 return firstRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.] == secondRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.]
54 }
55
56 // sameLicenseGroup returns false if either license isn't in a range or the two ranges are
57 // not in the same license group (e.g. group GPL != group Apache); otherwise, true
58 func sameLicenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/sameLicenseGroup().(firstRange *licenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#, secondRange *licenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#) bool {
59 if firstRange == nil || secondRange == nil || firstRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[licenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseGroup.] != secondRange.locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.[licenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseGroup.] {
60 return false
61 }
62 return true
63 }