Showing 614 of 901 total issues

cleanupManager has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

type cleanupManager struct {
    stageManager stage_manager.Manager

    nonexistentImportMetadataIDs []string

Severity: Minor
Found in pkg/cleaning/cleanup.go - About 2 hrs to fix

    Function run has 83 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func run(ctx context.Context, containerBackend container_backend.ContainerBackend, giterminismManager giterminism_manager.Interface) error {
        _, werfConfig, err := common.GetRequiredWerfConfig(ctx, &commonCmdData, giterminismManager, common.GetWerfConfigOptions(&commonCmdData, false))
        if err != nil {
            return fmt.Errorf("unable to load werf config: %w", err)
        }
    Severity: Major
    Found in cmd/werf/run/run.go - About 2 hrs to fix

      File helm_docs.go has 513 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package helm
      
      import "github.com/werf/werf/v2/cmd/werf/docs/structs"
      
      func GetHelmCreateDocs() structs.DocsStruct {
      Severity: Minor
      Found in cmd/werf/docs/replacers/helm/helm_docs.go - About 2 hrs to fix

        Function NewCmd has 82 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func NewCmd(ctx context.Context) *cobra.Command {
            ctx = common.NewContextWithCmdData(ctx, &commonCmdData)
            cmd := common.SetCommandContext(ctx, &cobra.Command{
                Use:                   "publish [IMAGE_NAME...]",
                Short:                 "Publish bundle",
        Severity: Major
        Found in cmd/werf/bundle/publish/publish.go - About 2 hrs to fix

          Function run has 25 return statements (exceeds 4 allowed).
          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: Major
          Found in cmd/werf/stage/image/main.go - About 2 hrs to fix

            Function runCleanup has 25 return statements (exceeds 4 allowed).
            Open

            func runCleanup(ctx context.Context) error {
                if err := werf.Init(*commonCmdData.TmpDir, *commonCmdData.HomeDir); err != nil {
                    return fmt.Errorf("initialization error: %w", err)
                }
            
            
            Severity: Major
            Found in cmd/werf/cleanup/cleanup.go - About 2 hrs to fix

              Function run has 81 lines of code (exceeds 50 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: Major
              Found in cmd/werf/managed_images/add/add.go - About 2 hrs to fix

                Method api.getRepoImageByDesc has 81 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (api *api) getRepoImageByDesc(ctx context.Context, originalTag string, desc *remote.Descriptor, ref name.Reference) (*image.Info, error) {
                    referenceParts, err := api.parseReferenceParts(ref.Name())
                    if err != nil {
                        return nil, fmt.Errorf("unable to parse reference %q: %w", ref.Name(), err)
                    }
                Severity: Major
                Found in pkg/docker_registry/api.go - About 2 hrs to fix

                  Function NewExportCmd has 80 lines of code (exceeds 50 allowed). Consider refactoring.
                  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 2 hrs to fix

                    FileReader has 21 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (r FileReader) projectRelativePathToAbsolutePath(relPath string) string {
                        return filepath.Join(r.sharedOptions.ProjectDir(), relPath)
                    }
                    Severity: Minor
                    Found in pkg/giterminism_manager/file_reader/fs.go - About 2 hrs to fix

                      GoroutineSafeBuffer has 21 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      type GoroutineSafeBuffer struct {
                          *bytes.Buffer
                          m sync.Mutex
                      }
                      Severity: Minor
                      Found in pkg/util/goroutine_safe_buffer.go - About 2 hrs to fix

                        CallbackModule has 21 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        class CallbackModule(LiveCallbackHelpers):
                            CALLBACK_VERSION = 2.0
                            CALLBACK_TYPE = 'stdout'
                            CALLBACK_NAME = 'live'
                        
                        
                        Severity: Minor
                        Found in pkg/build/builder/ansible/callback/live.py - About 2 hrs to fix

                          Function runMain has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func runMain(ctx context.Context) error {
                              global_warnings.PostponeMultiwerfNotUpToDateWarning()
                          
                              if err := werf.Init(*commonCmdData.TmpDir, *commonCmdData.HomeDir); err != nil {
                                  return fmt.Errorf("initialization error: %w", err)
                          Severity: Major
                          Found in cmd/werf/kube_run/kube_run.go - About 2 hrs to fix

                            Method cleanupManager.cleanupUnusedStages has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (m *cleanupManager) cleanupUnusedStages(ctx context.Context) error {
                                stageDescriptionList := m.stageManager.GetStageDescriptionList(stage_manager.StageDescriptionListOptions{})
                                stageDescriptionListCount := len(stageDescriptionList)
                            
                                if err := logboek.Context(ctx).Info().LogProcess("Fetching imports metadata").DoError(func() error {
                            Severity: Major
                            Found in pkg/cleaning/cleanup.go - About 2 hrs to fix

                              File kubectl.go has 505 lines of code (exceeds 500 allowed). Consider refactoring.
                              Open

                              package kubectl
                              
                              import (
                                  "fmt"
                              
                              
                              Severity: Minor
                              Found in cmd/werf/docs/replacers/kubectl/kubectl.go - About 2 hrs to fix

                                Function SecretEdit has 78 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func SecretEdit(ctx context.Context, m *secrets_manager.SecretsManager, workingDir, filePath string, values bool) error {
                                    var encoder *secret.YamlEncoder
                                    if enc, err := m.GetYamlEncoder(ctx, workingDir); err != nil {
                                        return err
                                    } else {
                                Severity: Major
                                Found in cmd/werf/helm/secret/common/edit.go - About 2 hrs to fix

                                  Method cleanupManager.skipStageIDsThatAreUsedInKubernetes has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func (m *cleanupManager) skipStageIDsThatAreUsedInKubernetes(ctx context.Context, deployedDockerImages []*DeployedDockerImage) error {
                                      handledDeployedStages := map[string]bool{}
                                      handleTagFunc := func(tag, stageID string, f func()) {
                                          dockerImageName := fmt.Sprintf("%s:%s", m.StorageManager.GetStagesStorage().Address(), tag)
                                          for _, deployedDockerImage := range deployedDockerImages {
                                  Severity: Minor
                                  Found in pkg/cleaning/cleanup.go - About 2 hrs 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 getStageDescription has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func getStageDescription(ctx context.Context, projectName string, stageID image.StageID, stagesStorage storage.StagesStorage, cacheStagesStorageList []storage.StagesStorage, opts getStageDescriptionOptions) (*image.StageDescription, error) {
                                      if opts.WithLocalManifestCache {
                                          stageDesc, err := getStageDescriptionFromLocalManifestCache(ctx, projectName, stageID, stagesStorage)
                                          if err != nil {
                                              return nil, fmt.Errorf("error getting stage %s description from %s: %w", stageID.String(), stagesStorage.String(), err)
                                  Severity: Minor
                                  Found in pkg/storage/manager/storage_manager.go - About 2 hrs 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 WerfChart.CreateNewBundle has 23 return statements (exceeds 4 allowed).
                                  Open

                                  func (wc *WerfChart) CreateNewBundle(ctx context.Context, destDir, chartVersion string, vals *values.Options) (*Bundle, error) {
                                      chartPath := filepath.Join(wc.GiterminismManager.ProjectDir(), wc.ChartDir)
                                      chrt, err := loader.LoadDir(chartPath)
                                      if err != nil {
                                          return nil, fmt.Errorf("error loading chart %q: %w", chartPath, err)
                                  Severity: Major
                                  Found in pkg/deploy/helm/chart_extender/werf_chart.go - About 2 hrs to fix

                                    Method commitHistoryScanner.handleCommit has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    func (s *commitHistoryScanner) handleCommit(ctx context.Context, commit string) ([]string, error) {
                                        var isReachedCommit bool
                                    
                                    outerLoop:
                                        for stageID, commitList := range s.expectedStageIDCommitList {
                                    Severity: Minor
                                    Found in pkg/cleaning/git_history_based_cleanup/scanner.go - About 2 hrs 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language