lutfailham96/go-tcp-proxy-tunnel

View on GitHub

Showing 8 of 10 total issues

Function main has 81 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {
    flag.Parse()

    log := logger.NewBaseLogger(logger.LogLevel(*logLevel))

Severity: Major
Found in cmd/tcp-proxy-tunnel/main.go - About 2 hrs to fix

    Function setupTcpListener has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func setupTcpListener(secure bool, log *logger.BaseLogger) {
        var ln net.Listener
        var err error
    
        if secure {
    Severity: Minor
    Found in cmd/ws-web-server/main.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

    Function setupTcpListener has 67 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func setupTcpListener(secure bool, log *logger.BaseLogger) {
        var ln net.Listener
        var err error
    
        if secure {
    Severity: Minor
    Found in cmd/ws-web-server/main.go - About 1 hr to fix

      Method WebForwarder.Start has 63 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (fwd *WebForwarder) Start() {
          if fwd.logger.LogLevel >= logger.Debug {
              defer func(conn net.Conn) {
                  CloseConnectionDebug(conn)
              }(fwd.srcConn)
      Severity: Minor
      Found in internal/tcp/web_forwarder.go - About 1 hr to fix

        Function main has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
        Open

        func main() {
            flag.Parse()
        
            log := logger.NewBaseLogger(logger.LogLevel(*logLevel))
        
        
        Severity: Minor
        Found in cmd/tcp-proxy-tunnel/main.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

        Function TLSGenerateConfig has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TLSGenerateConfig() (serverTLSConf *tls.Config, clientTLSConf *tls.Config, err error) {
            ca := TLSGenerateX509Cer(TLSCerTypeCA)
        
            caPrivateKey, err := rsa.GenerateKey(rand.Reader, 4096)
            if err != nil {
        Severity: Minor
        Found in internal/util/tls_util.go - About 1 hr to fix

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

          func TLSGenerateConfig() (serverTLSConf *tls.Config, clientTLSConf *tls.Config, err error) {
              ca := TLSGenerateX509Cer(TLSCerTypeCA)
          
              caPrivateKey, err := rsa.GenerateKey(rand.Reader, 4096)
              if err != nil {
          Severity: Major
          Found in internal/util/tls_util.go - About 40 mins to fix

            Method Proxy.handleOutboundData has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
            Open

            func (p *Proxy) handleOutboundData(src, dst net.Conn, connBuff *[]byte) {
                if p.lInitialized {
                    return
                }
            
            
            Severity: Minor
            Found in pkg/proxy/proxy.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