docker/swarmkit

View on GitHub
manager/controlapi/volume.go

Summary

Maintainability
B
5 hrs
Test Coverage

Method Server.UpdateVolume has 15 return statements (exceeds 4 allowed).
Open

func (s *Server) UpdateVolume(ctx context.Context, request *api.UpdateVolumeRequest) (*api.UpdateVolumeResponse, error) {
    if request.VolumeID == "" {
        return nil, status.Errorf(codes.InvalidArgument, "VolumeID must not be empty")
    }
    if request.Spec == nil {
Severity: Major
Found in manager/controlapi/volume.go - About 1 hr to fix

    Method Server.ListVolumes has 9 return statements (exceeds 4 allowed).
    Open

    func (s *Server) ListVolumes(ctx context.Context, request *api.ListVolumesRequest) (*api.ListVolumesResponse, error) {
        var (
            volumes []*api.Volume
            err     error
        )
    Severity: Major
    Found in manager/controlapi/volume.go - About 55 mins to fix

      Method Server.CreateVolume has 9 return statements (exceeds 4 allowed).
      Open

      func (s *Server) CreateVolume(ctx context.Context, request *api.CreateVolumeRequest) (*api.CreateVolumeResponse, error) {
          if request.Spec == nil {
              return nil, status.Errorf(codes.InvalidArgument, "spec must not be nil")
          }
      
      
      Severity: Major
      Found in manager/controlapi/volume.go - About 55 mins to fix

        Method Server.RemoveVolume has 6 return statements (exceeds 4 allowed).
        Open

        func (s *Server) RemoveVolume(ctx context.Context, request *api.RemoveVolumeRequest) (*api.RemoveVolumeResponse, error) {
            err := s.store.Update(func(tx store.Tx) error {
                volume := store.GetVolume(tx, request.VolumeID)
                if volume == nil {
                    return status.Errorf(codes.NotFound, "volume %s not found", request.VolumeID)
        Severity: Major
        Found in manager/controlapi/volume.go - About 40 mins to fix

          Similar blocks of code found in 6 locations. Consider refactoring.
          Open

          func filterVolumes(candidates []*api.Volume, filters ...func(*api.Volume) bool) []*api.Volume {
              result := []*api.Volume{}
              for _, c := range candidates {
                  match := true
                  for _, f := range filters {
          Severity: Major
          Found in manager/controlapi/volume.go and 5 other locations - About 1 hr to fix
          manager/controlapi/cluster.go on lines 186..203
          manager/controlapi/network.go on lines 236..253
          manager/controlapi/node.go on lines 59..76
          manager/controlapi/service.go on lines 960..977
          manager/controlapi/task.go on lines 55..72

          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 140.

          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