kubenetworks/kubevpn

View on GitHub
pkg/dns/dns_unix.go

Summary

Maintainability
A
3 hrs
Test Coverage

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

func networkCancel() {
    b, err := exec.Command("networksetup", "-listallnetworkservices").CombinedOutput()
    if err != nil {
        return
    }
Severity: Minor
Found in pkg/dns/dns_unix.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 networkSetup has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func networkSetup(ip string, namespace string) {
    networkCancel()
    b, err := exec.Command("networksetup", "-listallnetworkservices").Output()
    if err != nil {
        return
Severity: Minor
Found in pkg/dns/dns_unix.go - About 55 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

Method Config.CancelDNS has 7 return statements (exceeds 4 allowed).
Open

func (c *Config) CancelDNS() {
    if cancel != nil {
        cancel()
    }
    dir := "/etc/resolver"
Severity: Major
Found in pkg/dns/dns_unix.go - About 45 mins to fix

    Method Config.usingResolver has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *Config) usingResolver(ctx context.Context) {
        var clientConfig = c.Config
        var ns = c.Ns
    
        path := "/etc/resolver"
    Severity: Minor
    Found in pkg/dns/dns_unix.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

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

    func (c *Config) usingNetworkSetup(ip string, ns string) {
        networkSetup(ip, ns)
        var ctx context.Context
        ctx, cancel = context.WithCancel(context.Background())
        go func() {
    Severity: Minor
    Found in pkg/dns/dns_unix.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

    There are no issues that match your filters.

    Category
    Status