Run gofmt on compliance

Test: builds
Change-Id: I404b138faac0db9a92201be6163b19d9e6bff810
This commit is contained in:
Colin Cross
2022-01-27 15:18:52 -08:00
parent 2546febca7
commit 35f79c37aa
19 changed files with 339 additions and 346 deletions

View File

@@ -51,7 +51,6 @@ var (
failNoLicenses = fmt.Errorf("No licenses") failNoLicenses = fmt.Errorf("No licenses")
) )
// byError orders conflicts by error string // byError orders conflicts by error string
type byError []compliance.SourceSharePrivacyConflict type byError []compliance.SourceSharePrivacyConflict

View File

@@ -117,7 +117,7 @@ func Test_plaintext(t *testing.T) {
name: "apex_trimmed_share_private", name: "apex_trimmed_share_private",
roots: []string{"highest.apex.meta_lic"}, roots: []string{"highest.apex.meta_lic"},
ctx: context{ ctx: context{
conditions: append(compliance.ImpliesPrivate.AsList(),compliance.ImpliesShared.AsList()...), conditions: append(compliance.ImpliesPrivate.AsList(), compliance.ImpliesShared.AsList()...),
stripPrefix: "testdata/firstparty/", stripPrefix: "testdata/firstparty/",
}, },
expectedOut: []string{}, expectedOut: []string{},
@@ -275,7 +275,7 @@ func Test_plaintext(t *testing.T) {
name: "apex_trimmed_share_private", name: "apex_trimmed_share_private",
roots: []string{"highest.apex.meta_lic"}, roots: []string{"highest.apex.meta_lic"},
ctx: context{ ctx: context{
conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
stripPrefix: "testdata/notice/", stripPrefix: "testdata/notice/",
}, },
expectedOut: []string{}, expectedOut: []string{},
@@ -434,7 +434,7 @@ func Test_plaintext(t *testing.T) {
name: "apex_trimmed_share_private", name: "apex_trimmed_share_private",
roots: []string{"highest.apex.meta_lic"}, roots: []string{"highest.apex.meta_lic"},
ctx: context{ ctx: context{
conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
stripPrefix: "testdata/reciprocal/", stripPrefix: "testdata/reciprocal/",
}, },
expectedOut: []string{ expectedOut: []string{
@@ -607,7 +607,7 @@ func Test_plaintext(t *testing.T) {
name: "apex_trimmed_share_private", name: "apex_trimmed_share_private",
roots: []string{"highest.apex.meta_lic"}, roots: []string{"highest.apex.meta_lic"},
ctx: context{ ctx: context{
conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
stripPrefix: "testdata/restricted/", stripPrefix: "testdata/restricted/",
}, },
expectedOut: []string{ expectedOut: []string{
@@ -789,7 +789,7 @@ func Test_plaintext(t *testing.T) {
name: "apex_trimmed_share_private", name: "apex_trimmed_share_private",
roots: []string{"highest.apex.meta_lic"}, roots: []string{"highest.apex.meta_lic"},
ctx: context{ ctx: context{
conditions: append(compliance.ImpliesShared.AsList(),compliance.ImpliesPrivate.AsList()...), conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
stripPrefix: "testdata/proprietary/", stripPrefix: "testdata/proprietary/",
}, },
expectedOut: []string{ expectedOut: []string{
@@ -930,7 +930,7 @@ type targetMatcher struct {
} }
// newTestCondition constructs a test license condition in the license graph. // 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() cs := compliance.NewLicenseConditionSet()
for _, name := range conditionName { for _, name := range conditionName {
cs = cs.Plus(compliance.RecognizedConditionNames[name]) cs = cs.Plus(compliance.RecognizedConditionNames[name])

View File

@@ -629,7 +629,7 @@ func TestConditionSet(t *testing.T) {
if checkExpected(cs, t) { if checkExpected(cs, t) {
checkMatching(cs, t) checkMatching(cs, t)
} }
if checkExpectedSet(cs, t){ if checkExpectedSet(cs, t) {
checkMatchingSet(cs, t) checkMatchingSet(cs, t)
} }
}) })
@@ -639,7 +639,7 @@ func TestConditionSet(t *testing.T) {
if checkExpected(cs, t) { if checkExpected(cs, t) {
checkMatching(cs, t) checkMatching(cs, t)
} }
if checkExpectedSet(cs, t){ if checkExpectedSet(cs, t) {
checkMatchingSet(cs, t) checkMatchingSet(cs, t)
} }
}) })
@@ -649,7 +649,7 @@ func TestConditionSet(t *testing.T) {
if checkExpected(cs, t) { if checkExpected(cs, t) {
checkMatching(cs, t) checkMatching(cs, t)
} }
if checkExpectedSet(cs, t){ if checkExpectedSet(cs, t) {
checkMatchingSet(cs, t) checkMatchingSet(cs, t)
} }
}) })

View File

@@ -143,7 +143,6 @@ func LicenseConditionSetFromNames(tn *TargetNode, names ...string) LicenseCondit
return cs return cs
} }
// Resolution happens in three phases: // Resolution happens in three phases:
// //
// 1. A bottom-up traversal propagates (restricted) license conditions up to // 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 // Not all restricted licenses are create equal. Some have special rules or
// exceptions. e.g. LGPL or "with classpath excption". // exceptions. e.g. LGPL or "with classpath excption".
// depConditionsPropagatingToTarget returns the conditions which propagate up an // depConditionsPropagatingToTarget returns the conditions which propagate up an
// edge from dependency to target. // edge from dependency to target.
// //
@@ -204,7 +202,7 @@ func depConditionsPropagatingToTarget(lg *LicenseGraph, e *TargetEdge, depCondit
} }
result |= depConditions & LicenseConditionSet(RestrictedCondition) result |= depConditions & LicenseConditionSet(RestrictedCondition)
if 0 != (depConditions & LicenseConditionSet(RestrictedClasspathExceptionCondition)) && !edgeNodesAreIndependentModules(e) { if 0 != (depConditions&LicenseConditionSet(RestrictedClasspathExceptionCondition)) && !edgeNodesAreIndependentModules(e) {
result |= LicenseConditionSet(RestrictedClasspathExceptionCondition) result |= LicenseConditionSet(RestrictedClasspathExceptionCondition)
} }
return result return result
@@ -264,13 +262,12 @@ func conditionsAttachingAcrossEdge(lg *LicenseGraph, e *TargetEdge, universe Lic
} }
result &= LicenseConditionSet(RestrictedCondition | RestrictedClasspathExceptionCondition) result &= LicenseConditionSet(RestrictedCondition | RestrictedClasspathExceptionCondition)
if 0 != (result & LicenseConditionSet(RestrictedClasspathExceptionCondition)) && edgeNodesAreIndependentModules(e) { if 0 != (result&LicenseConditionSet(RestrictedClasspathExceptionCondition)) && edgeNodesAreIndependentModules(e) {
result &= LicenseConditionSet(RestrictedCondition) result &= LicenseConditionSet(RestrictedCondition)
} }
return result return result
} }
// edgeIsDynamicLink returns true for edges representing shared libraries // edgeIsDynamicLink returns true for edges representing shared libraries
// linked dynamically at runtime. // linked dynamically at runtime.
func edgeIsDynamicLink(e *TargetEdge) bool { func edgeIsDynamicLink(e *TargetEdge) bool {

View File

@@ -185,7 +185,7 @@ type targetNode struct {
// addDependencies converts the proto AnnotatedDependencies into `edges` // addDependencies converts the proto AnnotatedDependencies into `edges`
func addDependencies(lg *LicenseGraph, tn *TargetNode) error { 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 { for _, ad := range tn.proto.Deps {
dependency := ad.GetFile() dependency := ad.GetFile()
if len(dependency) == 0 { if len(dependency) == 0 {

View File

@@ -65,7 +65,6 @@ func (rs ResolutionSet) AttachesTo() TargetNodeList {
return result return result
} }
// AttachesToTarget returns true if the set contains conditions that // AttachesToTarget returns true if the set contains conditions that
// are `attachedTo`. // are `attachedTo`.
func (rs ResolutionSet) AttachesToTarget(target *TargetNode) bool { func (rs ResolutionSet) AttachesToTarget(target *TargetNode) bool {
@@ -73,7 +72,6 @@ func (rs ResolutionSet) AttachesToTarget(target *TargetNode) bool {
return isPresent return isPresent
} }
// Resolutions returns the list of resolutions that `attachedTo` // Resolutions returns the list of resolutions that `attachedTo`
// target must resolve. Returns empty list if no conditions apply. // target must resolve. Returns empty list if no conditions apply.
func (rs ResolutionSet) Resolutions(attachesTo *TargetNode) ResolutionList { func (rs ResolutionSet) Resolutions(attachesTo *TargetNode) ResolutionList {

View File

@@ -33,56 +33,56 @@ license_conditions: "notice"
// GPL starts a test metadata file for GPL 2.0 licensing. // GPL starts a test metadata file for GPL 2.0 licensing.
GPL = `` + GPL = `` +
`package_name: "Free Software" `package_name: "Free Software"
license_kinds: "SPDX-license-identifier-GPL-2.0" license_kinds: "SPDX-license-identifier-GPL-2.0"
license_conditions: "restricted" license_conditions: "restricted"
` `
// Classpath starts a test metadata file for GPL 2.0 with classpath exception licensing. // Classpath starts a test metadata file for GPL 2.0 with classpath exception licensing.
Classpath = `` + Classpath = `` +
`package_name: "Free Software" `package_name: "Free Software"
license_kinds: "SPDX-license-identifier-GPL-2.0-with-classpath-exception" license_kinds: "SPDX-license-identifier-GPL-2.0-with-classpath-exception"
license_conditions: "restricted" license_conditions: "restricted"
` `
// DependentModule starts a test metadata file for a module in the same package as `Classpath`. // DependentModule starts a test metadata file for a module in the same package as `Classpath`.
DependentModule = `` + DependentModule = `` +
`package_name: "Free Software" `package_name: "Free Software"
license_kinds: "SPDX-license-identifier-MIT" license_kinds: "SPDX-license-identifier-MIT"
license_conditions: "notice" license_conditions: "notice"
` `
// LGPL starts a test metadata file for a module with LGPL 2.0 licensing. // LGPL starts a test metadata file for a module with LGPL 2.0 licensing.
LGPL = `` + LGPL = `` +
`package_name: "Free Library" `package_name: "Free Library"
license_kinds: "SPDX-license-identifier-LGPL-2.0" license_kinds: "SPDX-license-identifier-LGPL-2.0"
license_conditions: "restricted" license_conditions: "restricted"
` `
// MPL starts a test metadata file for a module with MPL 2.0 reciprical licensing. // MPL starts a test metadata file for a module with MPL 2.0 reciprical licensing.
MPL = `` + MPL = `` +
`package_name: "Reciprocal" `package_name: "Reciprocal"
license_kinds: "SPDX-license-identifier-MPL-2.0" license_kinds: "SPDX-license-identifier-MPL-2.0"
license_conditions: "reciprocal" license_conditions: "reciprocal"
` `
// MIT starts a test metadata file for a module with generic notice (MIT) licensing. // MIT starts a test metadata file for a module with generic notice (MIT) licensing.
MIT = `` + MIT = `` +
`package_name: "Android" `package_name: "Android"
license_kinds: "SPDX-license-identifier-MIT" license_kinds: "SPDX-license-identifier-MIT"
license_conditions: "notice" license_conditions: "notice"
` `
// Proprietary starts a test metadata file for a module with proprietary licensing. // Proprietary starts a test metadata file for a module with proprietary licensing.
Proprietary = `` + Proprietary = `` +
`package_name: "Android" `package_name: "Android"
license_kinds: "legacy_proprietary" license_kinds: "legacy_proprietary"
license_conditions: "proprietary" license_conditions: "proprietary"
` `
// ByException starts a test metadata file for a module with by_exception_only licensing. // ByException starts a test metadata file for a module with by_exception_only licensing.
ByException = `` + ByException = `` +
`package_name: "Special" `package_name: "Special"
license_kinds: "legacy_by_exception_only" license_kinds: "legacy_by_exception_only"
license_conditions: "by_exception_only" license_conditions: "by_exception_only"
` `
@@ -219,7 +219,6 @@ func (l byEdge) Less(i, j int) bool {
return l[i].target < l[j].target return l[i].target < l[j].target
} }
// annotated describes annotated test data edges to define test graphs. // annotated describes annotated test data edges to define test graphs.
type annotated struct { type annotated struct {
target, dep string target, dep string