Showing 900 of 900 total issues

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

                            Method dockerHubApi.getToken has 5 return statements (exceeds 4 allowed).
                            Open

                            func (api *dockerHubApi) getToken(ctx context.Context, username, password string) (string, *http.Response, error) {
                                url := "https://hub.docker.com/v2/users/login/"
                                body, err := json.Marshal(map[string]string{
                                    "username": username,
                                    "password": password,
                            Severity: Major
                            Found in pkg/docker_registry/docker_hub_api.go - About 35 mins to fix

                              Method Result.walkWithResult has 5 return statements (exceeds 4 allowed).
                              Open

                              func (r *Result) walkWithResult(f func(r *Result, sr *SubmoduleResult, lsTreeEntry *LsTreeEntry) error) error {
                                  if err := r.lsTreeEntriesWalkWithResult(f); err != nil {
                                      return err
                                  }
                              
                              
                              Severity: Major
                              Found in pkg/true_git/ls_tree/result.go - About 35 mins to fix

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

                                func (m includePathMatcher) shouldGoThrough(path string) bool {
                                    if len(m.includeGlobs) == 0 {
                                        return false
                                    }
                                
                                
                                Severity: Major
                                Found in pkg/path_matcher/include.go - About 35 mins to fix

                                  Method NativeBuildah.Pull has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (b *NativeBuildah) Pull(ctx context.Context, ref string, opts PullOpts) error {
                                      sysCtx, err := b.getSystemContext(opts.TargetPlatform)
                                      if err != nil {
                                          return err
                                      }
                                  Severity: Major
                                  Found in pkg/buildah/native_linux.go - About 35 mins to fix

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

                                    func NewConfig(ctx context.Context, fileReader fileReader, configRelPath string) (c Config, err error) {
                                        exist, err := fileReader.IsGiterminismConfigExistAnywhere(ctx, configRelPath)
                                        if err != nil {
                                            return c, err
                                        }
                                    Severity: Major
                                    Found in pkg/giterminism_manager/config/config.go - About 35 mins to fix

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

                                      func runSSHAgent(ctx context.Context) (string, error) {
                                          sockPath := filepath.Join(werf.GetTmpDir(), "werf-ssh-agent", uuid.NewString())
                                          tmpSockPath = sockPath
                                      
                                          err := os.MkdirAll(filepath.Dir(sockPath), os.ModePerm)
                                      Severity: Major
                                      Found in pkg/ssh_agent/ssh_agent.go - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language