waku/v2/protocol/noise/pairing.go
Method Pairing.initiatorHandshake
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *Pairing) initiatorHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
go func() {
defer utils.LogOnPanic()
Method Pairing.responderHandshake
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
func() {
defer close(doneCh)
Method Pairing.initiatorHandshake
has 14 return statements (exceeds 4 allowed). Open
Open
func (p *Pairing) initiatorHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
go func() {
defer utils.LogOnPanic()
Method Pairing.initiatorHandshake
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func (p *Pairing) initiatorHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
go func() {
defer utils.LogOnPanic()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Pairing.responderHandshake
has 13 return statements (exceeds 4 allowed). Open
Open
func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
func() {
defer close(doneCh)
Method Pairing.responderHandshake
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
func() {
defer close(doneCh)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function NewPairing
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewPairing(myStaticKey n.Keypair, myEphemeralKey n.Keypair, opts PairingParameterOption, messenger NoiseMessenger, logger *zap.Logger) (*Pairing, error) {