Showing 1,008 of 1,820 total issues
Method roleManager.Run
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func (rm *roleManager) Run(ctx context.Context) {
defer close(rm.doneChan)
var (
nodes []*api.Node
- 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 ContainerSpec.CopyFrom
has 93 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ContainerSpec) CopyFrom(src interface{}) {
o := src.(*ContainerSpec)
*m = *o
if o.Labels != nil {
Method Meta.Unmarshal
has 30 return statements (exceeds 4 allowed). Open
func (m *Meta) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Endpoint.Unmarshal
has 30 return statements (exceeds 4 allowed). Open
func (m *Endpoint) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method TaskReaper.Run
has 91 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tr *TaskReaper) Run(ctx context.Context) {
watcher, watchCancel := state.Watch(tr.store.WatchQueue(), api.EventCreateTask{}, api.EventUpdateTask{}, api.EventUpdateCluster{})
defer func() {
close(tr.doneChan)
Method Server.signNodeCert
has 91 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) signNodeCert(ctx context.Context, node *api.Node) error {
s.signingMu.Lock()
rootCA := s.localRootCA
externalCA := s.externalCA
s.signingMu.Unlock()
Method Server.IssueNodeCertificate
has 91 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNodeCertificateRequest) (*api.IssueNodeCertificateResponse, error) {
// First, let's see if the remote node is presenting a non-empty CSR
if len(request.CSR) == 0 {
return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
}
Method Orchestrator.Run
has 90 lines of code (exceeds 50 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()
Method Config.Unmarshal
has 29 return statements (exceeds 4 allowed). Open
func (m *Config) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ConfigSpec.Unmarshal
has 29 return statements (exceeds 4 allowed). Open
func (m *ConfigSpec) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Supervisor.shouldRestart
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (r *Supervisor) shouldRestart(ctx context.Context, t *api.Task, service *api.Service) bool {
// TODO(aluzzardi): This function should not depend on `service`.
// There are 3 possible restart policies.
switch orchestrator.RestartCondition(t) {
case api.RestartOnAny:
- 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 JoinResponse.Unmarshal
has 29 return statements (exceeds 4 allowed). Open
func (m *JoinResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Function WaitForCluster
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode) {
err := testutils.PollFunc(clockSource, func() error {
var prev *etcdraft.Status
var leadNode *TestNode
nodeLoop:
- 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 Allocator.allocateService
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (a *Allocator) allocateService(ctx context.Context, s *api.Service, existingAddressesOnly bool) error {
nc := a.netCtx
if s.Spec.Endpoint != nil {
// service has user-defined endpoint
- 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 SelectBy.CopyFrom
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *SelectBy) CopyFrom(src interface{}) {
o := src.(*SelectBy)
*m = *o
if o.By != nil {
Method VolumeSpec.MarshalToSizedBuffer
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *VolumeSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method Server.ListTasks
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) (*api.ListTasksResponse, error) {
var (
tasks []*api.Task
err error
)
File updater.go
has 523 lines of code (exceeds 500 allowed). Consider refactoring. Open
package update
import (
"context"
"errors"
Method NetworkSpec.MarshalToSizedBuffer
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *NetworkSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method StoreObject.Unmarshal
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *StoreObject) Unmarshal(dAtA []byte) error {
var hasFields [1]uint64
l := len(dAtA)
iNdEx := 0
for iNdEx < l {