kubenetworks/kubevpn

View on GitHub
pkg/core/gvisortunendpoint.go

Summary

Maintainability
C
1 day
Test Coverage

Function NewTunEndpoint has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
Open

func NewTunEndpoint(ctx context.Context, tun net.Conn, mtu uint32, engine config.Engine, in chan<- *DataElem, out chan *DataElem) stack.LinkEndpoint {
    addr, _ := tcpip.ParseMACAddress("02:03:03:04:05:06")
    endpoint := channel.New(tcp.DefaultReceiveBufferSize, mtu, addr)

    go func() {
Severity: Minor
Found in pkg/core/gvisortunendpoint.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

Function NewTunEndpoint has 99 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func NewTunEndpoint(ctx context.Context, tun net.Conn, mtu uint32, engine config.Engine, in chan<- *DataElem, out chan *DataElem) stack.LinkEndpoint {
    addr, _ := tcpip.ParseMACAddress("02:03:03:04:05:06")
    endpoint := channel.New(tcp.DefaultReceiveBufferSize, mtu, addr)

    go func() {
Severity: Major
Found in pkg/core/gvisortunendpoint.go - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                if (ipProtocol == int(layers.IPProtocolUDP) || ipProtocol == int(layers.IPProtocolUDPLite) || ipProtocol == int(layers.IPProtocolTCP)) &&
                    (engine == config.EngineGvisor || (engine == config.EngineMix && (!config.CIDR.Contains(dst) && !config.CIDR6.Contains(dst)))) {
    Severity: Major
    Found in pkg/core/gvisortunendpoint.go - About 1 hr to fix

      Function NewTunEndpoint has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func NewTunEndpoint(ctx context.Context, tun net.Conn, mtu uint32, engine config.Engine, in chan<- *DataElem, out chan *DataElem) stack.LinkEndpoint {
      Severity: Minor
      Found in pkg/core/gvisortunendpoint.go - About 45 mins to fix

        Function NewTunEndpoint has 6 return statements (exceeds 4 allowed).
        Open

        func NewTunEndpoint(ctx context.Context, tun net.Conn, mtu uint32, engine config.Engine, in chan<- *DataElem, out chan *DataElem) stack.LinkEndpoint {
            addr, _ := tcpip.ParseMACAddress("02:03:03:04:05:06")
            endpoint := channel.New(tcp.DefaultReceiveBufferSize, mtu, addr)
        
            go func() {
        Severity: Major
        Found in pkg/core/gvisortunendpoint.go - About 40 mins to fix

          There are no issues that match your filters.

          Category
          Status