Showing 615 of 900 total issues

Function GetCustomTagsMetadata has 5 return statements (exceeds 4 allowed).
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)
    }
Severity: Major
Found in pkg/cleaning/stage_manager/manager.go - About 35 mins to fix

    Method StorageManager.CopySuitableByDigestStage has 5 return statements (exceeds 4 allowed).
    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 {
    Severity: Major
    Found in pkg/storage/manager/storage_manager.go - About 35 mins to fix

      Method BundleArchiveFileReader.ReadImageArchive has 5 return statements (exceeds 4 allowed).
      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)
      Severity: Major
      Found in pkg/deploy/bundles/bundle_archive_reader.go - About 35 mins to fix

        Function doRequest has 5 return statements (exceeds 4 allowed).
        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
            }
        Severity: Major
        Found in pkg/docker_registry/common_api.go - About 35 mins to fix

          Function GetRequiredSecretKey has 5 return statements (exceeds 4 allowed).
          Open

          func GetRequiredSecretKey(workingDir string) ([]byte, error) {
              var secretKey []byte
              var werfSecretKeyPaths []string
              var notFoundIn []string
          
          
          Severity: Major
          Found in pkg/deploy/secrets_manager/secret_key.go - About 35 mins to fix

            Method api.PullImageArchive has 5 return statements (exceeds 4 allowed).
            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)
                }
            Severity: Major
            Found in pkg/docker_registry/api.go - About 35 mins to fix

              Method KubernetesStagesStorageCache.GetStagesByDigest has 5 return statements (exceeds 4 allowed).
              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
              Severity: Major
              Found in pkg/storage/kubernetes_stages_storage_cache.go - About 35 mins to fix

                Method cleanupManager.deleteUnusedCustomTags has 5 return statements (exceeds 4 allowed).
                Open

                func (m *cleanupManager) deleteUnusedCustomTags(ctx context.Context) error {
                    stageIDCustomTagList := m.stageManager.GetCustomTagsMetadata()
                    if len(stageIDCustomTagList) == 0 {
                        return nil
                    }
                Severity: Major
                Found in pkg/cleaning/cleanup.go - About 35 mins to fix

                  Function getDigestAndUniqueIDFromRepoStageImageTag has 5 return statements (exceeds 4 allowed).
                  Open

                  func getDigestAndUniqueIDFromRepoStageImageTag(repoStageImageTag string) (string, int64, error) {
                      parts := strings.SplitN(repoStageImageTag, "-", 2)
                  
                      if len(parts) == 1 {
                          if len(parts[0]) != 56 {
                  Severity: Major
                  Found in pkg/storage/repo_stages_storage.go - About 35 mins to fix

                    Method SecretsManager.GetYamlEncoder has 5 return statements (exceeds 4 allowed).
                    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
                        }
                    Severity: Major
                    Found in pkg/deploy/secrets_manager/secret_manager.go - About 35 mins to fix

                      Function detectImplementation has 5 return statements (exceeds 4 allowed).
                      Open

                      func detectImplementation(accountOrRepositoryAddress string) (string, error) {
                          var parsedResource authn.Resource
                          var err error
                      
                          parts := strings.SplitN(accountOrRepositoryAddress, "/", 2)
                      Severity: Major
                      Found in pkg/docker_registry/docker_registry.go - About 35 mins to fix

                        Function parsePrivateSSHKey has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                        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)
                            }
                        Severity: Minor
                        Found in pkg/ssh_agent/ssh_agent.go - About 35 mins to fix

                        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

                        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)
                            }
                        Severity: Major
                        Found in pkg/ssh_agent/ssh_agent.go - About 35 mins to fix

                          Method Copy.Apply has 5 return statements (exceeds 4 allowed).
                          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)
                          Severity: Major
                          Found in pkg/container_backend/instruction/copy.go - About 35 mins to fix

                            Function RemovePathWithEmptyParentDirsInsideScope has 5 return statements (exceeds 4 allowed).
                            Open

                            func RemovePathWithEmptyParentDirsInsideScope(scopeDir, path string) error {
                                if !util.IsSubpathOfBasePath(scopeDir, path) {
                                    return nil
                                }
                            
                            
                            Severity: Major
                            Found in pkg/git_repo/gitdata/gc.go - About 35 mins to fix

                              Method harbor.GetRepoImage has 5 return statements (exceeds 4 allowed).
                              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)
                              Severity: Major
                              Found in pkg/docker_registry/harbor.go - About 35 mins to fix

                                Method Local.validateStatusResultSubmodules has 5 return statements (exceeds 4 allowed).
                                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
                                    }
                                Severity: Major
                                Found in pkg/git_repo/local.go - About 35 mins to fix

                                  Function revertExcludedChangesInServiceWorktreeIndex has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func revertExcludedChangesInServiceWorktreeIndex(ctx context.Context, sourceWorktreeDir, serviceWorktreeDir, sourceCommit, serviceBranchHeadCommit string, globExcludeList []string) (bool, error) {
                                      if len(globExcludeList) == 0 || serviceBranchHeadCommit == sourceCommit {
                                          return false, nil
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in pkg/true_git/service_branch.go - About 35 mins to fix

                                    Function HashContentsAndPathsRecurse has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func HashContentsAndPathsRecurse(path string) (string, error) {
                                        path = filepath.Clean(path)
                                    
                                        fi, err := os.Stat(path)
                                        if err != nil {
                                    Severity: Major
                                    Found in pkg/util/hashsum.go - About 35 mins to fix

                                      Method excludePathMatcher.shouldGoThrough has 5 return statements (exceeds 4 allowed).
                                      Open

                                      func (m excludePathMatcher) shouldGoThrough(path string) bool {
                                          if len(m.excludeGlobs) == 0 {
                                              return false
                                          }
                                      
                                      
                                      Severity: Major
                                      Found in pkg/path_matcher/exclude.go - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language