Showing 614 of 901 total issues

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 Local.Unshallow has 5 return statements (exceeds 4 allowed).
    Open

    func (repo *Local) Unshallow(ctx context.Context) error {
        if lock, err := repo.acquireFetchLock(ctx); err != nil {
            return fmt.Errorf("unable to acquire fetch lock: %w", err)
        } else {
            defer werf.ReleaseHostLock(lock)
    Severity: Major
    Found in pkg/git_repo/local.go - About 35 mins to fix

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

      func DoTasks(ctx context.Context, numberOfTasks int, options DoTasksOptions, taskFunc func(ctx context.Context, taskId int) error) error {
          if numberOfTasks == 0 {
              return nil
          }
      
      
      Severity: Major
      Found in pkg/util/parallel/parallel.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

          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

            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

            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 rawStapelImage.UnmarshalYAML has 5 return statements (exceeds 4 allowed).
              Open

              func (c *rawStapelImage) UnmarshalYAML(unmarshal func(interface{}) error) error {
                  parentStack.Push(c)
                  type plain rawStapelImage
                  err := unmarshal((*plain)(c))
                  parentStack.Pop()
              Severity: Major
              Found in pkg/config/raw_stapel_image.go - About 35 mins to fix

                Method rawStageDependencies.toDirective has 5 return statements (exceeds 4 allowed).
                Open

                func (c *rawStageDependencies) toDirective() (stageDependencies *StageDependencies, err error) {
                    stageDependencies = &StageDependencies{}
                
                    if install, err := InterfaceToStringArray(c.Install, c, c.rawGit.rawStapelImage.doc); err != nil {
                        return nil, err
                Severity: Major
                Found in pkg/config/raw_stage_dependencies.go - About 35 mins to fix

                  Method FullDockerfileStage.GetDependencies has 5 return statements (exceeds 4 allowed).
                  Open

                  func (s *FullDockerfileStage) GetDependencies(ctx context.Context, c Conveyor, cb container_backend.ContainerBackend, prevImage, prevBuiltImage *StageImage, buildContextArchive container_backend.BuildContextArchiver) (string, error) {
                      resolvedDependenciesArgsHash := ResolveDependenciesArgs(s.targetPlatform, s.dependencies, c)
                  
                      resolvedDockerMetaArgsHash, err := s.resolveDockerMetaArgs(resolvedDependenciesArgsHash)
                      if err != nil {
                  Severity: Major
                  Found in pkg/build/stage/full_dockerfile.go - About 35 mins to fix

                    Method container.RmIfExist has 5 return statements (exceeds 4 allowed).
                    Open

                    func (c *container) RmIfExist(ctx context.Context) error {
                        exist, err := docker.ContainerExist(ctx, c.Name)
                        if err != nil {
                            return err
                        }
                    Severity: Major
                    Found in pkg/stapel/container.go - About 35 mins to fix

                      Method BuildContextArchive.Create has 5 return statements (exceeds 4 allowed).
                      Open

                      func (a *BuildContextArchive) Create(ctx context.Context, opts container_backend.BuildContextArchiveCreateOptions) error {
                          contextPathRelativeToGitWorkTree := filepath.Join(a.giterminismMgr.RelativeToGitProjectDir(), opts.ContextGitSubDir)
                      
                          dockerIgnorePathMatcher, err := createDockerIgnorePathMatcher(ctx, a.giterminismMgr, opts.ContextGitSubDir, opts.DockerfileRelToContextPath)
                          if err != nil {
                      Severity: Major
                      Found in pkg/build/image/build_context_archive.go - About 35 mins to fix

                        Method WerfConfig.validateDependenciesImages has 5 return statements (exceeds 4 allowed).
                        Open

                        func (c *WerfConfig) validateDependenciesImages() error {
                            for _, dfImage := range c.ImagesFromDockerfile {
                                for _, imgDep := range dfImage.Dependencies {
                                    if imgDep.ImageName == dfImage.Name {
                                        return newDetailedConfigError(fmt.Sprintf("image can't depend on itself: `%s`!", imgDep.ImageName), imgDep.raw, dfImage.raw.doc)
                        Severity: Major
                        Found in pkg/config/werf.go - About 35 mins to fix

                          Method Image.setupBaseImageRepoDigest has 5 return statements (exceeds 4 allowed).
                          Open

                          func (i *Image) setupBaseImageRepoDigest(ctx context.Context, reference string) error {
                              i.Conveyor.GetServiceRWMutex("baseImagesRepoIdsCache" + reference).Lock()
                              defer i.Conveyor.GetServiceRWMutex("baseImagesRepoIdsCache" + reference).Unlock()
                          
                              switch {
                          Severity: Major
                          Found in pkg/build/image/image.go - About 35 mins to fix

                            Method StapelImageBase.validate has 5 return statements (exceeds 4 allowed).
                            Open

                            func (c *StapelImageBase) validate(giterminismManager giterminism_manager.Interface) error {
                                if c.FromLatest {
                                    if err := giterminismManager.Inspector().InspectConfigStapelFromLatest(); err != nil {
                                        return newDetailedConfigError(err.Error(), nil, c.raw.doc)
                                    }
                            Severity: Major
                            Found in pkg/config/stapel_image_base.go - About 35 mins to fix

                              Method _escStaticFS.prepare has 5 return statements (exceeds 4 allowed).
                              Open

                              func (_escStaticFS) prepare(name string) (*_escFile, error) {
                                  f, present := _escData[path.Clean(name)]
                                  if !present {
                                      return nil, os.ErrNotExist
                                  }
                              Severity: Major
                              Found in pkg/build/builder/ansible/static.go - About 35 mins to fix

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

                                func RunAutoHostCleanup(ctx context.Context, options AutoHostCleanupOptions) error {
                                    if !options.ForceShouldRun {
                                        shouldRun, err := ShouldRunAutoHostCleanup(ctx, options.HostCleanupOptions)
                                        if err != nil {
                                            logboek.Context(ctx).Warn().LogF("WARNING: unable to check if auto host cleanup should be run: %s\n", err)
                                Severity: Major
                                Found in pkg/host_cleaning/host_cleanup.go - About 35 mins to fix

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

                                  func InterfaceToStringArray(stringOrStringArray, configSection interface{}, doc *doc) ([]string, error) {
                                      if stringOrStringArray == nil {
                                          return []string{}, nil
                                      } else if val, ok := stringOrStringArray.(string); ok {
                                          return []string{val}, nil
                                  Severity: Major
                                  Found in pkg/config/common.go - About 35 mins to fix

                                    Method GitCacheStage.gitMappingsPatchSize has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (s *GitCacheStage) gitMappingsPatchSize(ctx context.Context, c Conveyor, prevBuiltImage *StageImage) (int64, error) {
                                        var size int64
                                        for _, gitMapping := range s.gitMappings {
                                            commit, err := gitMapping.GetBaseCommitForPrevBuiltImage(ctx, c, prevBuiltImage)
                                            if err != nil {
                                    Severity: Major
                                    Found in pkg/build/stage/git_cache.go - About 35 mins to fix

                                      Method WerfConfig.validateImageFrom has 5 return statements (exceeds 4 allowed).
                                      Open

                                      func (c *WerfConfig) validateImageFrom(i *StapelImageBase) error {
                                          if i.raw.FromImage != "" {
                                              fromImageName := i.raw.FromImage
                                      
                                              if fromImageName == i.Name {
                                      Severity: Major
                                      Found in pkg/config/werf.go - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language