alibaba/kt-connect

View on GitHub
pkg/kt/service/tun/tun_windows.go

Summary

Maintainability
A
3 hrs
Test Coverage

Method Cli.SetRoute has 62 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *Cli) SetRoute(ipRange []string, excludeIpRange []string) error {
    var lastErr error
    anyRouteOk := false

    // add by lichp, set ipv6 address
Severity: Minor
Found in pkg/kt/service/tun/tun_windows.go - About 1 hr to fix

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

    func getKtRouteRecords(s *Cli) ([]RouteRecord, error) {
        records := []RouteRecord{}
    
        // run command: netsh interface ipv4 show route store=persistent
        out, _, err := util.RunAndWait(exec.Command("netsh",
    Severity: Minor
    Found in pkg/kt/service/tun/tun_windows.go - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                      } else if index == 5 {
                          iface = parts[i]
                      } else if index > 5 {
                          iface = fmt.Sprintf("%s %s", iface, parts[i])
                      }
      Severity: Major
      Found in pkg/kt/service/tun/tun_windows.go - About 45 mins to fix

        Function getKtRouteRecords has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func getKtRouteRecords(s *Cli) ([]RouteRecord, error) {
            records := []RouteRecord{}
        
            // run command: netsh interface ipv4 show route store=persistent
            out, _, err := util.RunAndWait(exec.Command("netsh",
        Severity: Minor
        Found in pkg/kt/service/tun/tun_windows.go - About 35 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

        There are no issues that match your filters.

        Category
        Status