Showing 1,468 of 1,914 total issues
Method Controller.NewNetwork
has 21 return statements (exceeds 4 allowed). Open
func (c *Controller) NewNetwork(networkType, name string, id string, options ...NetworkOption) (_ *Network, retErr error) {
if id != "" {
c.networkLocker.Lock(id)
defer c.networkLocker.Unlock(id) //nolint:errcheck
Method driver.CreateEndpoint
has 21 return statements (exceeds 4 allowed). Open
func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, _ map[string]interface{}) error {
if ifInfo == nil {
return errors.New("invalid interface info passed")
}
Method driver.Join
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) (retErr error) {
join := &api.JoinRequest{
NetworkID: nid,
EndpointID: eid,
SandboxKey: sboxKey,
- 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 NodeEvent.Unmarshal
has 21 return statements (exceeds 4 allowed). Open
func (m *NodeEvent) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ImageService.getPushDescriptor
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (i *ImageService) getPushDescriptor(ctx context.Context, img containerdimages.Image, platform *ocispec.Platform) (ocispec.Descriptor, error) {
pm := i.matchRequestedOrDefault(platforms.OnlyStrict, platform)
anyMissing := false
- 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 PartialLogEntryMetadata.Unmarshal
has 21 return statements (exceeds 4 allowed). Open
func (m *PartialLogEntryMetadata) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method reader.drainJournal
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (r *reader) drainJournal(ctx context.Context) (bool, error) {
for i := 0; ; i++ {
// Read the entry's timestamp.
timestamp, err := r.j.Realtime()
if 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 Daemon.foldFilter
has 21 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) {
psFilters := config.Filters
var filtExited []int
Method Cluster.CreateService
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRegistry bool) (*swarm.ServiceCreateResponse, error) {
var resp *swarm.ServiceCreateResponse
err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
err := c.populateNetworkID(ctx, state.controlClient, &s)
if err != nil {
Function convertMount
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
func convertMount(m api.Mount) enginemount.Mount {
mount := enginemount.Mount{
Source: m.Source,
Target: m.Target,
ReadOnly: m.ReadOnly,
Function attemptBindHostPorts
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func attemptBindHostPorts(
ctx context.Context,
cfg []portBindingReq,
proto string,
hostPortStart, hostPortEnd uint16,
Method snapshotter.EnsureLayer
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *snapshotter) EnsureLayer(ctx context.Context, key string) ([]layer.DiffID, error) {
s.layerCreateLocker.Lock(key)
defer s.layerCreateLocker.Unlock(key)
diffIDs, err := s.GetDiffIDs(ctx, key)
Method Reader.testTail
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tr Reader) testTail(t *testing.T, live bool) {
t.Parallel()
factory := tr.Factory(t, logger.Info{
ContainerID: "tailtest0000",
ContainerName: "logtail",
Method layerStore.registerWithDescriptor
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, descriptor distribution.Descriptor) (Layer, error) {
// cErr is used to hold the error which will always trigger
// cleanup of creates sources but may not be an error returned
// to the caller (already exists).
var cErr error
Method windowsParser.validateMountConfigReg
has 20 return statements (exceeds 4 allowed). Open
func (p *windowsParser) validateMountConfigReg(mnt *mount.Mount, additionalValidators ...mountValidator) error {
if len(mnt.Target) == 0 {
return &errMountConfig{mnt, errMissingField("Target")}
}
for _, v := range additionalValidators {
Function UnpackLayer
has 20 return statements (exceeds 4 allowed). Open
func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, err error) {
tr := tar.NewReader(layer)
trBuf := pools.BufioReader32KPool.Get(tr)
defer pools.BufioReader32KPool.Put(trBuf)
Method Daemon.containerAttach
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (daemon *Daemon) containerAttach(c *container.Container, cfg *stream.AttachConfig, logs, doStream bool) error {
if logs {
logDriver, logCreated, err := daemon.getLogger(c)
if err != nil {
return err
Method containerAdapter.pullImage
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *containerAdapter) pullImage(ctx context.Context) error {
spec := c.container.spec()
// Skip pulling if the image is referenced by image ID.
if _, err := digest.Parse(spec.Image); err == nil {
Function buildCreateEndpointOptions
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
var createOptions []libnetwork.EndpointOption
genericOptions := make(options.Generic)
nwName := n.Name()
Function StdCopy
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) {
var (
buf = make([]byte, startingBufLen)
bufLen = len(buf)
nr, nw int