Showing 1,885 of 1,885 total issues
Method Provider.NewAllocator
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Provider) NewAllocator(netConfig *networkallocator.Config) (networkallocator.NetworkAllocator, error) {
na := &cnmNetworkAllocator{
networks: make(map[string]*network),
services: make(map[string]struct{}),
tasks: make(map[string]struct{}),
Method v1Endpoint.ping
has 5 return statements (exceeds 4 allowed). Open
Open
func (e *v1Endpoint) ping() (v1PingResult, error) {
if e.String() == IndexServer {
// Skip the check, we know this one is valid
// (and we never want to fallback to http in case of error)
return v1PingResult{}, nil
Method Client.ContainerWait
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) {
resultC := make(chan container.WaitResponse)
errC := make(chan error, 1)
// Make sure we negotiated (if the client is configured to do so),
Method Client.NetworksPrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) {
var report network.PruneReport
if err := cli.NewVersionError(ctx, "1.25", "network prune"); err != nil {
return report, err
Function ConvertPortBindings
has 5 return statements (exceeds 4 allowed). Open
Open
func ConvertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) {
var pbs []json.RawMessage
// Enumerate through the port bindings specified by the user and convert
// them into the internal structure matching the JSON blob that can be
Method Client.PluginUpgrade
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (rc io.ReadCloser, err error) {
if err := cli.NewVersionError(ctx, "1.26", "plugin upgrade"); err != nil {
return nil, err
}
query := url.Values{}
Function Exec
has 5 return statements (exceeds 4 allowed). Open
Open
func Exec(ctx context.Context, apiClient client.APIClient, id string, cmd []string, ops ...func(*container.ExecOptions)) (ExecResult, error) {
// prepare exec
execOptions := container.ExecOptions{
AttachStdout: true,
AttachStderr: true,
Function newDaemonCommand
has 5 return statements (exceeds 4 allowed). Open
Open
func newDaemonCommand() (*cobra.Command, error) {
// FIXME(thaJeztah): config.New also looks up default binary-path, but this code is also executed when running "--version".
cfg, err := config.New()
if err != nil {
return nil, err
Method serviceConfig.loadInsecureRegistries
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (config *serviceConfig) loadInsecureRegistries(registries []string) error {
// Localhost is by default considered as an insecure registry. This is a
// stop-gap for people who are running a private registry on localhost.
registries = append(registries, "127.0.0.0/8")
- 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 Client.ContainersPrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error) {
var report container.PruneReport
if err := cli.NewVersionError(ctx, "1.25", "container prune"); err != nil {
return report, err
Function ValidateMirror
has 5 return statements (exceeds 4 allowed). Open
Open
func ValidateMirror(val string) (string, error) {
uri, err := url.Parse(val)
if err != nil {
return "", invalidParamWrapf(err, "invalid mirror: %q is not a valid URI", val)
}
Method driver.Join
has 5 return statements (exceeds 4 allowed). 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, fmt.Sprintf("libnetwork.drivers.windows_%s.Join", d.name), trace.WithAttributes(
attribute.String("nid", nid),
attribute.String("eid", eid),
attribute.String("sboxKey", sboxKey)))
Method cnmNetworkAllocator.Allocate
has 5 return statements (exceeds 4 allowed). Open
Open
func (na *cnmNetworkAllocator) Allocate(n *api.Network) error {
if _, ok := na.networks[n.ID]; ok {
return fmt.Errorf("network %s already allocated", n.ID)
}
Method authTransport.RoundTrip
has 5 return statements (exceeds 4 allowed). Open
Open
func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) {
// Authorization should not be set on 302 redirect for untrusted locations.
// This logic mirrors the behavior in addRequiredHeadersToRedirectedRequests.
// As the authorization logic is currently implemented in RoundTrip,
// a 302 redirect is detected by looking at the Referrer header as go http package adds said header.
Method Client.ContainerCreate
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) {
var response container.CreateResponse
// Make sure we negotiated (if the client is configured to do so),
// as code below contains API-version specific handling of options.
- 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 VolumeStore.restore
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *VolumeStore) restore() {
var ls []volumeMetadata
s.db.View(func(tx *bolt.Tx) error {
ls = listMeta(tx)
return nil
Method driver.peerDelete
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error {
log.G(context.TODO()).Infof("WINOVERLAY: Enter peerDelete for endpoint %s and peer ip %s", eid, peerIP.String())
if err := validateID(nid, eid); err != nil {
return err
Method Sandbox.setupDefaultGW
has 5 return statements (exceeds 4 allowed). Open
Open
func (sb *Sandbox) setupDefaultGW() error {
// check if the container already has a GW endpoint
if ep := sb.getEndpointInGWNetwork(); ep != nil {
return nil
}
Method cnmNetworkAllocator.AllocateService
has 5 return statements (exceeds 4 allowed). Open
Open
func (na *cnmNetworkAllocator) AllocateService(s *api.Service) (err error) {
defer func() {
if err != nil {
na.DeallocateService(s)
}
Method Client.ImagesPrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (image.PruneReport, error) {
var report image.PruneReport
if err := cli.NewVersionError(ctx, "1.25", "image prune"); err != nil {
return report, err