waku-org/go-waku

View on GitHub
waku/v2/protocol/noise/pairing.go

Summary

Maintainability
C
1 day
Test Coverage
D
68%

Method Pairing.initiatorHandshake has 79 lines of code (exceeds 50 allowed). Consider refactoring.
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()
Severity: Major
Found in waku/v2/protocol/noise/pairing.go - About 2 hrs to fix

    Method Pairing.responderHandshake has 74 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
        doneCh = make(chan error, 1)
    
        func() {
            defer close(doneCh)
    Severity: Minor
    Found in waku/v2/protocol/noise/pairing.go - About 1 hr to fix

      Method Pairing.initiatorHandshake has 14 return statements (exceeds 4 allowed).
      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()
      Severity: Major
      Found in waku/v2/protocol/noise/pairing.go - About 1 hr to fix

        Method Pairing.initiatorHandshake has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
        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()
        Severity: Minor
        Found in waku/v2/protocol/noise/pairing.go - About 1 hr to fix

        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

        func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
            doneCh = make(chan error, 1)
        
            func() {
                defer close(doneCh)
        Severity: Major
        Found in waku/v2/protocol/noise/pairing.go - About 1 hr to fix

          Method Pairing.responderHandshake has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
              doneCh = make(chan error, 1)
          
              func() {
                  defer close(doneCh)
          Severity: Minor
          Found in waku/v2/protocol/noise/pairing.go - About 55 mins to fix

          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

          func NewPairing(myStaticKey n.Keypair, myEphemeralKey n.Keypair, opts PairingParameterOption, messenger NoiseMessenger, logger *zap.Logger) (*Pairing, error) {
          Severity: Minor
          Found in waku/v2/protocol/noise/pairing.go - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status