Showing 1,008 of 1,820 total issues
Method taskManager.run
has 129 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tm *taskManager) run(ctx context.Context) {
ctx, cancelAll := context.WithCancel(ctx)
defer cancelAll() // cancel all child operations on exit.
ctx = log.WithModule(ctx, "taskmanager")
Function printServiceSummary
has 129 lines of code (exceeds 50 allowed). Consider refactoring. Open
func printServiceSummary(service *api.Service, running int) {
w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0)
defer w.Flush()
task := service.Spec.Task
Method nodeSet.tree
has a Cognitive Complexity of 43 (exceeds 20 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
- 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.processUpdates
has 127 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *Dispatcher) processUpdates(ctx context.Context) {
var (
taskUpdates map[string]*api.TaskStatus
nodeUpdates map[string]nodeUpdate
unpublishedVolumes map[string][]string
Method Network.Unmarshal
has 46 return statements (exceeds 4 allowed). Open
func (m *Network) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Volume.Unmarshal
has 46 return statements (exceeds 4 allowed). Open
func (m *Volume) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Dispatcher.Session
has 125 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *Dispatcher) Session(r *api.SessionRequest, stream api.Dispatcher_SessionServer) error {
d.rpcRW.RLock()
defer d.rpcRW.RUnlock()
dctx, err := d.isRunningLocked()
Method testSuite.TestAllocatorRestartNoEndpointSpec
has 124 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (suite *testSuite) TestAllocatorRestartNoEndpointSpec() {
s := store.NewMemoryStore(nil)
suite.NotNil(s)
defer s.Close()
// Create 3 services with 1 task each
Method Orchestrator.reconcileOneNode
has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring. Open
func (g *Orchestrator) reconcileOneNode(ctx context.Context, node *api.Node) {
if node.Spec.Availability == api.NodeAvailabilityDrain {
log.G(ctx).Debugf("global orchestrator: node %s in drain state, shutting down its tasks", node.ID)
g.foreachTaskFromNode(ctx, node, g.shutdownTask)
return
- 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 Server.checkPortConflicts
has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring. Open
func (s *Server) checkPortConflicts(spec *api.ServiceSpec, serviceID string) error {
if spec.Endpoint == 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 readTx.findIterators
has 45 return statements (exceeds 4 allowed). Open
func (tx readTx) findIterators(table string, by By, checkType func(By) error) ([]memdb.ResultIterator, error) {
switch by.(type) {
case byAll, orCombinator: // generic types
default: // all other types
if err := checkType(by); err != nil {
Method NodeCertificateStatusResponse.Unmarshal
has 119 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *NodeCertificateStatusResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Function parseUpdate
has 119 lines of code (exceeds 50 allowed). Consider refactoring. Open
func parseUpdate(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if flags.Changed("update-parallelism") {
parallelism, err := flags.GetUint64("update-parallelism")
if err != nil {
return err
Method SubscribeLogsRequest.Unmarshal
has 119 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *SubscribeLogsRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Dispatcher.Session
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
func (d *Dispatcher) Session(r *api.SessionRequest, stream api.Dispatcher_SessionServer) error {
d.rpcRW.RLock()
defer d.rpcRW.RUnlock()
dctx, err := d.isRunningLocked()
- 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_Ulimit.Unmarshal
has 117 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ContainerSpec_Ulimit) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method WatchMessage.Unmarshal
has 117 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *WatchMessage) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Reconciler.ReconcileService
has 117 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *Reconciler) ReconcileService(id string) error {
var (
service *api.Service
tasks []*api.Task
cluster *api.Cluster
Method SessionMessage.Unmarshal
has 42 return statements (exceeds 4 allowed). Open
func (m *SessionMessage) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Resource.Unmarshal
has 42 return statements (exceeds 4 allowed). Open
func (m *Resource) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx