From 337055f5adb44a4c1899775c375e380085a51010 Mon Sep 17 00:00:00 2001 From: sonalmahajan15 Date: Mon, 30 Oct 2023 14:39:25 -0700 Subject: [PATCH] address code review comments --- annotation/affiliation.go | 8 ++++---- annotation/consume_trigger.go | 6 +++--- annotation/consume_trigger_test.go | 5 +++-- annotation/key_test.go | 1 + annotation/produce_trigger.go | 29 ++++++++++------------------- annotation/produce_trigger_test.go | 5 +++-- 6 files changed, 24 insertions(+), 30 deletions(-) diff --git a/annotation/affiliation.go b/annotation/affiliation.go index 1f179af0..a04fe21d 100644 --- a/annotation/affiliation.go +++ b/annotation/affiliation.go @@ -62,7 +62,7 @@ func FullTriggerForInterfaceParamFlow(affiliation AffiliationPair, paramNum int) Annotation: &InterfaceParamReachesImplementation{ TriggerIfNilable: &TriggerIfNilable{ Ann: ParamKeyFromArgNum(affiliation.InterfaceMethod, paramNum)}, - AffiliationPair: &affiliation, + AffiliationPair: affiliation, }, Expr: affiliation.interfaceMethodAsExpr(), }, @@ -70,7 +70,7 @@ func FullTriggerForInterfaceParamFlow(affiliation AffiliationPair, paramNum int) Annotation: &MethodParamFromInterface{ TriggerIfNonNil: &TriggerIfNonNil{ Ann: ParamKeyFromArgNum(affiliation.ImplementingMethod, paramNum)}, - AffiliationPair: &affiliation, + AffiliationPair: affiliation, }, Expr: affiliation.implementingMethodAsExpr(), Guards: util.NoGuards(), @@ -91,7 +91,7 @@ func FullTriggerForInterfaceResultFlow(affiliation AffiliationPair, retNum int) Annotation: &MethodResultReachesInterface{ TriggerIfNilable: &TriggerIfNilable{ Ann: RetKeyFromRetNum(affiliation.ImplementingMethod, retNum)}, - AffiliationPair: &affiliation, + AffiliationPair: affiliation, }, Expr: affiliation.implementingMethodAsExpr(), }, @@ -99,7 +99,7 @@ func FullTriggerForInterfaceResultFlow(affiliation AffiliationPair, retNum int) Annotation: &InterfaceResultFromImplementation{ TriggerIfNonNil: &TriggerIfNonNil{ Ann: RetKeyFromRetNum(affiliation.InterfaceMethod, retNum)}, - AffiliationPair: &affiliation, + AffiliationPair: affiliation, }, Expr: affiliation.interfaceMethodAsExpr(), Guards: util.NoGuards(), diff --git a/annotation/consume_trigger.go b/annotation/consume_trigger.go index 08104108..ae12353f 100644 --- a/annotation/consume_trigger.go +++ b/annotation/consume_trigger.go @@ -574,7 +574,7 @@ func (a RecvPassPrestring) String() string { // InterfaceResultFromImplementation is when a result is determined to flow from a concrete method to an interface method via implementation type InterfaceResultFromImplementation struct { *TriggerIfNonNil - *AffiliationPair + AffiliationPair } // equals returns true if the passed ConsumingAnnotationTrigger is equal to this one @@ -612,7 +612,7 @@ func (i InterfaceResultFromImplementationPrestring) String() string { // MethodParamFromInterface is when a param flows from an interface method to a concrete method via implementation type MethodParamFromInterface struct { *TriggerIfNonNil - *AffiliationPair + AffiliationPair } // equals returns true if the passed ConsumingAnnotationTrigger is equal to this one @@ -1389,7 +1389,7 @@ type ConsumeTrigger struct { GuardMatched bool } -// Eq compares two ConsumeTrigger pointers for equality +// equals compares two ConsumeTrigger pointers for equality func (c *ConsumeTrigger) equals(c2 *ConsumeTrigger) bool { return c.Annotation.equals(c2.Annotation) && c.Expr == c2.Expr && diff --git a/annotation/consume_trigger_test.go b/annotation/consume_trigger_test.go index 7cf36593..367628bd 100644 --- a/annotation/consume_trigger_test.go +++ b/annotation/consume_trigger_test.go @@ -47,8 +47,8 @@ func (s *ConsumingAnnotationTriggerTestSuite) SetupTest() { &GlobalVarAssign{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}}, &ArgPass{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}}, &RecvPass{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}}, - &InterfaceResultFromImplementation{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}, AffiliationPair: &AffiliationPair{}}, - &MethodParamFromInterface{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}, AffiliationPair: &AffiliationPair{}}, + &InterfaceResultFromImplementation{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}}, + &MethodParamFromInterface{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}}, &UseAsReturn{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}}, &UseAsFldOfReturn{TriggerIfNonNil: &TriggerIfNonNil{Ann: mockedKey}}, &SliceAssign{TriggerIfDeepNonNil: &TriggerIfDeepNonNil{Ann: mockedKey}}, @@ -73,5 +73,6 @@ func (s *ConsumingAnnotationTriggerTestSuite) SetupTest() { // TestConsumingAnnotationTriggerEqualsSuite runs the test suite for the `equals` method of all the structs that implement // the `ConsumingAnnotationTrigger` interface. func TestConsumingAnnotationTriggerEqualsSuite(t *testing.T) { + t.Parallel() suite.Run(t, new(ConsumingAnnotationTriggerTestSuite)) } diff --git a/annotation/key_test.go b/annotation/key_test.go index 5dd4c06d..cdf24e09 100644 --- a/annotation/key_test.go +++ b/annotation/key_test.go @@ -46,5 +46,6 @@ func (s *KeyTestSuite) SetupTest() { // TestKeyEqualsSuite runs the test suite for the `equals` method of all the structs that implement // the `Key` interface. func TestKeyEqualsSuite(t *testing.T) { + t.Parallel() suite.Run(t, new(KeyTestSuite)) } diff --git a/annotation/produce_trigger.go b/annotation/produce_trigger.go index 827ff39e..cc42dbe9 100644 --- a/annotation/produce_trigger.go +++ b/annotation/produce_trigger.go @@ -90,16 +90,10 @@ func (t *TriggerIfNilable) CheckProduce(annMap Map) bool { return ok && ann.IsNilable } -// NeedsGuardMatch for a `TriggerIfNilable` is default false, as guarding -// applies mostly to deep reads, but this behavior is overriden -// for `VariadicFuncParamDeep`s, which have the semantics of -// deep reads despite consulting shallow annotations +// NeedsGuardMatch returns true if this trigger needs to be matched with a guarded consumer func (t *TriggerIfNilable) NeedsGuardMatch() bool { return t.NeedsGuard } -// SetNeedsGuard for a `TriggerIfNilable` is, by default, a noop, as guarding -// applies mostly to deep reads, but this behavior is overriden -// for `VariadicFuncParamDeep`s, which have the semantics of -// deep reads despite consulting shallow annotations +// SetNeedsGuard sets the underlying Guard-Neediness of this ProduceTrigger, if present func (t *TriggerIfNilable) SetNeedsGuard(b bool) { t.NeedsGuard = b } // Kind returns Conditional. @@ -141,13 +135,10 @@ func (t *TriggerIfDeepNilable) CheckProduce(annMap Map) bool { return ok && ann.IsDeepNilable } -// NeedsGuardMatch for a `TriggerIfDeepNilable` is default false, -// but overridden for most concrete triggers to read a boolean -// field +// NeedsGuardMatch returns true if this trigger needs to be matched with a guarded consumer func (t *TriggerIfDeepNilable) NeedsGuardMatch() bool { return t.NeedsGuard } -// SetNeedsGuard for a `TriggerIfDeepNilable` is, by default, a noop, -// but overridden for most concrete triggers to set an underlying field +// SetNeedsGuard sets the underlying Guard-Neediness of this ProduceTrigger, if present func (t *TriggerIfDeepNilable) SetNeedsGuard(b bool) { t.NeedsGuard = b } // Kind returns DeepConditional. @@ -174,12 +165,12 @@ func (*ProduceTriggerTautology) CheckProduce(Map) bool { return true } -// NeedsGuardMatch for a ProduceTriggerTautology is false - there is no wiggle room with these +// NeedsGuardMatch returns true if this trigger needs to be matched with a guarded consumer func (p *ProduceTriggerTautology) NeedsGuardMatch() bool { return p.NeedsGuard } -// SetNeedsGuard for a ProduceTriggerTautology is a noop +// SetNeedsGuard sets the underlying Guard-Neediness of this ProduceTrigger, if present func (p *ProduceTriggerTautology) SetNeedsGuard(b bool) { p.NeedsGuard = b } // Prestring returns this Prestring as a Prestring @@ -230,10 +221,10 @@ func (*ProduceTriggerNever) CheckProduce(Map) bool { return false } -// NeedsGuardMatch for a ProduceTriggerNever is false, like ProduceTriggerTautology +// NeedsGuardMatch returns true if this trigger needs to be matched with a guarded consumer func (p *ProduceTriggerNever) NeedsGuardMatch() bool { return p.NeedsGuard } -// SetNeedsGuard for a ProduceTriggerNever is a noop, like ProduceTriggerTautology +// SetNeedsGuard sets the underlying Guard-Neediness of this ProduceTrigger, if present func (p *ProduceTriggerNever) SetNeedsGuard(b bool) { p.NeedsGuard = b } // Kind returns Never. @@ -835,7 +826,7 @@ func (m MethodReturnPrestring) String() string { // MethodResultReachesInterface is used when a result of a method is determined to flow into a result of an interface using inheritance type MethodResultReachesInterface struct { *TriggerIfNilable - *AffiliationPair + AffiliationPair } // equals returns true if the passed ProducingAnnotationTrigger is equal to this one @@ -872,7 +863,7 @@ func (m MethodResultReachesInterfacePrestring) String() string { // InterfaceParamReachesImplementation is used when a param of a method is determined to flow into the param of an implementing method type InterfaceParamReachesImplementation struct { *TriggerIfNilable - *AffiliationPair + AffiliationPair } // equals returns true if the passed ProducingAnnotationTrigger is equal to this one diff --git a/annotation/produce_trigger_test.go b/annotation/produce_trigger_test.go index de438400..dd2bd463 100644 --- a/annotation/produce_trigger_test.go +++ b/annotation/produce_trigger_test.go @@ -61,8 +61,8 @@ func (s *ProducingAnnotationTriggerTestSuite) SetupTest() { &FldReturn{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}}, &FuncReturn{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}}, &MethodReturn{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}}, - &MethodResultReachesInterface{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}, AffiliationPair: &AffiliationPair{}}, - &InterfaceParamReachesImplementation{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}, AffiliationPair: &AffiliationPair{}}, + &MethodResultReachesInterface{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}}, + &InterfaceParamReachesImplementation{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}}, &GlobalVarRead{TriggerIfNilable: &TriggerIfNilable{Ann: mockedKey}}, &MapRead{TriggerIfDeepNilable: &TriggerIfDeepNilable{Ann: mockedKey}}, &ArrayRead{TriggerIfDeepNilable: &TriggerIfDeepNilable{Ann: mockedKey}}, @@ -82,5 +82,6 @@ func (s *ProducingAnnotationTriggerTestSuite) SetupTest() { // TestProducingAnnotationTriggerEqualsSuite runs the test suite for the `equals` method of all the structs that implement // the `ProducingAnnotationTrigger` interface. func TestProducingAnnotationTriggerEqualsSuite(t *testing.T) { + t.Parallel() suite.Run(t, new(ProducingAnnotationTriggerTestSuite)) }