Showing 1,008 of 1,820 total issues
Function AddRaftNode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func AddRaftNode(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode, tc *cautils.TestCA, opts ...raft.NodeOptions) {
Method Node.saveToStorage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ctx context.Context,
raftConfig *api.RaftConfig,
hardState raftpb.HardState,
entries []raftpb.Entry,
snapshot raftpb.Snapshot,
Method nodePlugin.NodeUnpublishVolume
has 5 return statements (exceeds 4 allowed). Open
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")
}
Method Config.validate
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *Config) validate() error {
if c.Credentials == nil {
return errors.New("agent: Credentials is required")
}
Function getService
has 5 return statements (exceeds 4 allowed). Open
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.
Method PayloadContext.configGetter
has 5 return statements (exceeds 4 allowed). Open
Open
func (ctx *PayloadContext) configGetter(target string) (string, error) {
if ctx.restrictedConfigs == nil {
return "", errors.New("configs unavailable")
}
Function printClusterSummary
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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)
- Read upRead up
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 templatedConfigGetter.GetAndFlagSecretData
has 5 return statements (exceeds 4 allowed). Open
Open
func (t templatedConfigGetter) GetAndFlagSecretData(configID string) (*api.Config, bool, error) {
if t.dependencies == nil {
return nil, false, errors.New("no config provider available")
}
Method worker.Update
has 5 return statements (exceeds 4 allowed). Open
Open
func (w *worker) Update(ctx context.Context, assignments []*api.AssignmentChange) error {
w.mu.Lock()
defer w.mu.Unlock()
if w.closed {
Function getCluster
has 5 return statements (exceeds 4 allowed). Open
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
}
Method nodePlugin.NodePublishVolume
has 5 return statements (exceeds 4 allowed). Open
Open
func (np *nodePlugin) NodePublishVolume(ctx context.Context, req *api.VolumeAssignment) error {
err := capability.CheckArguments(req)
if err != nil {
return err
}
Method Agent.withSession
has 5 return statements (exceeds 4 allowed). Open
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,
Function getNode
has 5 return statements (exceeds 4 allowed). Open
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.
Method worker.Assign
has 5 return statements (exceeds 4 allowed). Open
Open
func (w *worker) Assign(ctx context.Context, assignments []*api.AssignmentChange) error {
w.mu.Lock()
defer w.mu.Unlock()
if w.closed {
Function dumpWAL
has 5 return statements (exceeds 4 allowed). Open
Open
func dumpWAL(swarmdir, unlockKey string, start, end uint64, redact bool) error {
walData, _, err := loadData(swarmdir, unlockKey)
if err != nil {
return err
}
Method templatedSecretGetter.Get
has 5 return statements (exceeds 4 allowed). Open
Open
func (t templatedSecretGetter) Get(secretID string) (*api.Secret, error) {
if t.dependencies == nil {
return nil, errors.New("no secret provider available")
}
Method Agent.Leave
has 5 return statements (exceeds 4 allowed). Open
Open
func (a *Agent) Leave(ctx context.Context) error {
select {
case <-a.started:
default:
return errAgentNotStarted
Method nodePlugin.NodeStageVolume
has 5 return statements (exceeds 4 allowed). Open
Open
func (np *nodePlugin) NodeStageVolume(ctx context.Context, req *api.VolumeAssignment) error {
np.mu.Lock()
defer np.mu.Unlock()
if !np.staging {
return nil
Method PayloadContext.secretGetter
has 5 return statements (exceeds 4 allowed). Open
Open
func (ctx *PayloadContext) secretGetter(target string) (string, error) {
if ctx.restrictedSecrets == nil {
return "", errors.New("secrets unavailable")
}
Function loadData
has 5 return statements (exceeds 4 allowed). Open
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 (