Showing 1,468 of 1,914 total issues
Method ImageService.GetImageAndReleasableLayer
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
if refOrID == "" { // FROM scratch
if runtime.GOOS == "windows" {
return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
}
- 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.setWindowsCredentialSpec
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) setWindowsCredentialSpec(c *container.Container, s *specs.Spec) error {
if c.HostConfig == nil || c.HostConfig.SecurityOpt == nil {
return 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.fillRootlessVersion
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
if !rootless.RunningWithRootlessKit() {
return nil
}
rlc, err := getRootlessKitClient()
- 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 driver.NetworkAllocate
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
if id == "" {
return nil, fmt.Errorf("invalid network id for overlay network")
}
Method driver.createNetwork
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *driver) createNetwork(config *configuration) (bool, error) {
foundExisting := false
networkList := d.getNetworks()
for _, nw := range networkList {
if config.Parent == nw.config.Parent {
Method driver.Join
has 60 lines of code (exceeds 50 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,
Method Resolver.forwardExtDNS
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *Resolver) forwardExtDNS(ctx context.Context, proto string, remoteAddr net.Addr, query *dns.Msg) *dns.Msg {
ctx, span := otel.Tracer("").Start(ctx, "resolver.forwardExtDNS")
defer span.End()
proxyDNS := r.proxyDNS.Load()
Method controller.Logs
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *controller) Logs(ctx context.Context, publisher exec.LogPublisher, options api.LogSubscriptionOptions) error {
if err := r.checkClosed(); err != nil {
return err
}
Method Info.ExtraAttributes
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (info *Info) ExtraAttributes(keyMod func(string) string) (map[string]string, error) {
extra := make(map[string]string)
labels, ok := info.Config["labels"]
if ok && len(labels) > 0 {
for _, l := range strings.Split(labels, ",") {
Method layerStore.CreateRWLayer
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ls *layerStore) CreateRWLayer(name string, parent ChainID, opts *CreateRWLayerOpts) (_ RWLayer, err error) {
var (
storageOpt map[string]string
initFunc MountInit
mountLabel string
Function ensureHTTPServerImage
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ensureHTTPServerImage(t testing.TB) {
t.Helper()
var doIt bool
ensureHTTPServerOnce.Do(func() {
doIt = true
Method puller.pullSchema1
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *puller) pullSchema1(ctx context.Context, ref reference.Reference, unverifiedManifest *schema1.SignedManifest, platform *ocispec.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) {
if platform != nil {
// Early bath if the requested OS doesn't match that of the configuration.
// This avoids doing the download, only to potentially fail later.
if err := image.CheckOS(platform.OS); err != nil {
Function toRootless
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func toRootless(spec *specs.Spec, v2Controllers []string, currentOOMScoreAdj int) error {
if len(v2Controllers) == 0 {
if spec.Linux != nil {
// Remove cgroup settings.
spec.Linux.Resources = nil
Function fetchTable
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func fetchTable(ip string, port int, network, tableName string, clusterPeers, networkPeers map[string]string, remediate bool) {
log.G(context.TODO()).Infof("Fetch %s table and check owners", tableName)
resp, err := http.Get(fmt.Sprintf(dumpTable, ip, port, network, tableName))
if err != nil {
log.G(context.TODO()).WithError(err).Fatalf("Failed fetching endpoint table")
Method driver.parseNetworkOptions
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string) (*networkConfiguration, error) {
config := &networkConfiguration{Type: d.name}
for label, value := range genericOptions {
switch label {
Function JobComplete
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func JobComplete(ctx context.Context, client client.CommonAPIClient, service swarmtypes.Service) func(log poll.LogT) poll.Result {
filter := filters.NewArgs(filters.Arg("service", service.ID))
var jobIteration swarmtypes.Version
if service.JobStatus != nil {
Function WithDevices
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func WithDevices(daemon *Daemon, c *container.Container) coci.SpecOpts {
return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
// Build lists of devices allowed and created within the container.
var devs []specs.LinuxDevice
devPermissions := s.Linux.Resources.Devices
Function TaskFromGRPC
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TaskFromGRPC(t swarmapi.Task) (types.Task, error) {
containerStatus := t.Status.GetContainer()
taskSpec, err := taskSpecFromGRPC(t.Spec)
if err != nil {
return types.Task{}, err
Function buildIPAMResources
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func buildIPAMResources(nw *libnetwork.Network) networktypes.IPAM {
var ipamConfig []networktypes.IPAMConfig
ipamDriver, ipamOptions, ipv4Conf, ipv6Conf := nw.IpamConfig()
Function buildPortsRelatedCreateEndpointOptions
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func buildPortsRelatedCreateEndpointOptions(c *container.Container, n *libnetwork.Network, sb *libnetwork.Sandbox) ([]libnetwork.EndpointOption, error) {
// Port-mapping rules belong to the container & applicable only to non-internal networks.
//
// TODO(thaJeztah): Look if we can provide a more minimal function for getPortMapInfo, as it does a lot, and we only need the "length".
if n.Internal() || len(getPortMapInfo(sb)) > 0 {