pkg/kt/service/tun/tun_windows.go
Method Cli.SetRoute
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *Cli) SetRoute(ipRange []string, excludeIpRange []string) error {
var lastErr error
anyRouteOk := false
// add by lichp, set ipv6 address
Function getKtRouteRecords
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
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",
Avoid deeply nested control flow statements. Open
Open
} else if index == 5 {
iface = parts[i]
} else if index > 5 {
iface = fmt.Sprintf("%s %s", iface, parts[i])
}
Function getKtRouteRecords
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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",
- Read upRead up
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"