Showing 615 of 900 total issues
Function GetCustomTagsMetadata
has 5 return statements (exceeds 4 allowed). Open
Open
func GetCustomTagsMetadata(ctx context.Context, storageManager manager.StorageManagerInterface) (map[string][]string, error) {
stageCustomTagMetadataIDs, err := storageManager.GetStagesStorage().GetStageCustomTagMetadataIDs(ctx, storage.WithCache())
if err != nil {
return nil, fmt.Errorf("unable to get stage custom tag metadata IDs: %w", err)
}
Method StorageManager.CopySuitableByDigestStage
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *StorageManager) CopySuitableByDigestStage(ctx context.Context, stageDesc *image.StageDescription, sourceStagesStorage, destinationStagesStorage storage.StagesStorage, containerBackend container_backend.ContainerBackend, targetPlatform string) (*image.StageDescription, error) {
img := container_backend.NewLegacyStageImage(nil, stageDesc.Info.Name, containerBackend, targetPlatform)
logboek.Context(ctx).Info().LogF("Fetching %s\n", img.Name())
if err := sourceStagesStorage.FetchImage(ctx, img); err != nil {
Method BundleArchiveFileReader.ReadImageArchive
has 5 return statements (exceeds 4 allowed). Open
Open
func (reader *BundleArchiveFileReader) ReadImageArchive(imageTag string) (*ImageArchiveReadCloser, error) {
treader, closer, err := reader.openForReading()
if err != nil {
defer closer()
return nil, fmt.Errorf("unable to open bundle archive: %w", err)
Function doRequest
has 5 return statements (exceeds 4 allowed). Open
Open
func doRequest(ctx context.Context, client *http.Client, method, url string, body io.Reader, options doRequestOptions) (*http.Response, []byte, error) {
req, err := http.NewRequestWithContext(ctx, method, url, body)
if err != nil {
return nil, nil, err
}
Function GetRequiredSecretKey
has 5 return statements (exceeds 4 allowed). Open
Open
func GetRequiredSecretKey(workingDir string) ([]byte, error) {
var secretKey []byte
var werfSecretKeyPaths []string
var notFoundIn []string
Method api.PullImageArchive
has 5 return statements (exceeds 4 allowed). Open
Open
func (api *api) PullImageArchive(ctx context.Context, archiveWriter io.Writer, reference string) error {
ref, err := name.ParseReference(reference, api.parseReferenceOptions()...)
if err != nil {
return fmt.Errorf("unable to parse reference %q: %w", reference, err)
}
Method KubernetesStagesStorageCache.GetStagesByDigest
has 5 return statements (exceeds 4 allowed). Open
Open
func (cache *KubernetesStagesStorageCache) GetStagesByDigest(ctx context.Context, projectName, digest string) (bool, []image.StageID, error) {
if obj, err := kubeutils.GetOrCreateConfigMapWithNamespaceIfNotExists(cache.KubeClient, cache.Namespace, cache.GetConfigMapNameFunc(projectName)); err != nil {
return false, nil, err
} else if cacheData, err := cache.extractCacheData(ctx, obj); err != nil {
return false, nil, err
Method cleanupManager.deleteUnusedCustomTags
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *cleanupManager) deleteUnusedCustomTags(ctx context.Context) error {
stageIDCustomTagList := m.stageManager.GetCustomTagsMetadata()
if len(stageIDCustomTagList) == 0 {
return nil
}
Function getDigestAndUniqueIDFromRepoStageImageTag
has 5 return statements (exceeds 4 allowed). Open
Open
func getDigestAndUniqueIDFromRepoStageImageTag(repoStageImageTag string) (string, int64, error) {
parts := strings.SplitN(repoStageImageTag, "-", 2)
if len(parts) == 1 {
if len(parts[0]) != 56 {
Method SecretsManager.GetYamlEncoder
has 5 return statements (exceeds 4 allowed). Open
Open
func (manager *SecretsManager) GetYamlEncoder(ctx context.Context, workingDir string) (*secret.YamlEncoder, error) {
if manager.DisableSecretsDecryption {
logboek.Context(ctx).Default().LogLnDetails("Secrets decryption disabled")
return secret.NewYamlEncoder(nil), nil
}
Function detectImplementation
has 5 return statements (exceeds 4 allowed). Open
Open
func detectImplementation(accountOrRepositoryAddress string) (string, error) {
var parsedResource authn.Resource
var err error
parts := strings.SplitN(accountOrRepositoryAddress, "/", 2)
Function parsePrivateSSHKey
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func parsePrivateSSHKey(cfg sshKeyConfig) (sshKey, error) {
keyData, err := ioutil.ReadFile(cfg.FilePath)
if err != nil {
return sshKey{}, fmt.Errorf("error reading key file %q: %w", cfg.FilePath, 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
Function parsePrivateSSHKey
has 5 return statements (exceeds 4 allowed). Open
Open
func parsePrivateSSHKey(cfg sshKeyConfig) (sshKey, error) {
keyData, err := ioutil.ReadFile(cfg.FilePath)
if err != nil {
return sshKey{}, fmt.Errorf("error reading key file %q: %w", cfg.FilePath, err)
}
Method Copy.Apply
has 5 return statements (exceeds 4 allowed). Open
Open
func (i *Copy) Apply(ctx context.Context, containerName string, drv buildah.Buildah, drvOpts buildah.CommonOpts, buildContextArchive container_backend.BuildContextArchiver) error {
var contextDir string
if i.UsesBuildContext() {
var err error
contextDir, err = buildContextArchive.ExtractOrGetExtractedDir(ctx)
Function RemovePathWithEmptyParentDirsInsideScope
has 5 return statements (exceeds 4 allowed). Open
Open
func RemovePathWithEmptyParentDirsInsideScope(scopeDir, path string) error {
if !util.IsSubpathOfBasePath(scopeDir, path) {
return nil
}
Method harbor.GetRepoImage
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *harbor) GetRepoImage(ctx context.Context, reference string) (*image.Info, error) {
var info *image.Info
operation := func() error {
var err error
info, err = r.api.GetRepoImage(ctx, reference)
Method Local.validateStatusResultSubmodules
has 5 return statements (exceeds 4 allowed). Open
Open
func (repo *Local) validateStatusResultSubmodules(_ context.Context, pathMatcher path_matcher.PathMatcher, scope status.Scope) error {
// No changes related to submodules.
if len(scope.Submodules()) == 0 {
return nil
}
Function revertExcludedChangesInServiceWorktreeIndex
has 5 return statements (exceeds 4 allowed). Open
Open
func revertExcludedChangesInServiceWorktreeIndex(ctx context.Context, sourceWorktreeDir, serviceWorktreeDir, sourceCommit, serviceBranchHeadCommit string, globExcludeList []string) (bool, error) {
if len(globExcludeList) == 0 || serviceBranchHeadCommit == sourceCommit {
return false, nil
}
Function HashContentsAndPathsRecurse
has 5 return statements (exceeds 4 allowed). Open
Open
func HashContentsAndPathsRecurse(path string) (string, error) {
path = filepath.Clean(path)
fi, err := os.Stat(path)
if err != nil {
Method excludePathMatcher.shouldGoThrough
has 5 return statements (exceeds 4 allowed). Open
Open
func (m excludePathMatcher) shouldGoThrough(path string) bool {
if len(m.excludeGlobs) == 0 {
return false
}