From 35f79c37aad8f5336da085a9a9c0f98b70892203 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 27 Jan 2022 15:18:52 -0800 Subject: [PATCH] Run gofmt on compliance Test: builds Change-Id: I404b138faac0db9a92201be6163b19d9e6bff810 --- tools/compliance/cmd/bom_test.go | 138 +++++++------- tools/compliance/cmd/checkshare.go | 5 +- tools/compliance/cmd/dumpgraph.go | 2 +- tools/compliance/cmd/dumpresolutions.go | 2 +- tools/compliance/cmd/dumpresolutions_test.go | 32 ++-- tools/compliance/cmd/listshare.go | 2 +- tools/compliance/cmd/shippedlibs.go | 8 +- tools/compliance/cmd/shippedlibs_test.go | 150 +++++++-------- tools/compliance/condition.go | 18 +- tools/compliance/conditionset_test.go | 180 +++++++++--------- tools/compliance/graph.go | 6 +- tools/compliance/policy/policy.go | 39 ++-- .../policy/shareprivacyconflicts_test.go | 2 +- tools/compliance/policy/shipped_test.go | 32 ++-- tools/compliance/policy/walk.go | 2 +- tools/compliance/readgraph.go | 2 +- tools/compliance/resolution.go | 2 +- tools/compliance/resolutionset.go | 2 - tools/compliance/test_util.go | 61 +++--- 19 files changed, 339 insertions(+), 346 deletions(-) diff --git a/tools/compliance/cmd/bom_test.go b/tools/compliance/cmd/bom_test.go index b0d61e1bf9..9c126710ac 100644 --- a/tools/compliance/cmd/bom_test.go +++ b/tools/compliance/cmd/bom_test.go @@ -31,9 +31,9 @@ func Test(t *testing.T) { expectedOut []string }{ { - condition: "firstparty", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "firstparty", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, stripPrefix: "out/target/product/fictional", expectedOut: []string{ "/system/apex/highest.apex", @@ -44,9 +44,9 @@ func Test(t *testing.T) { }, }, { - condition: "firstparty", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "firstparty", + name: "container", + roots: []string{"container.zip.meta_lic"}, stripPrefix: "out/target/product/fictional/data/", expectedOut: []string{ "container.zip", @@ -57,23 +57,23 @@ func Test(t *testing.T) { }, }, { - condition: "firstparty", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "firstparty", + name: "application", + roots: []string{"application.meta_lic"}, stripPrefix: "out/target/product/fictional/bin/", expectedOut: []string{"application"}, }, { - condition: "firstparty", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "firstparty", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"bin/bin1"}, }, { - condition: "firstparty", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "firstparty", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"lib/libd.so"}, }, @@ -102,27 +102,27 @@ func Test(t *testing.T) { }, }, { - condition: "notice", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "notice", + name: "application", + roots: []string{"application.meta_lic"}, expectedOut: []string{"out/target/product/fictional/bin/application"}, }, { - condition: "notice", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "notice", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, expectedOut: []string{"out/target/product/fictional/system/bin/bin1"}, }, { - condition: "notice", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "notice", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, expectedOut: []string{"out/target/product/fictional/system/lib/libd.so"}, }, { - condition: "reciprocal", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "reciprocal", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, stripPrefix: "out/target/product/fictional/system/apex/", expectedOut: []string{ "highest.apex", @@ -133,9 +133,9 @@ func Test(t *testing.T) { }, }, { - condition: "reciprocal", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "reciprocal", + name: "container", + roots: []string{"container.zip.meta_lic"}, stripPrefix: "out/target/product/fictional/data/", expectedOut: []string{ "container.zip", @@ -146,30 +146,30 @@ func Test(t *testing.T) { }, }, { - condition: "reciprocal", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "reciprocal", + name: "application", + roots: []string{"application.meta_lic"}, stripPrefix: "out/target/product/fictional/bin/", expectedOut: []string{"application"}, }, { - condition: "reciprocal", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "reciprocal", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"bin/bin1"}, }, { - condition: "reciprocal", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "reciprocal", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"lib/libd.so"}, }, { - condition: "restricted", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "restricted", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, stripPrefix: "out/target/product/fictional/system/apex/", expectedOut: []string{ "highest.apex", @@ -180,9 +180,9 @@ func Test(t *testing.T) { }, }, { - condition: "restricted", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "restricted", + name: "container", + roots: []string{"container.zip.meta_lic"}, stripPrefix: "out/target/product/fictional/data/", expectedOut: []string{ "container.zip", @@ -193,30 +193,30 @@ func Test(t *testing.T) { }, }, { - condition: "restricted", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "restricted", + name: "application", + roots: []string{"application.meta_lic"}, stripPrefix: "out/target/product/fictional/bin/", expectedOut: []string{"application"}, }, { - condition: "restricted", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "restricted", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"bin/bin1"}, }, { - condition: "restricted", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "restricted", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"lib/libd.so"}, }, { - condition: "proprietary", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "proprietary", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, stripPrefix: "out/target/product/fictional/system/apex/", expectedOut: []string{ "highest.apex", @@ -227,9 +227,9 @@ func Test(t *testing.T) { }, }, { - condition: "proprietary", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "proprietary", + name: "container", + roots: []string{"container.zip.meta_lic"}, stripPrefix: "out/target/product/fictional/data/", expectedOut: []string{ "container.zip", @@ -240,23 +240,23 @@ func Test(t *testing.T) { }, }, { - condition: "proprietary", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "proprietary", + name: "application", + roots: []string{"application.meta_lic"}, stripPrefix: "out/target/product/fictional/bin/", expectedOut: []string{"application"}, }, { - condition: "proprietary", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "proprietary", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"bin/bin1"}, }, { - condition: "proprietary", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "proprietary", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, stripPrefix: "out/target/product/fictional/system/", expectedOut: []string{"lib/libd.so"}, }, diff --git a/tools/compliance/cmd/checkshare.go b/tools/compliance/cmd/checkshare.go index 5114a28d6b..e2735c3ba8 100644 --- a/tools/compliance/cmd/checkshare.go +++ b/tools/compliance/cmd/checkshare.go @@ -46,12 +46,11 @@ outputs "FAIL" to stdout and exits with status 1. } var ( - failConflicts = fmt.Errorf("conflicts") + failConflicts = fmt.Errorf("conflicts") failNoneRequested = fmt.Errorf("\nNo metadata files requested") - failNoLicenses = fmt.Errorf("No licenses") + failNoLicenses = fmt.Errorf("No licenses") ) - // byError orders conflicts by error string type byError []compliance.SourceSharePrivacyConflict diff --git a/tools/compliance/cmd/dumpgraph.go b/tools/compliance/cmd/dumpgraph.go index 1ee63b238c..76fdff3f0c 100644 --- a/tools/compliance/cmd/dumpgraph.go +++ b/tools/compliance/cmd/dumpgraph.go @@ -31,7 +31,7 @@ var ( stripPrefix = flag.String("strip_prefix", "", "Prefix to remove from paths. i.e. path to root") failNoneRequested = fmt.Errorf("\nNo license metadata files requested") - failNoLicenses = fmt.Errorf("No licenses found") + failNoLicenses = fmt.Errorf("No licenses found") ) type context struct { diff --git a/tools/compliance/cmd/dumpresolutions.go b/tools/compliance/cmd/dumpresolutions.go index 318cd918e6..fc8c47c534 100644 --- a/tools/compliance/cmd/dumpresolutions.go +++ b/tools/compliance/cmd/dumpresolutions.go @@ -32,7 +32,7 @@ var ( stripPrefix = flag.String("strip_prefix", "", "Prefix to remove from paths. i.e. path to root") failNoneRequested = fmt.Errorf("\nNo license metadata files requested") - failNoLicenses = fmt.Errorf("No licenses found") + failNoLicenses = fmt.Errorf("No licenses found") ) type context struct { diff --git a/tools/compliance/cmd/dumpresolutions_test.go b/tools/compliance/cmd/dumpresolutions_test.go index d9046717b2..a3a298e988 100644 --- a/tools/compliance/cmd/dumpresolutions_test.go +++ b/tools/compliance/cmd/dumpresolutions_test.go @@ -97,7 +97,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesShared.AsList(), + conditions: compliance.ImpliesShared.AsList(), stripPrefix: "testdata/firstparty/", }, expectedOut: []string{}, @@ -107,7 +107,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesPrivate.AsList(), + conditions: compliance.ImpliesPrivate.AsList(), stripPrefix: "testdata/firstparty/", }, expectedOut: []string{}, @@ -117,7 +117,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: append(compliance.ImpliesPrivate.AsList(),compliance.ImpliesShared.AsList()...), + conditions: append(compliance.ImpliesPrivate.AsList(), compliance.ImpliesShared.AsList()...), stripPrefix: "testdata/firstparty/", }, expectedOut: []string{}, @@ -255,7 +255,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesShared.AsList(), + conditions: compliance.ImpliesShared.AsList(), stripPrefix: "testdata/notice/", }, expectedOut: []string{}, @@ -265,7 +265,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesPrivate.AsList(), + conditions: compliance.ImpliesPrivate.AsList(), stripPrefix: "testdata/notice/", }, expectedOut: []string{}, @@ -275,7 +275,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), + conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...), stripPrefix: "testdata/notice/", }, expectedOut: []string{}, @@ -408,7 +408,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesShared.AsList(), + conditions: compliance.ImpliesShared.AsList(), stripPrefix: "testdata/reciprocal/", }, expectedOut: []string{ @@ -424,7 +424,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesPrivate.AsList(), + conditions: compliance.ImpliesPrivate.AsList(), stripPrefix: "testdata/reciprocal/", }, expectedOut: []string{}, @@ -434,7 +434,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), + conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...), stripPrefix: "testdata/reciprocal/", }, expectedOut: []string{ @@ -573,7 +573,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesShared.AsList(), + conditions: compliance.ImpliesShared.AsList(), stripPrefix: "testdata/restricted/", }, expectedOut: []string{ @@ -597,7 +597,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesPrivate.AsList(), + conditions: compliance.ImpliesPrivate.AsList(), stripPrefix: "testdata/restricted/", }, expectedOut: []string{}, @@ -607,7 +607,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), + conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...), stripPrefix: "testdata/restricted/", }, expectedOut: []string{ @@ -754,7 +754,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesShared.AsList(), + conditions: compliance.ImpliesShared.AsList(), stripPrefix: "testdata/proprietary/", }, expectedOut: []string{ @@ -771,7 +771,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: compliance.ImpliesPrivate.AsList(), + conditions: compliance.ImpliesPrivate.AsList(), stripPrefix: "testdata/proprietary/", }, expectedOut: []string{ @@ -789,7 +789,7 @@ func Test_plaintext(t *testing.T) { name: "apex_trimmed_share_private", roots: []string{"highest.apex.meta_lic"}, ctx: context{ - conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), + conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...), stripPrefix: "testdata/proprietary/", }, expectedOut: []string{ @@ -930,7 +930,7 @@ type targetMatcher struct { } // newTestCondition constructs a test license condition in the license graph. -func newTestCondition(lg *compliance.LicenseGraph, conditionName... string) compliance.LicenseConditionSet { +func newTestCondition(lg *compliance.LicenseGraph, conditionName ...string) compliance.LicenseConditionSet { cs := compliance.NewLicenseConditionSet() for _, name := range conditionName { cs = cs.Plus(compliance.RecognizedConditionNames[name]) diff --git a/tools/compliance/cmd/listshare.go b/tools/compliance/cmd/listshare.go index 5c58dc4052..ae9382ef6d 100644 --- a/tools/compliance/cmd/listshare.go +++ b/tools/compliance/cmd/listshare.go @@ -41,7 +41,7 @@ restricted (e.g. GPL) or reciprocal (e.g. MPL). var ( failNoneRequested = fmt.Errorf("\nNo license metadata files requested") - failNoLicenses = fmt.Errorf("No licenses found") + failNoLicenses = fmt.Errorf("No licenses found") ) func main() { diff --git a/tools/compliance/cmd/shippedlibs.go b/tools/compliance/cmd/shippedlibs.go index f25d7295b1..290ced65c2 100644 --- a/tools/compliance/cmd/shippedlibs.go +++ b/tools/compliance/cmd/shippedlibs.go @@ -26,16 +26,16 @@ import ( ) var ( - outputFile = flag.String("o", "-", "Where to write the library list. (default stdout)") + outputFile = flag.String("o", "-", "Where to write the library list. (default stdout)") failNoneRequested = fmt.Errorf("\nNo license metadata files requested") failNoLicenses = fmt.Errorf("No licenses found") ) type context struct { - stdout io.Writer - stderr io.Writer - rootFS fs.FS + stdout io.Writer + stderr io.Writer + rootFS fs.FS } func init() { diff --git a/tools/compliance/cmd/shippedlibs_test.go b/tools/compliance/cmd/shippedlibs_test.go index 69ec8176f2..4b2e4ee18f 100644 --- a/tools/compliance/cmd/shippedlibs_test.go +++ b/tools/compliance/cmd/shippedlibs_test.go @@ -30,153 +30,153 @@ func Test(t *testing.T) { expectedOut []string }{ { - condition: "firstparty", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "firstparty", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, expectedOut: []string{"Android"}, }, { - condition: "firstparty", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "firstparty", + name: "container", + roots: []string{"container.zip.meta_lic"}, expectedOut: []string{"Android"}, }, { - condition: "firstparty", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "firstparty", + name: "application", + roots: []string{"application.meta_lic"}, expectedOut: []string{"Android"}, }, { - condition: "firstparty", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "firstparty", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, expectedOut: []string{"Android"}, }, { - condition: "firstparty", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "firstparty", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, expectedOut: []string{"Android"}, }, { - condition: "notice", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "notice", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "notice", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "notice", + name: "container", + roots: []string{"container.zip.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "notice", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "notice", + name: "application", + roots: []string{"application.meta_lic"}, expectedOut: []string{"Android", "Device"}, }, { - condition: "notice", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "notice", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "notice", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "notice", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, expectedOut: []string{"External"}, }, { - condition: "reciprocal", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "reciprocal", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "reciprocal", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "reciprocal", + name: "container", + roots: []string{"container.zip.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "reciprocal", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "reciprocal", + name: "application", + roots: []string{"application.meta_lic"}, expectedOut: []string{"Android", "Device"}, }, { - condition: "reciprocal", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "reciprocal", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "reciprocal", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "reciprocal", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, expectedOut: []string{"External"}, }, { - condition: "restricted", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "restricted", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "restricted", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "restricted", + name: "container", + roots: []string{"container.zip.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "restricted", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "restricted", + name: "application", + roots: []string{"application.meta_lic"}, expectedOut: []string{"Android", "Device"}, }, { - condition: "restricted", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "restricted", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "restricted", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "restricted", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, expectedOut: []string{"External"}, }, { - condition: "proprietary", - name: "apex", - roots: []string{"highest.apex.meta_lic"}, + condition: "proprietary", + name: "apex", + roots: []string{"highest.apex.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "proprietary", - name: "container", - roots: []string{"container.zip.meta_lic"}, + condition: "proprietary", + name: "container", + roots: []string{"container.zip.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "proprietary", - name: "application", - roots: []string{"application.meta_lic"}, + condition: "proprietary", + name: "application", + roots: []string{"application.meta_lic"}, expectedOut: []string{"Android", "Device"}, }, { - condition: "proprietary", - name: "binary", - roots: []string{"bin/bin1.meta_lic"}, + condition: "proprietary", + name: "binary", + roots: []string{"bin/bin1.meta_lic"}, expectedOut: []string{"Android", "Device", "External"}, }, { - condition: "proprietary", - name: "library", - roots: []string{"lib/libd.so.meta_lic"}, + condition: "proprietary", + name: "library", + roots: []string{"lib/libd.so.meta_lic"}, expectedOut: []string{"External"}, }, } diff --git a/tools/compliance/condition.go b/tools/compliance/condition.go index 26b91cab2e..cfe6f8247e 100644 --- a/tools/compliance/condition.go +++ b/tools/compliance/condition.go @@ -61,16 +61,16 @@ const ( var ( // RecognizedConditionNames maps condition strings to LicenseCondition. RecognizedConditionNames = map[string]LicenseCondition{ - "unencumbered": UnencumberedCondition, - "permissive": PermissiveCondition, - "notice": NoticeCondition, - "reciprocal": ReciprocalCondition, - "restricted": RestrictedCondition, + "unencumbered": UnencumberedCondition, + "permissive": PermissiveCondition, + "notice": NoticeCondition, + "reciprocal": ReciprocalCondition, + "restricted": RestrictedCondition, "restricted_with_classpath_exception": RestrictedClasspathExceptionCondition, - "restricted_allows_dynamic_linking": WeaklyRestrictedCondition, - "proprietary": ProprietaryCondition, - "by_exception_only": ByExceptionOnlyCondition, - "not_allowed": NotAllowedCondition, + "restricted_allows_dynamic_linking": WeaklyRestrictedCondition, + "proprietary": ProprietaryCondition, + "by_exception_only": ByExceptionOnlyCondition, + "not_allowed": NotAllowedCondition, } ) diff --git a/tools/compliance/conditionset_test.go b/tools/compliance/conditionset_test.go index c7306e7c14..1d80676354 100644 --- a/tools/compliance/conditionset_test.go +++ b/tools/compliance/conditionset_test.go @@ -33,82 +33,82 @@ func TestConditionSet(t *testing.T) { conditions: []string{}, plus: &[]string{}, matchingAny: map[string][]string{ - "notice": []string{}, - "restricted": []string{}, + "notice": []string{}, + "restricted": []string{}, "restricted|reciprocal": []string{}, }, - expected: []string{}, + expected: []string{}, }, { name: "emptyminusnothing", conditions: []string{}, minus: &[]string{}, matchingAny: map[string][]string{ - "notice": []string{}, - "restricted": []string{}, + "notice": []string{}, + "restricted": []string{}, "restricted|reciprocal": []string{}, }, - expected: []string{}, + expected: []string{}, }, { name: "emptyminusnotice", conditions: []string{}, minus: &[]string{"notice"}, matchingAny: map[string][]string{ - "notice": []string{}, - "restricted": []string{}, + "notice": []string{}, + "restricted": []string{}, "restricted|reciprocal": []string{}, }, - expected: []string{}, + expected: []string{}, }, { - name: "noticeonly", + name: "noticeonly", conditions: []string{"notice"}, matchingAny: map[string][]string{ - "notice": []string{"notice"}, - "notice|proprietary": []string{"notice"}, - "restricted": []string{}, + "notice": []string{"notice"}, + "notice|proprietary": []string{"notice"}, + "restricted": []string{}, }, expected: []string{"notice"}, }, { - name: "allnoticeonly", + name: "allnoticeonly", conditions: []string{"notice"}, - plus: &[]string{"notice"}, + plus: &[]string{"notice"}, matchingAny: map[string][]string{ - "notice": []string{"notice"}, - "notice|proprietary": []string{"notice"}, - "restricted": []string{}, + "notice": []string{"notice"}, + "notice|proprietary": []string{"notice"}, + "restricted": []string{}, }, expected: []string{"notice"}, }, { - name: "emptyplusnotice", + name: "emptyplusnotice", conditions: []string{}, - plus: &[]string{"notice"}, + plus: &[]string{"notice"}, matchingAny: map[string][]string{ - "notice": []string{"notice"}, - "notice|proprietary": []string{"notice"}, - "restricted": []string{}, + "notice": []string{"notice"}, + "notice|proprietary": []string{"notice"}, + "restricted": []string{}, }, expected: []string{"notice"}, }, { - name: "everything", + name: "everything", conditions: []string{"unencumbered", "permissive", "notice", "reciprocal", "restricted", "proprietary"}, - plus: &[]string{"restricted_with_classpath_exception", "restricted_allows_dynamic_linking", "by_exception_only", "not_allowed"}, + plus: &[]string{"restricted_with_classpath_exception", "restricted_allows_dynamic_linking", "by_exception_only", "not_allowed"}, matchingAny: map[string][]string{ - "unencumbered": []string{"unencumbered"}, - "permissive": []string{"permissive"}, - "notice": []string{"notice"}, - "reciprocal": []string{"reciprocal"}, - "restricted": []string{"restricted"}, - "restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"}, - "restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"}, - "proprietary": []string{"proprietary"}, - "by_exception_only": []string{"by_exception_only"}, - "not_allowed": []string{"not_allowed"}, - "notice|proprietary": []string{"notice", "proprietary"}, + "unencumbered": []string{"unencumbered"}, + "permissive": []string{"permissive"}, + "notice": []string{"notice"}, + "reciprocal": []string{"reciprocal"}, + "restricted": []string{"restricted"}, + "restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"}, + "restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"}, + "proprietary": []string{"proprietary"}, + "by_exception_only": []string{"by_exception_only"}, + "not_allowed": []string{"not_allowed"}, + "notice|proprietary": []string{"notice", "proprietary"}, }, expected: []string{ "unencumbered", @@ -137,13 +137,13 @@ func TestConditionSet(t *testing.T) { "by_exception_only", "not_allowed", }, - plus: &[]string{}, + plus: &[]string{}, minus: &[]string{}, matchingAny: map[string][]string{ "unencumbered|permissive|notice": []string{"unencumbered", "permissive", "notice"}, - "restricted|reciprocal": []string{"reciprocal", "restricted"}, - "proprietary|by_exception_only": []string{"proprietary", "by_exception_only"}, - "not_allowed": []string{"not_allowed"}, + "restricted|reciprocal": []string{"reciprocal", "restricted"}, + "proprietary|by_exception_only": []string{"proprietary", "by_exception_only"}, + "not_allowed": []string{"not_allowed"}, }, expected: []string{ "unencumbered", @@ -159,21 +159,21 @@ func TestConditionSet(t *testing.T) { }, }, { - name: "allbutone", + name: "allbutone", conditions: []string{"unencumbered", "permissive", "notice", "reciprocal", "restricted", "proprietary"}, - plus: &[]string{"restricted_allows_dynamic_linking", "by_exception_only", "not_allowed"}, + plus: &[]string{"restricted_allows_dynamic_linking", "by_exception_only", "not_allowed"}, matchingAny: map[string][]string{ - "unencumbered": []string{"unencumbered"}, - "permissive": []string{"permissive"}, - "notice": []string{"notice"}, - "reciprocal": []string{"reciprocal"}, - "restricted": []string{"restricted"}, - "restricted_with_classpath_exception": []string{}, - "restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"}, - "proprietary": []string{"proprietary"}, - "by_exception_only": []string{"by_exception_only"}, - "not_allowed": []string{"not_allowed"}, - "notice|proprietary": []string{"notice", "proprietary"}, + "unencumbered": []string{"unencumbered"}, + "permissive": []string{"permissive"}, + "notice": []string{"notice"}, + "reciprocal": []string{"reciprocal"}, + "restricted": []string{"restricted"}, + "restricted_with_classpath_exception": []string{}, + "restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"}, + "proprietary": []string{"proprietary"}, + "by_exception_only": []string{"by_exception_only"}, + "not_allowed": []string{"not_allowed"}, + "notice|proprietary": []string{"notice", "proprietary"}, }, expected: []string{ "unencumbered", @@ -203,17 +203,17 @@ func TestConditionSet(t *testing.T) { }, minus: &[]string{"restricted_allows_dynamic_linking"}, matchingAny: map[string][]string{ - "unencumbered": []string{"unencumbered"}, - "permissive": []string{"permissive"}, - "notice": []string{"notice"}, - "reciprocal": []string{"reciprocal"}, - "restricted": []string{"restricted"}, - "restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"}, - "restricted_allows_dynamic_linking": []string{}, - "proprietary": []string{"proprietary"}, - "by_exception_only": []string{"by_exception_only"}, - "not_allowed": []string{"not_allowed"}, - "restricted|proprietary": []string{"restricted", "proprietary"}, + "unencumbered": []string{"unencumbered"}, + "permissive": []string{"permissive"}, + "notice": []string{"notice"}, + "reciprocal": []string{"reciprocal"}, + "restricted": []string{"restricted"}, + "restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"}, + "restricted_allows_dynamic_linking": []string{}, + "proprietary": []string{"proprietary"}, + "by_exception_only": []string{"by_exception_only"}, + "not_allowed": []string{"not_allowed"}, + "restricted|proprietary": []string{"restricted", "proprietary"}, }, expected: []string{ "unencumbered", @@ -254,35 +254,35 @@ func TestConditionSet(t *testing.T) { "not_allowed", }, matchingAny: map[string][]string{ - "unencumbered": []string{}, - "permissive": []string{}, - "notice": []string{}, - "reciprocal": []string{}, - "restricted": []string{}, - "restricted_with_classpath_exception": []string{}, - "restricted_allows_dynamic_linking": []string{}, - "proprietary": []string{}, - "by_exception_only": []string{}, - "not_allowed": []string{}, - "restricted|proprietary": []string{}, + "unencumbered": []string{}, + "permissive": []string{}, + "notice": []string{}, + "reciprocal": []string{}, + "restricted": []string{}, + "restricted_with_classpath_exception": []string{}, + "restricted_allows_dynamic_linking": []string{}, + "proprietary": []string{}, + "by_exception_only": []string{}, + "not_allowed": []string{}, + "restricted|proprietary": []string{}, }, expected: []string{}, }, { - name: "restrictedplus", + name: "restrictedplus", conditions: []string{"restricted", "restricted_with_classpath_exception", "restricted_allows_dynamic_linking"}, - plus: &[]string{"permissive", "notice", "restricted", "proprietary"}, + plus: &[]string{"permissive", "notice", "restricted", "proprietary"}, matchingAny: map[string][]string{ - "unencumbered": []string{}, - "permissive": []string{"permissive"}, - "notice": []string{"notice"}, - "restricted": []string{"restricted"}, - "restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"}, - "restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"}, - "proprietary": []string{"proprietary"}, - "restricted|proprietary": []string{"restricted", "proprietary"}, - "by_exception_only": []string{}, - "proprietary|by_exception_only": []string{"proprietary"}, + "unencumbered": []string{}, + "permissive": []string{"permissive"}, + "notice": []string{"notice"}, + "restricted": []string{"restricted"}, + "restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"}, + "restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"}, + "proprietary": []string{"proprietary"}, + "restricted|proprietary": []string{"restricted", "proprietary"}, + "by_exception_only": []string{}, + "proprietary|by_exception_only": []string{"proprietary"}, }, expected: []string{"permissive", "notice", "restricted", "restricted_with_classpath_exception", "restricted_allows_dynamic_linking", "proprietary"}, }, @@ -629,7 +629,7 @@ func TestConditionSet(t *testing.T) { if checkExpected(cs, t) { checkMatching(cs, t) } - if checkExpectedSet(cs, t){ + if checkExpectedSet(cs, t) { checkMatchingSet(cs, t) } }) @@ -639,7 +639,7 @@ func TestConditionSet(t *testing.T) { if checkExpected(cs, t) { checkMatching(cs, t) } - if checkExpectedSet(cs, t){ + if checkExpectedSet(cs, t) { checkMatchingSet(cs, t) } }) @@ -649,7 +649,7 @@ func TestConditionSet(t *testing.T) { if checkExpected(cs, t) { checkMatching(cs, t) } - if checkExpectedSet(cs, t){ + if checkExpectedSet(cs, t) { checkMatchingSet(cs, t) } }) diff --git a/tools/compliance/graph.go b/tools/compliance/graph.go index efcc6e4f7d..e73ab462e7 100644 --- a/tools/compliance/graph.go +++ b/tools/compliance/graph.go @@ -148,7 +148,7 @@ func (e *TargetEdge) String() string { type TargetEdgeList []*TargetEdge // Len returns the count of the elmements in the list. -func (l TargetEdgeList) Len() int { return len(l) } +func (l TargetEdgeList) Len() int { return len(l) } // Swap rearranges 2 elements so that each occupies the other's former position. func (l TargetEdgeList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } @@ -171,7 +171,7 @@ func (l TargetEdgeList) Less(i, j int) bool { // edge with a context `ctx` defined by whatever process is creating the path. type TargetEdgePathSegment struct { edge *TargetEdge - ctx interface{} + ctx interface{} } // Target identifies the target that depends on the dependency. @@ -495,7 +495,7 @@ func (ts *TargetNodeSet) String() string { type TargetNodeList []*TargetNode // Len returns the count of elements in the list. -func (l TargetNodeList) Len() int { return len(l) } +func (l TargetNodeList) Len() int { return len(l) } // Swap rearranges 2 elements so that each occupies the other's former position. func (l TargetNodeList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } diff --git a/tools/compliance/policy/policy.go b/tools/compliance/policy/policy.go index 4261ed011a..442025ea63 100644 --- a/tools/compliance/policy/policy.go +++ b/tools/compliance/policy/policy.go @@ -33,21 +33,21 @@ var ( // proprietary or confidential pathnames to whether to strip the prefix // from the path when used as the library name for notices. SafePathPrefixes = map[string]bool{ - "external/": true, - "art/": false, - "build/": false, - "cts/": false, - "dalvik/": false, - "developers/": false, + "external/": true, + "art/": false, + "build/": false, + "cts/": false, + "dalvik/": false, + "developers/": false, "development/": false, - "frameworks/": false, - "packages/": true, - "prebuilts/": false, - "sdk/": false, - "system/": false, - "test/": false, - "toolchain/": false, - "tools/": false, + "frameworks/": false, + "packages/": true, + "prebuilts/": false, + "sdk/": false, + "system/": false, + "test/": false, + "toolchain/": false, + "tools/": false, } // SafePrebuiltPrefixes maps the regular expression to match a prebuilt @@ -62,8 +62,8 @@ var ( // ImpliesNotice lists the condition names implying a notice or attribution policy. ImpliesNotice = LicenseConditionSet(UnencumberedCondition | PermissiveCondition | NoticeCondition | ReciprocalCondition | - RestrictedCondition | RestrictedClasspathExceptionCondition | WeaklyRestrictedCondition | - ProprietaryCondition | ByExceptionOnlyCondition) + RestrictedCondition | RestrictedClasspathExceptionCondition | WeaklyRestrictedCondition | + ProprietaryCondition | ByExceptionOnlyCondition) // ImpliesReciprocal lists the condition names implying a local source-sharing policy. ImpliesReciprocal = LicenseConditionSet(ReciprocalCondition) @@ -143,7 +143,6 @@ func LicenseConditionSetFromNames(tn *TargetNode, names ...string) LicenseCondit return cs } - // Resolution happens in three phases: // // 1. A bottom-up traversal propagates (restricted) license conditions up to @@ -182,7 +181,6 @@ func LicenseConditionSetFromNames(tn *TargetNode, names ...string) LicenseCondit // Not all restricted licenses are create equal. Some have special rules or // exceptions. e.g. LGPL or "with classpath excption". - // depConditionsPropagatingToTarget returns the conditions which propagate up an // edge from dependency to target. // @@ -204,7 +202,7 @@ func depConditionsPropagatingToTarget(lg *LicenseGraph, e *TargetEdge, depCondit } result |= depConditions & LicenseConditionSet(RestrictedCondition) - if 0 != (depConditions & LicenseConditionSet(RestrictedClasspathExceptionCondition)) && !edgeNodesAreIndependentModules(e) { + if 0 != (depConditions&LicenseConditionSet(RestrictedClasspathExceptionCondition)) && !edgeNodesAreIndependentModules(e) { result |= LicenseConditionSet(RestrictedClasspathExceptionCondition) } return result @@ -264,13 +262,12 @@ func conditionsAttachingAcrossEdge(lg *LicenseGraph, e *TargetEdge, universe Lic } result &= LicenseConditionSet(RestrictedCondition | RestrictedClasspathExceptionCondition) - if 0 != (result & LicenseConditionSet(RestrictedClasspathExceptionCondition)) && edgeNodesAreIndependentModules(e) { + if 0 != (result&LicenseConditionSet(RestrictedClasspathExceptionCondition)) && edgeNodesAreIndependentModules(e) { result &= LicenseConditionSet(RestrictedCondition) } return result } - // edgeIsDynamicLink returns true for edges representing shared libraries // linked dynamically at runtime. func edgeIsDynamicLink(e *TargetEdge) bool { diff --git a/tools/compliance/policy/shareprivacyconflicts_test.go b/tools/compliance/policy/shareprivacyconflicts_test.go index ad3f3f45ce..2d2a1d0258 100644 --- a/tools/compliance/policy/shareprivacyconflicts_test.go +++ b/tools/compliance/policy/shareprivacyconflicts_test.go @@ -24,7 +24,7 @@ import ( type byConflict []SourceSharePrivacyConflict // Len returns the count of elements in the slice. -func (l byConflict) Len() int { return len(l) } +func (l byConflict) Len() int { return len(l) } // Swap rearranged 2 elements so that each occupies the other's former // position. diff --git a/tools/compliance/policy/shipped_test.go b/tools/compliance/policy/shipped_test.go index 718e56fe82..25f6af0ca3 100644 --- a/tools/compliance/policy/shipped_test.go +++ b/tools/compliance/policy/shipped_test.go @@ -29,30 +29,30 @@ func TestShippedNodes(t *testing.T) { expectedNodes []string }{ { - name: "singleton", - roots: []string{"apacheLib.meta_lic"}, - edges: []annotated{}, + name: "singleton", + roots: []string{"apacheLib.meta_lic"}, + edges: []annotated{}, expectedNodes: []string{"apacheLib.meta_lic"}, }, { - name: "simplebinary", - roots: []string{"apacheBin.meta_lic"}, + name: "simplebinary", + roots: []string{"apacheBin.meta_lic"}, edges: []annotated{ {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, }, expectedNodes: []string{"apacheBin.meta_lic", "apacheLib.meta_lic"}, }, { - name: "simpledynamic", - roots: []string{"apacheBin.meta_lic"}, + name: "simpledynamic", + roots: []string{"apacheBin.meta_lic"}, edges: []annotated{ {"apacheBin.meta_lic", "lgplLib.meta_lic", []string{"dynamic"}}, }, expectedNodes: []string{"apacheBin.meta_lic"}, }, { - name: "container", - roots: []string{"apacheContainer.meta_lic"}, + name: "container", + roots: []string{"apacheContainer.meta_lic"}, edges: []annotated{ {"apacheContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, {"apacheContainer.meta_lic", "gplLib.meta_lic", []string{"static"}}, @@ -64,8 +64,8 @@ func TestShippedNodes(t *testing.T) { }, }, { - name: "binary", - roots: []string{"apacheBin.meta_lic"}, + name: "binary", + roots: []string{"apacheBin.meta_lic"}, edges: []annotated{ {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, {"apacheBin.meta_lic", "gplLib.meta_lic", []string{"static"}}, @@ -77,8 +77,8 @@ func TestShippedNodes(t *testing.T) { }, }, { - name: "binarydynamic", - roots: []string{"apacheBin.meta_lic"}, + name: "binarydynamic", + roots: []string{"apacheBin.meta_lic"}, edges: []annotated{ {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, {"apacheBin.meta_lic", "gplLib.meta_lic", []string{"dynamic"}}, @@ -89,8 +89,8 @@ func TestShippedNodes(t *testing.T) { }, }, { - name: "containerdeep", - roots: []string{"apacheContainer.meta_lic"}, + name: "containerdeep", + roots: []string{"apacheContainer.meta_lic"}, edges: []annotated{ {"apacheContainer.meta_lic", "apacheBin.meta_lic", []string{"static"}}, {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, @@ -127,7 +127,7 @@ func TestShippedNodes(t *testing.T) { t.Logf("sorted nodes: [%s]", strings.Join(actualNodes, ", ")) t.Logf("expected nodes: [%s]", strings.Join(expectedNodes, ", ")) - if len(expectedNodes) != len(actualNodes) { + if len(expectedNodes) != len(actualNodes) { t.Errorf("unexpected number of shipped nodes: %d nodes, want %d nodes", len(actualNodes), len(expectedNodes)) return diff --git a/tools/compliance/policy/walk.go b/tools/compliance/policy/walk.go index 3e730889ed..f4d7bbaf3a 100644 --- a/tools/compliance/policy/walk.go +++ b/tools/compliance/policy/walk.go @@ -83,7 +83,7 @@ func WalkTopDown(ctx EdgeContextProvider, lg *LicenseGraph, visit VisitNode) { // specific set of conditions. type resolutionKey struct { target *TargetNode - cs LicenseConditionSet + cs LicenseConditionSet } // WalkResolutionsForCondition performs a top-down walk of the LicenseGraph diff --git a/tools/compliance/readgraph.go b/tools/compliance/readgraph.go index c809a96dd9..6f91e1c34b 100644 --- a/tools/compliance/readgraph.go +++ b/tools/compliance/readgraph.go @@ -185,7 +185,7 @@ type targetNode struct { // addDependencies converts the proto AnnotatedDependencies into `edges` func addDependencies(lg *LicenseGraph, tn *TargetNode) error { - tn.edges = make(TargetEdgeList, 0,len(tn.proto.Deps)) + tn.edges = make(TargetEdgeList, 0, len(tn.proto.Deps)) for _, ad := range tn.proto.Deps { dependency := ad.GetFile() if len(dependency) == 0 { diff --git a/tools/compliance/resolution.go b/tools/compliance/resolution.go index 6f15ca350e..acc61e2ebf 100644 --- a/tools/compliance/resolution.go +++ b/tools/compliance/resolution.go @@ -66,7 +66,7 @@ func (r Resolution) asString() string { type ResolutionList []Resolution // Len returns the count of elements in the list. -func (l ResolutionList) Len() int { return len(l) } +func (l ResolutionList) Len() int { return len(l) } // Swap rearranges 2 elements so that each occupies the other's former position. func (l ResolutionList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } diff --git a/tools/compliance/resolutionset.go b/tools/compliance/resolutionset.go index 893ef26971..ef898834a0 100644 --- a/tools/compliance/resolutionset.go +++ b/tools/compliance/resolutionset.go @@ -65,7 +65,6 @@ func (rs ResolutionSet) AttachesTo() TargetNodeList { return result } - // AttachesToTarget returns true if the set contains conditions that // are `attachedTo`. func (rs ResolutionSet) AttachesToTarget(target *TargetNode) bool { @@ -73,7 +72,6 @@ func (rs ResolutionSet) AttachesToTarget(target *TargetNode) bool { return isPresent } - // Resolutions returns the list of resolutions that `attachedTo` // target must resolve. Returns empty list if no conditions apply. func (rs ResolutionSet) Resolutions(attachesTo *TargetNode) ResolutionList { diff --git a/tools/compliance/test_util.go b/tools/compliance/test_util.go index 8f4088ab7f..26d7461b8b 100644 --- a/tools/compliance/test_util.go +++ b/tools/compliance/test_util.go @@ -33,56 +33,56 @@ license_conditions: "notice" // GPL starts a test metadata file for GPL 2.0 licensing. GPL = `` + -`package_name: "Free Software" + `package_name: "Free Software" license_kinds: "SPDX-license-identifier-GPL-2.0" license_conditions: "restricted" ` // Classpath starts a test metadata file for GPL 2.0 with classpath exception licensing. Classpath = `` + -`package_name: "Free Software" + `package_name: "Free Software" license_kinds: "SPDX-license-identifier-GPL-2.0-with-classpath-exception" license_conditions: "restricted" ` // DependentModule starts a test metadata file for a module in the same package as `Classpath`. DependentModule = `` + -`package_name: "Free Software" + `package_name: "Free Software" license_kinds: "SPDX-license-identifier-MIT" license_conditions: "notice" ` // LGPL starts a test metadata file for a module with LGPL 2.0 licensing. LGPL = `` + -`package_name: "Free Library" + `package_name: "Free Library" license_kinds: "SPDX-license-identifier-LGPL-2.0" license_conditions: "restricted" ` // MPL starts a test metadata file for a module with MPL 2.0 reciprical licensing. MPL = `` + -`package_name: "Reciprocal" + `package_name: "Reciprocal" license_kinds: "SPDX-license-identifier-MPL-2.0" license_conditions: "reciprocal" ` // MIT starts a test metadata file for a module with generic notice (MIT) licensing. MIT = `` + -`package_name: "Android" + `package_name: "Android" license_kinds: "SPDX-license-identifier-MIT" license_conditions: "notice" ` // Proprietary starts a test metadata file for a module with proprietary licensing. Proprietary = `` + -`package_name: "Android" + `package_name: "Android" license_kinds: "legacy_proprietary" license_conditions: "proprietary" ` // ByException starts a test metadata file for a module with by_exception_only licensing. ByException = `` + -`package_name: "Special" + `package_name: "Special" license_kinds: "legacy_by_exception_only" license_conditions: "by_exception_only" ` @@ -91,22 +91,22 @@ license_conditions: "by_exception_only" var ( // meta maps test file names to metadata file content without dependencies. meta = map[string]string{ - "apacheBin.meta_lic": AOSP, - "apacheLib.meta_lic": AOSP, - "apacheContainer.meta_lic": AOSP + "is_container: true\n", - "dependentModule.meta_lic": DependentModule, + "apacheBin.meta_lic": AOSP, + "apacheLib.meta_lic": AOSP, + "apacheContainer.meta_lic": AOSP + "is_container: true\n", + "dependentModule.meta_lic": DependentModule, "gplWithClasspathException.meta_lic": Classpath, - "gplBin.meta_lic": GPL, - "gplLib.meta_lic": GPL, - "gplContainer.meta_lic": GPL + "is_container: true\n", - "lgplBin.meta_lic": LGPL, - "lgplLib.meta_lic": LGPL, - "mitBin.meta_lic": MIT, - "mitLib.meta_lic": MIT, - "mplBin.meta_lic": MPL, - "mplLib.meta_lic": MPL, - "proprietary.meta_lic": Proprietary, - "by_exception.meta_lic": ByException, + "gplBin.meta_lic": GPL, + "gplLib.meta_lic": GPL, + "gplContainer.meta_lic": GPL + "is_container: true\n", + "lgplBin.meta_lic": LGPL, + "lgplLib.meta_lic": LGPL, + "mitBin.meta_lic": MIT, + "mitLib.meta_lic": MIT, + "mplBin.meta_lic": MPL, + "mplLib.meta_lic": MPL, + "proprietary.meta_lic": Proprietary, + "by_exception.meta_lic": ByException, } ) @@ -204,7 +204,7 @@ func (e edge) String() string { type byEdge []edge // Len returns the count of elements in the slice. -func (l byEdge) Len() int { return len(l) } +func (l byEdge) Len() int { return len(l) } // Swap rearranges 2 elements of the slice so that each occupies the other's // former position. @@ -219,7 +219,6 @@ func (l byEdge) Less(i, j int) bool { return l[i].target < l[j].target } - // annotated describes annotated test data edges to define test graphs. type annotated struct { target, dep string @@ -240,7 +239,7 @@ func (e annotated) IsEqualTo(other annotated) bool { if e.dep != other.dep { return false } - if len(e.annotations) != len(other.annotations) { + if len(e.annotations) != len(other.annotations) { return false } a1 := append([]string{}, e.annotations...) @@ -401,7 +400,7 @@ func (l actionList) String() string { } // Len returns the count of elements in the slice. -func (l actionList) Len() int { return len(l) } +func (l actionList) Len() int { return len(l) } // Swap rearranges 2 elements of the slice so that each occupies the other's // former position. @@ -467,10 +466,10 @@ func toConflictList(lg *LicenseGraph, data []confl) []SourceSharePrivacyConflict oprivacy := fields[0] cprivacy := fields[1] result = append(result, SourceSharePrivacyConflict{ - newTestNode(lg, c.sourceNode), - newTestCondition(lg, oshare, cshare), - newTestCondition(lg, oprivacy, cprivacy), - }) + newTestNode(lg, c.sourceNode), + newTestCondition(lg, oshare, cshare), + newTestCondition(lg, oprivacy, cprivacy), + }) } return result }