Showing 1,008 of 1,820 total issues
Object
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
type Object struct {
// Types that are valid to be assigned to Object:
// *Object_Node
// *Object_Service
// *Object_Network
StoreAction
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
type StoreAction struct {
Action StoreActionKind `protobuf:"varint,1,opt,name=action,proto3,enum=docker.swarmkit.v1.StoreActionKind" json:"action,omitempty"`
// Types that are valid to be assigned to Target:
// *StoreAction_Node
// *StoreAction_Service
Function ConvertTaskWatch
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func ConvertTaskWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Task
checkFuncs []TaskCheckFunc
hasDesiredState bool
- 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 Assignment.Unmarshal
has 37 return statements (exceeds 4 allowed). Open
func (m *Assignment) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Server.ListTasks
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) (*api.ListTasksResponse, error) {
var (
tasks []*api.Task
err error
)
- 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 Dispatcher.Run
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *Dispatcher) Run(ctx context.Context) error {
ctx = log.WithModule(ctx, "dispatcher")
log.G(ctx).Info("dispatcher starting")
d.taskUpdatesLock.Lock()
Method SecretSpec.Unmarshal
has 36 return statements (exceeds 4 allowed). Open
func (m *SecretSpec) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Dispatcher.Tasks
has 104 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *Dispatcher) Tasks(r *api.TasksRequest, stream api.Dispatcher_TasksServer) error {
d.rpcRW.RLock()
defer d.rpcRW.RUnlock()
dctx, err := d.isRunningLocked()
Function reconcileTaskState
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func reconcileTaskState(ctx context.Context, w *worker, assignments []*api.AssignmentChange, fullSnapshot bool) error {
var (
updatedTasks []*api.Task
removedTasks []*api.Task
)
Function WatchMessageEvent
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func WatchMessageEvent(c Event) *WatchMessage_Event {
switch v := c.(type) {
case EventCreateNode:
return &WatchMessage_Event{Action: WatchActionKindCreate, Object: &Object{Object: &Object_Node{Node: v.Node}}}
case EventUpdateNode:
Method Scheduler.applySchedulingDecisions
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Scheduler) applySchedulingDecisions(ctx context.Context, schedulingDecisions map[string]schedulingDecision) (successful, failed []schedulingDecision) {
// applySchedulingDecisions is the only place where we make store
// transactions in the scheduler. the scheduler is responsible for freeing
// volumes that are no longer in use. this means that volumes should be
// freed in this function. sometimes, there are no scheduling decisions to
Method Extension.Unmarshal
has 35 return statements (exceeds 4 allowed). Open
func (m *Extension) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Server.UpdateService
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. 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 {
- 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 AssignmentChange.Unmarshal
has 102 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *AssignmentChange) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Server.Run
has 102 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) Run(ctx context.Context) error {
s.mu.Lock()
if s.isRunning() {
s.mu.Unlock()
return errors.New("CA signer is already running")
Method EndpointSpec.Unmarshal
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *EndpointSpec) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method TLSAuthorization.Unmarshal
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *TLSAuthorization) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Function CheckTasks
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func CheckTasks(ctx context.Context, s *store.MemoryStore, readTx store.ReadTx, initHandler InitHandler, startSupervisor restart.SupervisorInterface) error {
instances := make(map[orchestrator.SlotTuple][]*api.Task)
err := s.Batch(func(batch *store.Batch) error {
tasks, err := store.FindTasks(readTx, store.All)
if err != nil {
Method InternalRaftRequest.Unmarshal
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *InternalRaftRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Allocator
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
func (a *Allocator) doNetworkInit(ctx context.Context) (err error) {
nc := &networkContext{
nwkAllocator: a.nwkAllocator,
portAllocator: newPortAllocator(),
pendingTasks: make(map[string]*api.Task),