Showing 1,468 of 1,914 total issues
Method tarexporter.legacyLoad
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (l *tarexporter) legacyLoad(tmpDir string, outStream io.Writer, progressOutput progress.Output) error {
if runtime.GOOS == "windows" {
return errors.New("Windows does not support legacy loading of images")
}
- 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 newRepository
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ctx context.Context, repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint,
metaHeaders http.Header, authConfig *registrytypes.AuthConfig, actions ...string,
Method manifestStore.getLocal
has 7 return statements (exceeds 4 allowed). Open
Open
func (m *manifestStore) getLocal(ctx context.Context, desc ocispec.Descriptor, ref reference.Named) (distribution.Manifest, error) {
ra, err := m.local.ReaderAt(ctx, desc)
if err != nil {
return nil, errors.Wrap(err, "error getting content store reader")
}
Function EnsureRemoveAll
has 7 return statements (exceeds 4 allowed). Open
Open
func EnsureRemoveAll(dir string) error {
notExistErr := make(map[string]bool)
// track retries
exitOnErr := make(map[string]int)
Method Manager.Pull
has 7 return statements (exceeds 4 allowed). Open
Open
func (pm *Manager) Pull(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer, opts ...CreateOpt) (err error) {
pm.muGC.RLock()
defer pm.muGC.RUnlock()
// revalidate because Pull is public
Method store.restore
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (is *store) restore() error {
// As the code below is run when restoring all images (which can be "many"),
// constructing the "log.G(ctx).WithFields" is deliberately not "DRY", as the
// logger is only used for error-cases, and we don't want to do allocations
// if we don't need it. The "f" type alias is here is just for convenience,
- 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 KernelVersion.UnmarshalJSON
has 7 return statements (exceeds 4 allowed). Open
Open
func (k *KernelVersion) UnmarshalJSON(version []byte) error {
var (
ver string
err error
)
Method Store.resolvePluginID
has 7 return statements (exceeds 4 allowed). Open
Open
func (ps *Store) resolvePluginID(idOrName string) (string, error) {
if validFullID.MatchString(idOrName) {
return idOrName, nil
}
Function kubernetesSafeOpen
has 7 return statements (exceeds 4 allowed). Open
Open
func kubernetesSafeOpen(base, subpath string) (int, error) {
// syscall.Openat flags used to traverse directories not following symlinks
const nofollowFlags = unix.O_RDONLY | unix.O_NOFOLLOW
// flags for getting file descriptor without following the symlink
const openFDFlags = unix.O_NOFOLLOW | unix.O_PATH
Function evaluatePath
has 7 return statements (exceeds 4 allowed). Open
Open
func evaluatePath(path, subpath string) (resolvedBasePath string, resolvedSubpath string, err error) {
baseResolved, err := filepath.EvalSymlinks(path)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return "", "", &ErrNotAccessible{Path: path, Cause: err}
Function isHostNS
has 7 return statements (exceeds 4 allowed). Open
Open
func isHostNS(spec *specs.Spec, nsType specs.LinuxNamespaceType) (bool, error) {
if strings.Contains(string(nsType), string(os.PathSeparator)) {
return false, fmt.Errorf("unexpected namespace type %q", nsType)
}
if spec.Linux == nil {
Function splitConfigRootFSFromTar
has 7 return statements (exceeds 4 allowed). Open
Open
func splitConfigRootFSFromTar(in io.ReadCloser, config *[]byte) io.ReadCloser {
pr, pw := io.Pipe()
go func() {
tarReader := tar.NewReader(in)
tarWriter := tar.NewWriter(pw)
Avoid deeply nested control flow statements. Open
Open
} else if len(output) != 0 {
return fmt.Errorf("could not delete establish rule from %s: %s", c.Table, output)
}
Method Controller.addEndpointNameResolution
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *Controller) addEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, addService bool, method string) error {
Method Controller.NewSandbox
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *Controller) NewSandbox(ctx context.Context, containerID string, options ...SandboxOption) (_ *Sandbox, retErr error) {
if containerID == "" {
return nil, types.InvalidParameterErrorf("invalid container ID")
}
Function NewAllocator
has 7 return statements (exceeds 4 allowed). Open
Open
func NewAllocator(lcAs, glAs []*ipamutils.NetworkToSplit) (*Allocator, error) {
var (
a Allocator
err error
lcAs4, lcAs6, glAs4, glAs6 []*ipamutils.NetworkToSplit
Method Controller.handleEpTableEvent
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *Controller) handleEpTableEvent(ev events.Event) {
var (
nid string
eid string
value []byte
Method PortAllocator.RequestPortsInRange
has 7 return statements (exceeds 4 allowed). Open
Open
func (p *PortAllocator) RequestPortsInRange(ips []net.IP, proto string, portStart, portEnd int) (int, error) {
if proto != "tcp" && proto != "udp" && proto != "sctp" {
return 0, ErrUnknownProtocol
}
Method Controller.addServiceBinding
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *Controller) addServiceBinding(svcName, svcID, nID, eID, containerName string, vip net.IP, ingressPorts []*PortConfig, serviceAliases, taskAliases []string, ip net.IP, method string) error {
Avoid deeply nested control flow statements. Open
Open
} else if len(output) != 0 {
return fmt.Errorf("could not delete linking rule from %s/%s: %s", c.Table, c.Name, output)
}