Showing 1,468 of 1,914 total issues
Function loginV2
has 5 return statements (exceeds 4 allowed). Open
Open
func loginV2(authConfig *registry.AuthConfig, endpoint APIEndpoint, userAgent string) (string, string, error) {
var (
endpointStr = strings.TrimRight(endpoint.URL.String(), "/") + "/v2/"
modifiers = Headers(userAgent, nil)
authTransport = transport.NewTransport(newTransport(endpoint.TLSConfig), modifiers...)
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
Function setupInternalNetworkRules
has 5 return statements (exceeds 4 allowed). Open
Open
func setupInternalNetworkRules(bridgeIface string, addr *net.IPNet, icc, insert bool) error {
var version iptables.IPVersion
var inDropRule, outDropRule iptRule
// Either add or remove the interface from the firewalld zone, if firewalld is running.
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 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, "libnetwork.drivers.windows_overlay.Join", trace.WithAttributes(
attribute.String("nid", nid),
attribute.String("eid", eid),
attribute.String("sboxKey", sboxKey)))
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.DeleteEndpoint
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) DeleteEndpoint(nid, eid string) error {
if err := validateID(nid, eid); err != nil {
return err
}
Method driver.CreateEndpoint
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
if err := validateID(nid, eid); err != nil {
return err
}
n, err := d.getNetwork(nid)
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.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
Function NewClientWithOpts
has 5 return statements (exceeds 4 allowed). Open
Open
func NewClientWithOpts(ops ...Opt) (*Client, error) {
hostURL, err := ParseHostURL(DefaultDockerHost)
if err != nil {
return nil, err
}
Method windowsParser.ParseVolumesFrom
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *windowsParser) ParseVolumesFrom(spec string) (string, string, error) {
if len(spec) == 0 {
return "", "", fmt.Errorf("volumes-from specification cannot be an empty string")
}
Method Service.lookupV2Endpoints
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, err error) {
ana := s.config.allowNondistributableArtifacts(hostname)
if hostname == DefaultNamespace || hostname == IndexHostname {
for _, mirror := range s.config.Mirrors {
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) {
if err := cli.NewVersionError(ctx, "1.25", "container prune"); err != nil {
return container.PruneReport{}, err
}
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) {
if err := cli.NewVersionError(ctx, "1.25", "image prune"); err != nil {
return image.PruneReport{}, err
}
Method Service.Auth
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, userAgent string) (status, token string, err error) {
// TODO Use ctx when searching for repositories
registryHostName := IndexHostname
if authConfig.ServerAddress != "" {
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 lazySource.Hash
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *lazySource) Hash(path string) (string, error) {
cleanPath, fullPath, err := normalize(path, c.root)
if err != nil {
return "", err
}
Method Worker.ResolveSourceMetadata
has 5 return statements (exceeds 4 allowed). Open
Open
func (w *Worker) ResolveSourceMetadata(ctx context.Context, op *pb.SourceOp, opt sourceresolver.Opt, sm *session.Manager, g session.Group) (*sourceresolver.MetaResponse, error) {
if opt.SourcePolicies != nil {
return nil, errors.New("source policies can not be set for worker")
}
Method Container.StatPath
has 5 return statements (exceeds 4 allowed). Open
Open
func (container *Container) StatPath(resolvedPath, absPath string) (stat *containertypes.PathStat, err error) {
if container.BaseFS == "" {
return nil, errors.New("StatPath: BaseFS of container " + container.ID + " is unexpectedly empty")
}