Showing 1,468 of 1,914 total issues
Function getConflictFreeConfiguration
has 7 return statements (exceeds 4 allowed). Open
Open
func getConflictFreeConfiguration(configFile string, flags *pflag.FlagSet) (*Config, error) {
b, err := os.ReadFile(configFile)
if err != nil {
return nil, err
}
Avoid deeply nested control flow statements. Open
Open
if err := os.RemoveAll(path); err != nil {
return 0, err
}
Function CompareKernelVersion
has 7 return statements (exceeds 4 allowed). Open
Open
func CompareKernelVersion(a, b VersionInfo) int {
if a.Kernel < b.Kernel {
return -1
} else if a.Kernel > b.Kernel {
return 1
Function Parse
has 7 return statements (exceeds 4 allowed). Open
Open
func Parse(filePath string, objName string) (*ParsedPkg, error) {
fs := token.NewFileSet()
pkg, err := parser.ParseFile(fs, filePath, nil, parser.AllErrors)
if err != nil {
return nil, err
Avoid deeply nested control flow statements. Open
Open
if _, err := io.Copy(ts.writer, ts.bufTar); err != nil {
return 0, err
}
Function StdCopy
has 7 return statements (exceeds 4 allowed). Open
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
Avoid deeply nested control flow statements. Open
Open
for key, val in task.items():
if isinstance(val, dict):
for k, v in val.items():
entries.append(v)
else:
Method Client.callWithRetry
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool, reqOpts ...func(*RequestOpts)) (io.ReadCloser, error) {
var retries int
start := time.Now()
var opts RequestOpts
Avoid deeply nested control flow statements. Open
Open
if os.IsNotExist(err) {
err = nil // parent was deleted
}
Function mkdirAs
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting bool) error {
path, err := filepath.Abs(path)
if err != nil {
return err
}
- 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
Avoid deeply nested control flow statements. Open
Open
if err := ts.writer.Close(); err != nil {
return 0, err
}
Function AddNamespaceRangesUser
has 7 return statements (exceeds 4 allowed). Open
Open
func AddNamespaceRangesUser(name string) (int, int, error) {
if err := addUser(name); err != nil {
return -1, -1, fmt.Errorf("error adding user %q: %v", name, err)
}
Avoid deeply nested control flow statements. Open
Open
if err := ts.tarW.Close(); err != nil {
return 0, err
}
Avoid deeply nested control flow statements. Open
Open
if aufsTempdir, err = os.MkdirTemp(dest, "dockerplnk"); err != nil {
return 0, err
}
Function PrepareQuotaTestImage
has 7 return statements (exceeds 4 allowed). Open
Open
func PrepareQuotaTestImage(t *testing.T) (string, error) {
// imageSize is the size of the test-image. The minimum size allowed
// is 300MB.
//
// See https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/commit/?id=6e0ed3d19c54603f0f7d628ea04b550151d8a262
Function createSubordinateRanges
has 7 return statements (exceeds 4 allowed). Open
Open
func createSubordinateRanges(name string) error {
// first, we should verify that ranges weren't automatically created
// by the distro tooling
ranges, err := parseSubuid(name)
if err != nil {
Method puller.pullRepository
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *puller) pullRepository(ctx context.Context, ref reference.Named) (err error) {
var layersDownloaded bool
if !reference.IsNameOnly(ref) {
layersDownloaded, err = p.pullTag(ctx, ref, p.config.Platform)
if err != nil {
Method Manager.Remove
has 6 return statements (exceeds 4 allowed). Open
Open
func (pm *Manager) Remove(name string, config *backend.PluginRmConfig) error {
p, err := pm.config.Store.GetV2Plugin(name)
pm.mu.RLock()
c := pm.cMap[p]
pm.mu.RUnlock()
Function checkValidParent
has 6 return statements (exceeds 4 allowed). Open
Open
func checkValidParent(img, parent *image.Image) bool {
if len(img.History) == 0 && len(parent.History) == 0 {
return true // having history is not mandatory
}
if len(img.History)-len(parent.History) != 1 {
Consider simplifying this complex logical expression. Open
Open
if p.OS == "" && p.Architecture == "" && p.Variant == "" && p.OSVersion == "" && p.OSFeatures == nil && p.Features == nil {