dotcloud/docker

View on GitHub
builder/dockerfile/builder.go

Summary

Maintainability
B
4 hrs
Test Coverage

Method Builder.dispatchDockerfileWithCancellation has 54 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (b *Builder) dispatchDockerfileWithCancellation(ctx context.Context, parseResult []instructions.Stage, metaArgs []instructions.ArgCommand, escapeToken rune, source builder.Source) (*dispatchState, error) {
    dispatchRequest := dispatchRequest{}
    buildArgs := NewBuildArgs(b.options.BuildArgs)
    totalCommands := len(metaArgs) + len(parseResult)
    currentCommandIndex := 1
Severity: Minor
Found in builder/dockerfile/builder.go - About 1 hr to fix

    Method Builder.dispatchDockerfileWithCancellation has 8 return statements (exceeds 4 allowed).
    Open

    func (b *Builder) dispatchDockerfileWithCancellation(ctx context.Context, parseResult []instructions.Stage, metaArgs []instructions.ArgCommand, escapeToken rune, source builder.Source) (*dispatchState, error) {
        dispatchRequest := dispatchRequest{}
        buildArgs := NewBuildArgs(b.options.BuildArgs)
        totalCommands := len(metaArgs) + len(parseResult)
        currentCommandIndex := 1
    Severity: Major
    Found in builder/dockerfile/builder.go - About 50 mins to fix

      Function BuildFromConfig has 7 return statements (exceeds 4 allowed).
      Open

      func BuildFromConfig(ctx context.Context, config *container.Config, changes []string, os string) (*container.Config, error) {
          if len(changes) == 0 {
              return config, nil
          }
      
      
      Severity: Major
      Found in builder/dockerfile/builder.go - About 45 mins to fix

        Method Builder.dispatchDockerfileWithCancellation has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func (b *Builder) dispatchDockerfileWithCancellation(ctx context.Context, parseResult []instructions.Stage, metaArgs []instructions.ArgCommand, escapeToken rune, source builder.Source) (*dispatchState, error) {
        Severity: Minor
        Found in builder/dockerfile/builder.go - About 35 mins to fix

          Method Builder.build has 5 return statements (exceeds 4 allowed).
          Open

          func (b *Builder) build(ctx context.Context, source builder.Source, dockerfile *parser.Result) (*builder.Result, error) {
              defer b.imageSources.Unmount()
          
              stages, metaArgs, err := instructions.Parse(dockerfile.AST, nil)
              if err != nil {
          Severity: Major
          Found in builder/dockerfile/builder.go - About 35 mins to fix

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

            func (b *Builder) dispatchDockerfileWithCancellation(ctx context.Context, parseResult []instructions.Stage, metaArgs []instructions.ArgCommand, escapeToken rune, source builder.Source) (*dispatchState, error) {
                dispatchRequest := dispatchRequest{}
                buildArgs := NewBuildArgs(b.options.BuildArgs)
                totalCommands := len(metaArgs) + len(parseResult)
                currentCommandIndex := 1
            Severity: Minor
            Found in builder/dockerfile/builder.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