Showing 900 of 900 total issues

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

func GetStorageLockManager(ctx context.Context, synchronization *SynchronizationParams) (storage.LockManager, error) {
    switch synchronization.SynchronizationType {
    case LocalSynchronization:
        return storage.NewGenericLockManager(werf.GetHostLocker()), nil
    case KubernetesSynchronization:
Severity: Major
Found in cmd/werf/common/synchronization.go - About 35 mins to fix

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

    func createNamespace(ctx context.Context, namespace string) error {
        if *commonCmdData.DryRun {
            return nil
        }
    
    
    Severity: Major
    Found in cmd/werf/kube_run/kube_run.go - About 35 mins to fix

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

      func NewExportCmd(ctx context.Context) *cobra.Command {
          var tagTemplateList []string
          var addLabelArray []string
      
          ctx = common.NewContextWithCmdData(ctx, &commonCmdData)
      Severity: Major
      Found in cmd/werf/export/export.go - About 35 mins to fix

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

        func validateCopyTo() error {
            rawCopyTo := getCopyToRaw()
        
            for _, copyTo := range rawCopyTo {
                parts := strings.Split(copyTo, ":")
        Severity: Major
        Found in cmd/werf/kube_run/kube_run.go - About 35 mins to fix

          Function run has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
          Open

          func run(ctx context.Context, imageName string) error {
              if err := werf.Init(*commonCmdData.TmpDir, *commonCmdData.HomeDir); err != nil {
                  return fmt.Errorf("initialization error: %w", err)
              }
          
          
          Severity: Minor
          Found in cmd/werf/managed_images/add/add.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 deleteCustomTags has 5 return statements (exceeds 4 allowed).
          Open

          func deleteCustomTags(ctx context.Context, storageManager manager.StorageManagerInterface, customTagList []string, dryRun bool) error {
              if dryRun {
                  for _, customTag := range customTagList {
                      logboek.Context(ctx).Default().LogFDetails("  tag: %s\n", customTag)
                      logboek.Context(ctx).Default().LogOptionalLn()
          Severity: Major
          Found in pkg/cleaning/purge.go - About 35 mins to fix

            Method KubernetesStagesStorageCache.changeCacheData has 5 return statements (exceeds 4 allowed).
            Open

            func (cache *KubernetesStagesStorageCache) changeCacheData(ctx context.Context, projectName string, changeFunc func(obj *v1.ConfigMap, cacheData *KubernetesStagesStorageCacheData) error) error {
            RETRY_CHANGE:
            
                obj, err := kubeutils.GetOrCreateConfigMapWithNamespaceIfNotExists(cache.KubeClient, cache.Namespace, cache.GetConfigMapNameFunc(projectName))
                if err != nil {
            Severity: Major
            Found in pkg/storage/kubernetes_stages_storage_cache.go - About 35 mins to fix

              Method StorageManager.SelectSuitableStage has 5 return statements (exceeds 4 allowed).
              Open

              func (m *StorageManager) SelectSuitableStage(ctx context.Context, c stage.Conveyor, stg stage.Interface, stages []*image.StageDescription) (*image.StageDescription, error) {
                  if len(stages) == 0 {
                      return nil, nil
                  }
              
              
              Severity: Major
              Found in pkg/storage/manager/storage_manager.go - About 35 mins to fix

                Method purgeManager.deleteCustomTags has 5 return statements (exceeds 4 allowed).
                Open

                func (m *purgeManager) deleteCustomTags(ctx context.Context) error {
                    stageIDCustomTagList, err := stage_manager.GetCustomTagsMetadata(ctx, m.StorageManager)
                    if err != nil {
                        return err
                    }
                Severity: Major
                Found in pkg/cleaning/purge.go - About 35 mins to fix

                  Method BundleArchiveFileReader.ReadChartArchive has 5 return statements (exceeds 4 allowed).
                  Open

                  func (reader *BundleArchiveFileReader) ReadChartArchive() ([]byte, error) {
                      treader, closer, err := reader.openForReading()
                      defer closer()
                  
                      if err != nil {
                  Severity: Major
                  Found in pkg/deploy/bundles/bundle_archive_reader.go - About 35 mins to fix

                    Method RepoStagesStorage.CopyFromStorage has 5 return statements (exceeds 4 allowed).
                    Open

                    func (storage *RepoStagesStorage) CopyFromStorage(ctx context.Context, src StagesStorage, projectName string, stageID image.StageID, opts CopyFromStorageOptions) (*image.StageDescription, error) {
                        desc, err := storage.GetStageDescription(ctx, projectName, stageID)
                        if err != nil {
                            return nil, fmt.Errorf("unable to get stage %s description: %w", stageID, err)
                        }
                    Severity: Major
                    Found in pkg/storage/repo_stages_storage.go - About 35 mins to fix

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

                      func doFetchStage(ctx context.Context, projectName string, stagesStorage storage.StagesStorage, stageID image.StageID, img container_backend.LegacyImageInterface) error {
                          err := logboek.Context(ctx).Info().LogProcess("Check manifest availability").DoError(func() error {
                              freshStageDescription, err := stagesStorage.GetStageDescription(ctx, projectName, stageID)
                              if err != nil {
                                  return fmt.Errorf("unable to get stage description: %w", err)
                      Severity: Major
                      Found in pkg/storage/manager/storage_manager.go - About 35 mins to fix

                        Function GetRequiredSecretKey has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func GetRequiredSecretKey(workingDir string) ([]byte, error) {
                            var secretKey []byte
                            var werfSecretKeyPaths []string
                            var notFoundIn []string
                        
                        
                        Severity: Minor
                        Found in pkg/deploy/secrets_manager/secret_key.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 readBundleJsonMap has 5 return statements (exceeds 4 allowed).
                        Open

                        func readBundleJsonMap(path string) (map[string]string, error) {
                            var res map[string]string
                            if _, err := os.Stat(path); os.IsNotExist(err) {
                                return nil, nil
                            } else if err != nil {
                        Severity: Major
                        Found in pkg/deploy/helm/chart_extender/bundle.go - About 35 mins to fix

                          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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language