dotcloud/docker

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

Summary

Maintainability
C
7 hrs
Test Coverage

Worker has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

type Worker struct {
    Opt
    SourceManager *source.Manager
}
Severity: Minor
Found in builder/builder-next/worker/worker.go - About 2 hrs to fix

    Method Worker.FromRemote has 7 return statements (exceeds 4 allowed).
    Open

    func (w *Worker) FromRemote(ctx context.Context, remote *solver.Remote) (cache.ImmutableRef, error) {
        rootfs, err := getLayers(ctx, remote.Descriptors)
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in builder/builder-next/worker/worker.go - About 45 mins to fix

      Method Worker.GetRemotes has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (w *Worker) GetRemotes(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool, _ cacheconfig.RefConfig, all bool, s session.Group) ([]*solver.Remote, error) {
      Severity: Minor
      Found in builder/builder-next/worker/worker.go - About 45 mins to fix

        Method Worker.GetRemotes has 6 return statements (exceeds 4 allowed).
        Open

        func (w *Worker) GetRemotes(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool, _ cacheconfig.RefConfig, all bool, s session.Group) ([]*solver.Remote, error) {
            if ref == nil {
                return nil, nil
            }
            var diffIDs []layer.DiffID
        Severity: Major
        Found in builder/builder-next/worker/worker.go - About 40 mins to fix

          Method Worker.ResolveSourceMetadata has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func (w *Worker) ResolveSourceMetadata(ctx context.Context, op *pb.SourceOp, opt sourceresolver.Opt, sm *session.Manager, g session.Group) (*sourceresolver.MetaResponse, error) {
          Severity: Minor
          Found in builder/builder-next/worker/worker.go - About 35 mins to fix

            Method Worker.ResolveImageConfig has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (w *Worker) ResolveImageConfig(ctx context.Context, ref string, opt sourceresolver.Opt, sm *session.Manager, g session.Group) (digest.Digest, []byte, error) {
            Severity: Minor
            Found in builder/builder-next/worker/worker.go - About 35 mins to fix

              Method Worker.ResolveSourceMetadata has 5 return statements (exceeds 4 allowed).
              Open

              func (w *Worker) ResolveSourceMetadata(ctx context.Context, op *pb.SourceOp, opt sourceresolver.Opt, sm *session.Manager, g session.Group) (*sourceresolver.MetaResponse, error) {
                  if opt.SourcePolicies != nil {
                      return nil, errors.New("source policies can not be set for worker")
                  }
              
              
              Severity: Major
              Found in builder/builder-next/worker/worker.go - About 35 mins to fix

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                func oneOffProgress(ctx context.Context, id string) func(err error) error {
                    pw, _, _ := progress.NewFromContext(ctx)
                    now := time.Now()
                    st := progress.Status{
                        Started: &now,
                Severity: Major
                Found in builder/builder-next/worker/worker.go and 1 other location - About 1 hr to fix
                builder/builder-next/exporter/mobyexporter/writer.go on lines 209..224

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 176.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status