Showing 614 of 901 total issues

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

func NewUpgradeCmd(actionConfig *action.Configuration, wc *chart_extender.WerfChartStub, namespace *string) *cobra.Command {
    cmd, _ := helm_v3.NewUpgradeCmd(actionConfig, os.Stdout, helm_v3.UpgradeCmdOptions{
        StagesSplitter:              helm.NewStagesSplitter(),
        StagesExternalDepsGenerator: helm.NewStagesExternalDepsGenerator(&actionConfig.RESTClientGetter, namespace),
        ChainPostRenderer:           wc.ChainPostRenderer,
Severity: Major
Found in cmd/werf/helm/upgrade.go - About 35 mins to fix

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

    func sortResources(id1, id2 *resrcid.ResourceID) bool {
        kind1 := id1.GroupVersionKind().Kind
        kind2 := id2.GroupVersionKind().Kind
        if kind1 != kind2 {
            return kind1 < kind2
    Severity: Major
    Found in cmd/werf/render/render.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 readEditedFile has 5 return statements (exceeds 4 allowed).
        Open

        func readEditedFile(filePath string, values bool, encoder *secret.YamlEncoder) ([]byte, []byte, error) {
            var data, encodedData []byte
        
            exist, err := util.FileExists(filePath)
            if err != nil {
        Severity: Major
        Found in cmd/werf/helm/secret/common/edit.go - About 35 mins to fix

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

            func getTelemetryProjectID(ctx context.Context) (string, error) {
                var projectID string
            
                var workingDir, gitWorkTree string
            
            
            Severity: Major
            Found in cmd/werf/common/telemetry.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 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

                  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 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

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

                      func doRequest(ctx context.Context, 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

                        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

                          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

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

                              func (api *genericApi) mirrorReferenceList(ctx context.Context, reference string) ([]string, error) {
                                  var referenceList []string
                              
                                  referenceParts, err := api.commonApi.parseReferenceParts(reference)
                                  if err != nil {
                              Severity: Major
                              Found in pkg/docker_registry/generic_api.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

                                  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

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