kubenetworks/kubevpn

View on GitHub
pkg/dev/docker_utils.go

Summary

Maintainability
D
2 days
Test Coverage

File docker_utils.go has 533 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package dev

import (
    "bytes"
    "context"
Severity: Minor
Found in pkg/dev/docker_utils.go - About 2 hrs to fix

    Function legacyWaitExitOrRemoved has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
    Open

    func legacyWaitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containerID string, waitRemove bool) <-chan int {
        var removeErr error
        statusChan := make(chan int)
        exitCode := 125
    
    
    Severity: Minor
    Found in pkg/dev/docker_utils.go - About 2 hrs 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 runContainer has 79 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func runContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) error {
        config := runConfig.config
        stdout, stderr := dockerCli.Out(), dockerCli.Err()
        apiClient := dockerCli.Client()
    
    
    Severity: Major
    Found in pkg/dev/docker_utils.go - About 2 hrs to fix

      Function run has 71 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func run(ctx context.Context, cli *client.Client, dockerCli *command.DockerCli, runConfig *RunConfig) (id string, err error) {
          rand.New(rand.NewSource(time.Now().UnixNano()))
      
          var config = runConfig.config
          var hostConfig = runConfig.hostConfig
      Severity: Minor
      Found in pkg/dev/docker_utils.go - About 1 hr to fix

        Function createContainer has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
        Open

        func createContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) (string, error) {
            config := runConfig.config
            hostConfig := runConfig.hostConfig
            networkingConfig := runConfig.networkingConfig
            var (
        Severity: Minor
        Found in pkg/dev/docker_utils.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 runContainer has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
        Open

        func runContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) error {
            config := runConfig.config
            stdout, stderr := dockerCli.Out(), dockerCli.Err()
            apiClient := dockerCli.Client()
        
        
        Severity: Minor
        Found in pkg/dev/docker_utils.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 legacyWaitExitOrRemoved has 64 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func legacyWaitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containerID string, waitRemove bool) <-chan int {
            var removeErr error
            statusChan := make(chan int)
            exitCode := 125
        
        
        Severity: Minor
        Found in pkg/dev/docker_utils.go - About 1 hr to fix

          Function createContainer has 57 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func createContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) (string, error) {
              config := runConfig.config
              hostConfig := runConfig.hostConfig
              networkingConfig := runConfig.networkingConfig
              var (
          Severity: Minor
          Found in pkg/dev/docker_utils.go - About 1 hr to fix

            Function run has 10 return statements (exceeds 4 allowed).
            Open

            func run(ctx context.Context, cli *client.Client, dockerCli *command.DockerCli, runConfig *RunConfig) (id string, err error) {
                rand.New(rand.NewSource(time.Now().UnixNano()))
            
                var config = runConfig.config
                var hostConfig = runConfig.hostConfig
            Severity: Major
            Found in pkg/dev/docker_utils.go - About 1 hr to fix

              Function createContainer has 10 return statements (exceeds 4 allowed).
              Open

              func createContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) (string, error) {
                  config := runConfig.config
                  hostConfig := runConfig.hostConfig
                  networkingConfig := runConfig.networkingConfig
                  var (
              Severity: Major
              Found in pkg/dev/docker_utils.go - About 1 hr to fix

                Function runContainer has 9 return statements (exceeds 4 allowed).
                Open

                func runContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) error {
                    config := runConfig.config
                    stdout, stderr := dockerCli.Out(), dockerCli.Err()
                    apiClient := dockerCli.Client()
                
                
                Severity: Major
                Found in pkg/dev/docker_utils.go - About 55 mins to fix

                  Function attachContainer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func attachContainer(ctx context.Context, dockerCli command.Cli, containerID string, errCh *chan error, config *container.Config, options container.AttachOptions) (func(), error) {
                  Severity: Minor
                  Found in pkg/dev/docker_utils.go - About 45 mins to fix

                    Function run has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func run(ctx context.Context, cli *client.Client, dockerCli *command.DockerCli, runConfig *RunConfig) (id string, err error) {
                        rand.New(rand.NewSource(time.Now().UnixNano()))
                    
                        var config = runConfig.config
                        var hostConfig = runConfig.hostConfig
                    Severity: Minor
                    Found in pkg/dev/docker_utils.go - About 45 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 runLogsWaitRunning has 5 return statements (exceeds 4 allowed).
                    Open

                    func runLogsWaitRunning(ctx context.Context, dockerCli command.Cli, id string) error {
                        c, err := dockerCli.Client().ContainerInspect(ctx, id)
                        if err != nil {
                            return err
                        }
                    Severity: Major
                    Found in pkg/dev/docker_utils.go - About 35 mins to fix

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

                      func legacyWaitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containerID string, waitRemove bool) <-chan int {
                          var removeErr error
                          statusChan := make(chan int)
                          exitCode := 125
                      
                      
                      Severity: Major
                      Found in pkg/dev/docker_utils.go - About 35 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status