Showing 1,008 of 1,820 total issues
Method ResolveAddressRequest.Unmarshal
has 12 return statements (exceeds 4 allowed). Open
Open
func (m *ResolveAddressRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Dispatcher.processUpdates
has 12 return statements (exceeds 4 allowed). Open
Open
func (d *Dispatcher) processUpdates(ctx context.Context) {
var (
taskUpdates map[string]*api.TaskStatus
nodeUpdates map[string]nodeUpdate
unpublishedVolumes map[string][]string
Method Dispatcher.Session
has 12 return statements (exceeds 4 allowed). Open
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 Server.checkPortConflicts
has 12 return statements (exceeds 4 allowed). Open
Open
func (s *Server) checkPortConflicts(spec *api.ServiceSpec, serviceID string) error {
if spec.Endpoint == nil {
return nil
}
Method Server.RemoveNode
has 12 return statements (exceeds 4 allowed). Open
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 Node.Join
has 12 return statements (exceeds 4 allowed). Open
Open
func (n *Node) Join(ctx context.Context, req *api.JoinRequest) (*api.JoinResponse, error) {
nodeInfo, err := ca.RemoteNode(ctx)
if err != nil {
return nil, err
}
Function ParseAddSecret
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ParseAddSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
secrets, err := flags.GetStringSlice(flagName)
Function ParseAddConfig
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ParseAddConfig(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
configs, err := flags.GetStringSlice(flagName)
Method NetworkAttachment.MarshalToSizedBuffer
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *NetworkAttachment) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method Dispatcher.markNodesUnknown
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (d *Dispatcher) markNodesUnknown(ctx context.Context) error {
log := log.G(ctx).WithField("method", "(*Dispatcher).markNodesUnknown")
var nodes []*api.Node
var err error
d.store.View(func(tx store.ReadTx) {
Method Allocator.allocateNode
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *Allocator) allocateNode(ctx context.Context, node *api.Node, existingAddressesOnly bool, networks []*api.Network) bool {
var allocated bool
nc := a.netCtx
Method LogMessage.MarshalToSizedBuffer
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *LogMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method TaskSpec.CopyFrom
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *TaskSpec) CopyFrom(src interface{}) {
o := src.(*TaskSpec)
*m = *o
if o.Resources != nil {
Method Scheduler.scheduleNTasksOnNodes
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *Scheduler) scheduleNTasksOnNodes(ctx context.Context, n int, taskGroup map[string]*api.Task, nodes []NodeInfo, schedulingDecisions map[string]schedulingDecision, nodeLess func(a *NodeInfo, b *NodeInfo) bool) int {
tasksScheduled := 0
failedConstraints := make(map[int]bool) // key is index in nodes slice
nodeIter := 0
nodeCount := len(nodes)
Method Server.ListResources
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *Server) ListResources(ctx context.Context, request *api.ListResourcesRequest) (*api.ListResourcesResponse, error) {
var (
resources []*api.Resource
respResources []*api.Resource
err error
Method Deallocator.Run
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (deallocator *Deallocator) Run(ctx context.Context) error {
var (
allServices []*api.Service
allNetworks []*api.Network
)
Method Node.triggerSnapshot
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (n *Node) triggerSnapshot(ctx context.Context, raftConfig api.RaftConfig) {
snapshot := api.Snapshot{Version: api.Snapshot_V0}
for _, member := range n.cluster.Members() {
snapshot.Membership.Members = append(snapshot.Membership.Members,
&api.RaftMember{
Function init
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func init() {
register(ObjectStoreConfig{
Table: &memdb.TableSchema{
Name: tableResource,
Indexes: map[string]*memdb.IndexSchema{
Function parseUpdate
has 11 return statements (exceeds 4 allowed). Open
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 executor.Describe
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
info, err := e.client.Info(ctx)
if err != nil {
return nil, 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"