Showing 1,008 of 1,820 total issues
Method deepCopyGen.genMsgDeepCopy
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (d *deepCopyGen) genMsgDeepCopy(m *generator.Descriptor) {
ccTypeName := generator.CamelCaseSlice(m.TypeName())
// Generate backwards compatible, type-safe Copy() function.
d.P("func (m *", ccTypeName, ") Copy() *", ccTypeName, "{")
- 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 Orchestrator.Run
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (g *Orchestrator) Run(ctx context.Context) error {
defer close(g.doneChan)
// Watch changes to services and tasks
queue := g.store.WatchQueue()
- 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 Manager.handleVolume
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (vm *Manager) handleVolume(ctx context.Context, id string) error {
var volume *api.Volume
vm.store.View(func(tx store.ReadTx) {
volume = store.GetVolume(tx, 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
Function validateCAConfig
has 17 return statements (exceeds 4 allowed). Open
func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cluster *api.Cluster) (*api.RootCA, error) {
newConfig := cluster.Spec.CAConfig.Copy()
newConfig.SigningCACert = ca.NormalizePEMs(newConfig.SigningCACert) // ensure this is normalized before we use it
if len(newConfig.SigningCAKey) > 0 && len(newConfig.SigningCACert) == 0 {
Method Collector.Run
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (c *Collector) Run(ctx context.Context) error {
defer close(c.doneChan)
watcher, cancel, err := store.ViewAndWatch(c.store, func(readTx store.ReadTx) error {
nodes, err := store.FindNodes(readTx, store.All)
- 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 renewCerts
has 64 lines of code (exceeds 50 allowed). Consider refactoring. 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 {
Method Server.UpdateCluster
has 64 lines of code (exceeds 50 allowed). Consider refactoring. 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 {
Method Allocator.doTaskAlloc
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (a *Allocator) doTaskAlloc(ctx context.Context, ev events.Event) {
var (
isDelete bool
t *api.Task
)
Method HeartbeatResponse.Unmarshal
has 16 return statements (exceeds 4 allowed). Open
func (m *HeartbeatResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method TasksMessage.Unmarshal
has 16 return statements (exceeds 4 allowed). Open
func (m *TasksMessage) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method SubscribeLogsMessage.Unmarshal
has 16 return statements (exceeds 4 allowed). Open
func (m *SubscribeLogsMessage) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method StreamRaftMessageRequest.Unmarshal
has 16 return statements (exceeds 4 allowed). Open
func (m *StreamRaftMessageRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method LeaveRequest.Unmarshal
has 16 return statements (exceeds 4 allowed). Open
func (m *LeaveRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ProcessRaftMessageRequest.Unmarshal
has 16 return statements (exceeds 4 allowed). Open
func (m *ProcessRaftMessageRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Server.UpdateService
has 16 return statements (exceeds 4 allowed). Open
func (s *Server) UpdateService(ctx context.Context, request *api.UpdateServiceRequest) (*api.UpdateServiceResponse, error) {
if request.ServiceID == "" || request.ServiceVersion == nil {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
if err := validateServiceSpec(request.Spec); err != nil {
Function NodeMatches
has 16 return statements (exceeds 4 allowed). Open
func NodeMatches(constraints []Constraint, n *api.Node) bool {
for _, constraint := range constraints {
switch {
case strings.EqualFold(constraint.key, "node.id"):
if !constraint.Match(n.ID) {
Method Server.NodeCertificateStatus
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCertificateStatusRequest) (*api.NodeCertificateStatusResponse, error) {
if request.NodeID == "" {
return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
}
Method controller.Start
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *controller) Start(ctx context.Context) error {
if err := r.checkClosed(); err != nil {
return err
}
Method Orchestrator.reconcile
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *Orchestrator) reconcile(ctx context.Context, service *api.Service) {
runningSlots, deadSlots, err := r.updatableAndDeadSlots(ctx, service)
if err != nil {
log.G(ctx).WithError(err).Errorf("reconcile failed finding tasks")
return
Method assignmentSet.releaseTaskDependencies
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (a *assignmentSet) releaseTaskDependencies(readTx store.ReadTx, t *api.Task) bool {
var modified bool
for _, resourceRef := range t.Spec.ResourceReferences {
var assignment *api.Assignment