docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method Node.saveToStorage has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    ctx context.Context,
    raftConfig *api.RaftConfig,
    hardState raftpb.HardState,
    entries []raftpb.Entry,
    snapshot raftpb.Snapshot,
Severity: Minor
Found in manager/state/raft/raft.go - About 35 mins to fix

    Function AddRaftNode has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func AddRaftNode(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode, tc *cautils.TestCA, opts ...raft.NodeOptions) {
    Severity: Minor
    Found in manager/state/raft/testutils/testutils.go - About 35 mins to fix

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

      func dumpWAL(swarmdir, unlockKey string, start, end uint64, redact bool) error {
          walData, _, err := loadData(swarmdir, unlockKey)
          if err != nil {
              return err
          }
      Severity: Major
      Found in swarmd/cmd/swarm-rafttool/dump.go - About 35 mins to fix

        Method PayloadContext.configGetter has 5 return statements (exceeds 4 allowed).
        Open

        func (ctx *PayloadContext) configGetter(target string) (string, error) {
            if ctx.restrictedConfigs == nil {
                return "", errors.New("configs unavailable")
            }
        
        
        Severity: Major
        Found in template/context.go - About 35 mins to fix

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

          func getNode(ctx context.Context, c api.ControlClient, input string) (*api.Node, error) {
              // GetNode to match via full ID.
              rg, err := c.GetNode(ctx, &api.GetNodeRequest{NodeID: input})
              if err != nil {
                  // If any error (including NotFound), ListServices to match via full name.
          Severity: Major
          Found in swarmd/cmd/swarmctl/node/common.go - About 35 mins to fix

            Method nodePlugin.NodeUnpublishVolume has 5 return statements (exceeds 4 allowed).
            Open

            func (np *nodePlugin) NodeUnpublishVolume(ctx context.Context, req *api.VolumeAssignment) error {
                // Check arguments
                if len(req.VolumeID) == 0 {
                    return status.Error(codes.InvalidArgument, "Volume ID missing in request")
                }
            Severity: Major
            Found in agent/csi/plugin/plugin.go - About 35 mins to fix

              Method worker.Update has 5 return statements (exceeds 4 allowed).
              Open

              func (w *worker) Update(ctx context.Context, assignments []*api.AssignmentChange) error {
                  w.mu.Lock()
                  defer w.mu.Unlock()
              
                  if w.closed {
              Severity: Major
              Found in agent/worker.go - About 35 mins to fix

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

                func loadData(swarmdir, unlockKey string) (*storage.WALData, *raftpb.Snapshot, error) {
                    snapDir := filepath.Join(swarmdir, "raft", "snap-v3-encrypted")
                    walDir := filepath.Join(swarmdir, "raft", "wal-v3-encrypted")
                
                    var (
                Severity: Major
                Found in swarmd/cmd/swarm-rafttool/dump.go - About 35 mins to fix

                  Method templatedSecretGetter.Get has 5 return statements (exceeds 4 allowed).
                  Open

                  func (t templatedSecretGetter) Get(secretID string) (*api.Secret, error) {
                      if t.dependencies == nil {
                          return nil, errors.New("no secret provider available")
                      }
                  
                  
                  Severity: Major
                  Found in template/getter.go - About 35 mins to fix

                    Method PayloadContext.secretGetter has 5 return statements (exceeds 4 allowed).
                    Open

                    func (ctx *PayloadContext) secretGetter(target string) (string, error) {
                        if ctx.restrictedSecrets == nil {
                            return "", errors.New("secrets unavailable")
                        }
                    
                    
                    Severity: Major
                    Found in template/context.go - About 35 mins to fix

                      Function printClusterSummary has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func printClusterSummary(cluster *api.Cluster) {
                          w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0)
                          defer w.Flush()
                      
                          common.FprintfIfNotEmpty(w, "ID\t: %s\n", cluster.ID)
                      Severity: Minor
                      Found in swarmd/cmd/swarmctl/cluster/inspect.go - About 35 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

                      Method nodePlugin.NodeStageVolume has 5 return statements (exceeds 4 allowed).
                      Open

                      func (np *nodePlugin) NodeStageVolume(ctx context.Context, req *api.VolumeAssignment) error {
                          np.mu.Lock()
                          defer np.mu.Unlock()
                          if !np.staging {
                              return nil
                      Severity: Major
                      Found in agent/csi/plugin/plugin.go - About 35 mins to fix

                        Method templatedConfigGetter.GetAndFlagSecretData has 5 return statements (exceeds 4 allowed).
                        Open

                        func (t templatedConfigGetter) GetAndFlagSecretData(configID string) (*api.Config, bool, error) {
                            if t.dependencies == nil {
                                return nil, false, errors.New("no config provider available")
                            }
                        
                        
                        Severity: Major
                        Found in template/getter.go - About 35 mins to fix

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

                          func getCluster(ctx context.Context, c api.ControlClient, input string) (*api.Cluster, error) {
                              rg, err := c.GetCluster(ctx, &api.GetClusterRequest{ClusterID: input})
                              if err == nil {
                                  return rg.Cluster, nil
                              }
                          Severity: Major
                          Found in swarmd/cmd/swarmctl/cluster/common.go - About 35 mins to fix

                            Method Config.validate has 5 return statements (exceeds 4 allowed).
                            Open

                            func (c *Config) validate() error {
                                if c.Credentials == nil {
                                    return errors.New("agent: Credentials is required")
                                }
                            
                            
                            Severity: Major
                            Found in agent/config.go - About 35 mins to fix

                              Method nodePlugin.NodePublishVolume has 5 return statements (exceeds 4 allowed).
                              Open

                              func (np *nodePlugin) NodePublishVolume(ctx context.Context, req *api.VolumeAssignment) error {
                                  err := capability.CheckArguments(req)
                                  if err != nil {
                                      return err
                                  }
                              Severity: Major
                              Found in agent/csi/plugin/plugin.go - About 35 mins to fix

                                Method worker.Assign has 5 return statements (exceeds 4 allowed).
                                Open

                                func (w *worker) Assign(ctx context.Context, assignments []*api.AssignmentChange) error {
                                    w.mu.Lock()
                                    defer w.mu.Unlock()
                                
                                    if w.closed {
                                Severity: Major
                                Found in agent/worker.go - About 35 mins to fix

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

                                  func getService(ctx context.Context, c api.ControlClient, input string) (*api.Service, error) {
                                      // GetService to match via full ID.
                                      rg, err := c.GetService(ctx, &api.GetServiceRequest{ServiceID: input})
                                      if err != nil {
                                          // If any error (including NotFound), ListServices to match via full name.
                                  Severity: Major
                                  Found in swarmd/cmd/swarmctl/service/common.go - About 35 mins to fix

                                    Method Agent.Leave has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (a *Agent) Leave(ctx context.Context) error {
                                        select {
                                        case <-a.started:
                                        default:
                                            return errAgentNotStarted
                                    Severity: Major
                                    Found in agent/agent.go - About 35 mins to fix

                                      Method Agent.withSession has 5 return statements (exceeds 4 allowed).
                                      Open

                                      func (a *Agent) withSession(ctx context.Context, fn func(session *session) error) error {
                                          response := make(chan error, 1)
                                          select {
                                          case a.sessionq <- sessionOperation{
                                              fn:       fn,
                                      Severity: Major
                                      Found in agent/agent.go - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language