johnsonjh/gfcp

View on GitHub
gfcp.go

Summary

Maintainability
F
1 wk
Test Coverage

File gfcp.go has 1436 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Package gfcp - A Fast and Reliable ARQ Protocol
//
// Copyright © 2021 Jeffrey H. Johnson <trnsz@pobox.com>.
// Copyright © 2015 Daniel Fu <daniel820313@gmail.com>.
// Copyright © 2019 Loki 'l0k18' Verloren <stalker.loki@protonmail.ch>.
Severity: Major
Found in gfcp.go - About 3 days to fix

    Method GFCP.Flush has 275 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (
        GFcp *GFCP,
    ) Flush(
        ackOnly bool,
    ) uint32 {
    Severity: Major
    Found in gfcp.go - About 1 day to fix

      Method GFCP.Flush has a Cognitive Complexity of 65 (exceeds 20 allowed). Consider refactoring.
      Open

      func (
          GFcp *GFCP,
      ) Flush(
          ackOnly bool,
      ) uint32 {
      Severity: Minor
      Found in gfcp.go - About 7 hrs 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 GFCP.Input has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
      Open

      func (
          GFcp *GFCP,
      ) Input(
          data []byte,
          regular,
      Severity: Minor
      Found in gfcp.go - About 6 hrs 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 GFCP.Input has 184 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (
          GFcp *GFCP,
      ) Input(
          data []byte,
          regular,
      Severity: Major
      Found in gfcp.go - About 6 hrs to fix

        Method GFCP.Send has 104 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (
            GFcp *GFCP,
        ) Send(
            buffer []byte,
        ) int {
        Severity: Major
        Found in gfcp.go - About 3 hrs to fix

          GFCP has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type GFCP struct {
              conv, mtu, mss, state               uint32
              sndUna, sndNxt, rcvNxt              uint32
              ssthresh                            uint32
              rxRttVar, rxSrtt                    int32
          Severity: Minor
          Found in gfcp.go - About 2 hrs to fix

            Method GFCP.Recv has 81 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (
                GFcp *GFCP,
            ) Recv(
                buffer []byte,
            ) (
            Severity: Major
            Found in gfcp.go - About 2 hrs to fix

              Method GFCP.parseData has 79 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (
                  GFcp *GFCP,
              ) parseData(
                  newGFcpSeg Segment,
              ) bool {
              Severity: Major
              Found in gfcp.go - About 2 hrs to fix

                Method GFCP.Check has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (
                    GFcp *GFCP,
                ) Check() uint32 {
                    current := CurrentMs()
                    tsFlush := GFcp.tsFlush
                Severity: Minor
                Found in gfcp.go - About 1 hr to fix

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

                  func (
                      GFcp *GFCP,
                  ) Send(
                      buffer []byte,
                  ) int {
                  Severity: Minor
                  Found in gfcp.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

                  Avoid deeply nested control flow statements.
                  Open

                                      if GFcp.incr < mss {
                                          GFcp.incr = mss
                                      }
                  Severity: Major
                  Found in gfcp.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                    if _itimediff(
                                        sn,
                                        GFcp.rcvNxt,
                                    ) >= 0 {
                                        var GFcpSeg Segment
                    Severity: Major
                    Found in gfcp.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if (GFcp.cwnd+1)*mss <= GFcp.incr {
                                              GFcp.cwnd++
                                          }
                      Severity: Major
                      Found in gfcp.go - About 45 mins to fix

                        Method GFCP.Input has 6 return statements (exceeds 4 allowed).
                        Open

                        func (
                            GFcp *GFCP,
                        ) Input(
                            data []byte,
                            regular,
                        Severity: Major
                        Found in gfcp.go - About 40 mins to fix

                          2: cannot find package "go4.org/legal" in any of:
                          Open

                              gfcpLegal "go4.org/legal"
                          Severity: Minor
                          Found in gfcp.go by govet

                          TODO found
                          Open

                                      // TODO(jhj): Switch to pointer to avoid allocation
                          Severity: Minor
                          Found in gfcp.go by fixme

                          XXX found
                          Open

                              }*/ // XXX(jhj): buffer can't be nil?
                          Severity: Minor
                          Found in gfcp.go by fixme

                          XXX found
                          Open

                                      // XXX(jhj) ??? FUCK YOU CHINKS
                          Severity: Minor
                          Found in gfcp.go by fixme

                          There are no issues that match your filters.

                          Category
                          Status