Showing 1,468 of 1,914 total issues
Method Cluster.GetServices
has 90 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Cluster) GetServices(options types.ServiceListOptions) ([]swarm.Service, error) {
c.mu.RLock()
defer c.mu.RUnlock()
state := c.currentNodeState()
Function volumeName
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
Open
func volumeName(path string) (v string) {
if len(path) < 2 {
return ""
}
// with drive letter
- 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 LayerDownloadManager.Download
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS image.RootFS, layers []DownloadDescriptor, progressOutput progress.Output) (image.RootFS, func(), error) {
var (
topLayer layer.Layer
topDownload *downloadTransfer
watcher *watcher
Method driver.Join
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.overlay.Join", trace.WithAttributes(
attribute.String("nid", nid),
attribute.String("eid", eid),
attribute.String("sboxKey", sboxKey)))
Method client.processEventStream
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *client) processEventStream(ctx context.Context, ns string) {
// Create a new context specifically for this subscription.
// The context must be cancelled to cancel the subscription.
// In cases where we have to restart event stream processing,
// we'll need the original context b/c this one will be cancelled
Method ImageService.createDiff
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (i *ImageService) createDiff(ctx context.Context, name string, sn snapshots.Snapshotter, cs content.Store, comparer diff.Comparer) (*ocispec.Descriptor, digest.Digest, error) {
info, err := sn.Stat(ctx, name)
if err != nil {
return nil, "", err
}
Method walker.walk
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (w *walker) walk(path string, i1, i2 os.FileInfo) (err error) {
// Register these nodes with the return trees, unless we're still at the
// (already-created) roots:
if path != "/" {
if err := walkchunk(path, i1, w.dir1, w.root1); err != nil {
Function verifyPlatformContainerResources
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func verifyPlatformContainerResources(resources *containertypes.Resources, isHyperv bool) (warnings []string, err error) {
fixMemorySwappiness(resources)
if !isHyperv {
// The processor resource controls are mutually exclusive on
// Windows Server Containers, the order of precedence is
Method Daemon.statsV2
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) statsV2(s *containertypes.StatsResponse, stats *statsV2.Metrics) (*containertypes.StatsResponse, error) {
if stats.Io != nil {
var isbr []containertypes.BlkioStatEntry
for _, re := range stats.Io.Usage {
isbr = append(isbr,
Method ImageService.manifestMatchesPlatform
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
ls, err := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
if err != nil {
if cerrdefs.IsNotFound(err) {
return false, nil
Function merge
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func merge(userConf, imageConf *containertypes.Config) error {
if userConf.User == "" {
userConf.User = imageConf.User
}
if len(userConf.ExposedPorts) == 0 {
layerStore
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type layerStore struct {
store *fileMetadataStore
driver graphdriver.Driver
layerMap map[ChainID]*roLayer
Method Controller.handleKeyChange
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
drvEnc := discoverapi.DriverEncryptionUpdate{}
agent := c.getAgent()
if agent == nil {
Method ImageService.ImageInspect
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{})
if err != nil {
return nil, err
}
Method Endpoint.sbLeave
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (ep *Endpoint) sbLeave(ctx context.Context, sb *Sandbox, force bool) error {
n, err := ep.getNetworkFromStore()
if err != nil {
return fmt.Errorf("failed to get network from store during leave: %v", err)
}
Function StartProxy
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func StartProxy(pb types.PortBinding,
proxyPath string,
listenSock *os.File,
) (stop func() error, retErr error) {
if proxyPath == "" {
Method Daemon.statsV1
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) statsV1(s *containertypes.StatsResponse, stats *statsV1.Metrics) (*containertypes.StatsResponse, error) {
if stats.Blkio != nil {
s.BlkioStats = containertypes.BlkioStats{
IoServiceBytesRecursive: copyBlkioEntry(stats.Blkio.IoServiceBytesRecursive),
IoServicedRecursive: copyBlkioEntry(stats.Blkio.IoServicedRecursive),
Method addrSpace.allocatePredefinedPool
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
Open
func (aSpace *addrSpace) allocatePredefinedPool(reserved []netip.Prefix) (netip.Prefix, error) {
aSpace.mu.Lock()
defer aSpace.mu.Unlock()
var pdfID int
- 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 NetworkEvent.Unmarshal
has 27 return statements (exceeds 4 allowed). Open
Open
func (m *NetworkEvent) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method NetworkEntry.Unmarshal
has 27 return statements (exceeds 4 allowed). Open
Open
func (m *NetworkEntry) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx