dotcloud/docker

View on GitHub
builder/builder-next/builder.go

Summary

Maintainability
D
2 days
Test Coverage

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

func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
    if len(opt.Options.Outputs) > 1 {
        return nil, errors.Errorf("multiple outputs not supported")
    }

Severity: Minor
Found in builder/builder-next/builder.go - About 1 day 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 Builder.Build has 186 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
    if len(opt.Options.Outputs) > 1 {
        return nil, errors.Errorf("multiple outputs not supported")
    }

Severity: Major
Found in builder/builder-next/builder.go - About 6 hrs to fix

    File builder.go has 585 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package buildkit
    
    import (
        "context"
        "fmt"
    Severity: Minor
    Found in builder/builder-next/builder.go - About 4 hrs to fix

      Method Builder.Build has 17 return statements (exceeds 4 allowed).
      Open

      func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
          if len(opt.Options.Outputs) > 1 {
              return nil, errors.Errorf("multiple outputs not supported")
          }
      
      
      Severity: Major
      Found in builder/builder-next/builder.go - About 1 hr to fix

        Function toBuildkitPruneInfo has 54 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func toBuildkitPruneInfo(opts types.BuildCachePruneOptions) (client.PruneInfo, error) {
            var until time.Duration
            untilValues := opts.Filters.Get("until")          // canonical
            unusedForValues := opts.Filters.Get("unused-for") // deprecated synonym for "until" filter
        
        
        Severity: Minor
        Found in builder/builder-next/builder.go - About 1 hr to fix

          Method Builder.Prune has 6 return statements (exceeds 4 allowed).
          Open

          func (b *Builder) Prune(ctx context.Context, opts types.BuildCachePruneOptions) (int64, []string, error) {
              ch := make(chan *controlapi.UsageRecord)
          
              eg, ctx := errgroup.WithContext(ctx)
          
          
          Severity: Major
          Found in builder/builder-next/builder.go - About 40 mins to fix

            Method Builder.DiskUsage has 6 return statements (exceeds 4 allowed).
            Open

            func (b *Builder) DiskUsage(ctx context.Context) ([]*types.BuildCache, error) {
                duResp, err := b.controller.DiskUsage(ctx, &controlapi.DiskUsageRequest{})
                if err != nil {
                    return nil, err
                }
            Severity: Major
            Found in builder/builder-next/builder.go - About 40 mins to fix

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

              func toBuildkitExtraHosts(inp []string, hostGatewayIP net.IP) (string, error) {
                  if len(inp) == 0 {
                      return "", nil
                  }
                  hosts := make([]string, 0, len(inp))
              Severity: Major
              Found in builder/builder-next/builder.go - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status