Showing 1,008 of 1,820 total issues
Method ContainerSpec.MarshalToSizedBuffer
has 11 return statements (exceeds 4 allowed). Open
Open
func (m *ContainerSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Function skipSpecs
has 11 return statements (exceeds 4 allowed). Open
Open
func skipSpecs(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
Function skipWatch
has 11 return statements (exceeds 4 allowed). Open
Open
func skipWatch(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
Function skipPlugin
has 11 return statements (exceeds 4 allowed). Open
Open
func skipPlugin(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
Method Updater.updateTask
has 11 return statements (exceeds 4 allowed). Open
Open
func (u *Updater) updateTask(ctx context.Context, slot orchestrator.Slot, updated *api.Task, order api.UpdateConfig_UpdateOrder) error {
// Kick off the watch before even creating the updated task. This is in order to avoid missing any event.
taskUpdates, cancel := state.Watch(u.watchQueue, api.EventUpdateTask{
Task: &api.Task{ID: updated.ID},
Checks: []api.TaskCheckFunc{api.TaskCheckID},
Function skipRaft
has 11 return statements (exceeds 4 allowed). Open
Open
func skipRaft(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
Method Server.UpdateCluster
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func (s *Server) UpdateCluster(ctx context.Context, request *api.UpdateClusterRequest) (*api.UpdateClusterResponse, error) {
if request.ClusterID == "" || request.ClusterVersion == nil {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
if err := validateClusterSpec(request.Spec); err != nil {
- 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
Function validateConfigRefsSpec
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func validateConfigRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
- 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
Function validateHealthCheck
has 11 return statements (exceeds 4 allowed). Open
Open
func validateHealthCheck(hc *api.HealthConfig) error {
if hc == nil {
return nil
}
Method Node.processInternalRaftRequest
has 11 return statements (exceeds 4 allowed). Open
Open
func (n *Node) processInternalRaftRequest(ctx context.Context, r *api.InternalRaftRequest, cb func()) (proto.Message, error) {
n.stopMu.RLock()
if !n.IsMember() {
n.stopMu.RUnlock()
return nil, ErrStopped
Method LogBroker.SubscribeLogs
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (lb *LogBroker) SubscribeLogs(request *api.SubscribeLogsRequest, stream api.Logs_SubscribeLogsServer) error {
ctx := stream.Context()
if err := validateSelector(request.Selector); err != nil {
return err
Method MemoryStore.update
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *MemoryStore) update(proposer state.Proposer, cb func(Tx) error) error {
defer metrics.StartTimer(updateLatencyTimer)()
s.updateLock.Lock()
memDBTx := s.memDB.Txn(true)
Method Agent.handleSessionMessage
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *Agent) handleSessionMessage(ctx context.Context, message *api.SessionMessage, nti *api.NodeTLSInfo) error {
seen := map[api.Peer]struct{}{}
for _, manager := range message.Managers {
if manager.Peer.Addr == "" {
continue
Function parseRestart
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func parseRestart(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if spec.Task.Restart == nil {
// set new service's restart policy as RestartOnAny
spec.Task.Restart = &api.RestartPolicy{
Condition: api.RestartOnAny,
Method Resource.MarshalToSizedBuffer
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *Resource) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method ServiceSpec.CopyFrom
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *ServiceSpec) CopyFrom(src interface{}) {
o := src.(*ServiceSpec)
*m = *o
github_com_moby_swarmkit_v2_api_deepcopy.Copy(&m.Annotations, &o.Annotations)
Method Server.ListServiceStatuses
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *Server) ListServiceStatuses(ctx context.Context, req *api.ListServiceStatusesRequest) (*api.ListServiceStatusesResponse, error) {
resp := &api.ListServiceStatusesResponse{}
if req == nil {
return resp, nil
}
Function renewCerts
has 10 return statements (exceeds 4 allowed). Open
Open
func renewCerts(swarmdir, unlockKey string) error {
// First, load the existing cert. We don't actually bother to check if
// it's expired - this will just obtain a new cert anyway.
krw, err := getKRW(swarmdir, unlockKey)
if err != nil {
Function parseContainer
has 10 return statements (exceeds 4 allowed). Open
Open
func parseContainer(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if flags.Changed("image") {
image, err := flags.GetString("image")
if err != nil {
return err
Method controller.Wait
has 10 return statements (exceeds 4 allowed). Open
Open
func (r *controller) Wait(ctx context.Context) error {
if err := r.checkClosed(); err != nil {
return err
}