xjasonlyu/tun2socks

View on GitHub
transport/socks5/socks5.go

Summary

Maintainability
A
3 hrs
Test Coverage

Function ClientHandshake has 14 return statements (exceeds 4 allowed).
Open

func ClientHandshake(rw io.ReadWriter, addr Addr, command Command, user *User) (Addr, error) {
    buf := make([]byte, MaxAddrLen)

    var method uint8
    if user != nil {
Severity: Major
Found in transport/socks5/socks5.go - About 1 hr to fix

    Function ClientHandshake has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
    Open

    func ClientHandshake(rw io.ReadWriter, addr Addr, command Command, user *User) (Addr, error) {
        buf := make([]byte, MaxAddrLen)
    
        var method uint8
        if user != nil {
    Severity: Minor
    Found in transport/socks5/socks5.go - About 45 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 ReadAddr has 6 return statements (exceeds 4 allowed).
    Open

    func ReadAddr(r io.Reader, b []byte) (Addr, error) {
        if len(b) < MaxAddrLen {
            return nil, io.ErrShortBuffer
        }
    
    
    Severity: Major
    Found in transport/socks5/socks5.go - About 40 mins to fix

      Method Addr.Valid has 5 return statements (exceeds 4 allowed).
      Open

      func (a Addr) Valid() bool {
          if len(a) < 1+1+2 /* minimum length */ {
              return false
          }
      
      
      Severity: Major
      Found in transport/socks5/socks5.go - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status