Showing 1,008 of 1,820 total issues
Method Server.RemoveNode
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) RemoveNode(ctx context.Context, request *api.RemoveNodeRequest) (*api.RemoveNodeResponse, error) {
if request.NodeID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
Method Dispatcher.UpdateTaskStatus
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *Dispatcher) UpdateTaskStatus(ctx context.Context, r *api.UpdateTaskStatusRequest) (*api.UpdateTaskStatusResponse, error) {
d.rpcRW.RLock()
defer d.rpcRW.RUnlock()
dctx, err := d.isRunningLocked()
Function WatchFrom
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func WatchFrom(store *MemoryStore, version *api.Version, specifiers ...api.Event) (chan events.Event, func(), error) {
if version == nil {
ch, cancel := state.Watch(store.WatchQueue(), specifiers...)
return ch, cancel, nil
}
Function init
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func init() {
register(ObjectStoreConfig{
Table: &memdb.TableSchema{
Name: tableNode,
Indexes: map[string]*memdb.IndexSchema{
Function init
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func init() {
register(ObjectStoreConfig{
Table: &memdb.TableSchema{
Name: tableVolume,
Indexes: map[string]*memdb.IndexSchema{
Method Allocator.doNetworkInit
has 57 lines of code (exceeds 50 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),
Function processIPAMOptions
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func processIPAMOptions(cmd *cobra.Command) (*api.IPAMOptions, error) {
flags := cmd.Flags()
var ipamOpts *api.IPAMOptions
if flags.Changed("ipam-driver") {
- 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 Task.MarshalToSizedBuffer
has 13 return statements (exceeds 4 allowed). Open
func (m *Task) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method NetworkSpec.MarshalToSizedBuffer
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (m *NetworkSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
- 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 Supervisor.Restart
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (r *Supervisor) Restart(ctx context.Context, tx store.Tx, cluster *api.Cluster, service *api.Service, t api.Task) error {
// TODO(aluzzardi): This function should not depend on `service`.
// Is the old task still in the process of restarting? If so, wait for
// its restart delay to elapse, to avoid tight restart loops (for
- 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.tickTasks
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (g *Orchestrator) tickTasks(ctx context.Context) {
if len(g.restartTasks) == 0 {
return
}
err := g.store.Batch(func(batch *store.Batch) 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
Function validateHealthCheck
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func validateHealthCheck(hc *api.HealthConfig) error {
if hc == 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
Method LogBroker.PublishLogs
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (lb *LogBroker) PublishLogs(stream api.LogBroker_PublishLogsServer) (err error) {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
- 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 nodeSet.tree
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ns *nodeSet) tree(serviceID string, preferences []*api.PlacementPreference, maxAssignments int, meetsConstraints func(*NodeInfo) bool, nodeLess func(*NodeInfo, *NodeInfo) bool) decisionTree {
var root decisionTree
if maxAssignments == 0 {
return root
Method Allocator.allocateTask
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (a *Allocator) allocateTask(ctx context.Context, t *api.Task) (err error) {
taskUpdated := false
nc := a.netCtx
logger := log.G(ctx).WithField("method", "(*Allocator).allocateTask")
Method Server.ListServices
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) ListServices(ctx context.Context, request *api.ListServicesRequest) (*api.ListServicesResponse, error) {
var (
services []*api.Service
err error
)
Method peer.sendProcessMessage
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *peer) sendProcessMessage(ctx context.Context, m raftpb.Message) error {
// These lines used to be in the code, but they've been removed. I'm
// leaving them in in a comment just in case they cause some unforeseen
// breakage later, to show why they were removed.
//
Method HealthCheckResponse.Unmarshal
has 12 return statements (exceeds 4 allowed). Open
func (m *HealthCheckResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Function ConvertTaskWatch
has 12 return statements (exceeds 4 allowed). Open
func ConvertTaskWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Task
checkFuncs []TaskCheckFunc
hasDesiredState bool
Method ReplicatedService.Unmarshal
has 12 return statements (exceeds 4 allowed). Open
func (m *ReplicatedService) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx