xjasonlyu/tun2socks

View on GitHub

Showing 25 of 39 total issues

Function Unpack has 5 return statements (exceeds 4 allowed).
Open

func Unpack(dst, pkt []byte, ciph Cipher) ([]byte, error) {
    saltSize := ciph.SaltSize()
    if len(pkt) < saltSize {
        return nil, ErrShortPacket
    }
Severity: Major
Found in transport/shadowsocks/shadowaead/packet.go - About 35 mins to fix

    Function PickCipher has 5 return statements (exceeds 4 allowed).
    Open

    func PickCipher(name string, key []byte, password string) (Cipher, error) {
        name = strings.ToUpper(name)
    
        switch name {
        case "DUMMY":
    Severity: Major
    Found in transport/shadowsocks/core/cipher.go - About 35 mins to fix

      Method HTTPObfs.Read has 5 return statements (exceeds 4 allowed).
      Open

      func (ho *HTTPObfs) Read(b []byte) (int, error) {
          if ho.buf != nil {
              n := copy(b, ho.buf[ho.offset:])
              ho.offset += n
              if ho.offset == len(ho.buf) {
      Severity: Major
      Found in transport/simple-obfs/http.go - About 35 mins to fix

        Function netstack has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
        Open

        func netstack(k *Key) (err error) {
            if k.Proxy == "" {
                return errors.New("empty proxy")
            }
            if k.Device == "" {
        Severity: Minor
        Found in engine/engine.go - About 25 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 setSocketOptions has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
        Open

        func setSocketOptions(network, address string, c syscall.RawConn, opts *Options) (err error) {
            if opts == nil || !isTCPSocket(network) && !isUDPSocket(network) {
                return
            }
        
        
        Severity: Minor
        Found in dialer/sockopt_darwin.go - About 25 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

        Severity
        Category
        Status
        Source
        Language