Showing 901 of 901 total issues

Function RunGC has 145 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func RunGC(ctx context.Context, allowedVolumeUsagePercentage, allowedVolumeUsageMarginPercentage float64) error {
    if lock, err := lockGC(ctx, false); err != nil {
        return err
    } else {
        defer werf.ReleaseHostLock(lock)
Severity: Major
Found in pkg/git_repo/gitdata/gc.go - About 4 hrs to fix

    Method Image.SetupBaseImage has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
    Open

    func (i *Image) SetupBaseImage(ctx context.Context, storageManager manager.StorageManagerInterface, storageOpts manager.StorageOptions) error {
        logboek.Context(ctx).Debug().LogF(" -- SetupBaseImage for %q\n", i.Name)
    
        switch i.baseImageType {
        case StageAsBaseImage:
    Severity: Minor
    Found in pkg/build/image/image.go - About 4 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 runGetServiceValues has 142 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func runGetServiceValues(ctx context.Context, imagesToProcess build.ImagesToProcess) error {
        logboek.SetAcceptedLevel(level.Error)
    
        if err := werf.Init(*getAutogeneratedValuedCmdData.TmpDir, *getAutogeneratedValuedCmdData.HomeDir); err != nil {
            return fmt.Errorf("initialization error: %w", err)
    Severity: Major
    Found in cmd/werf/helm/get_autogenerated_values.go - About 4 hrs to fix

      Method WerfChart.CreateNewBundle has 142 lines of code (exceeds 50 allowed). Consider refactoring.
      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 4 hrs to fix

        Function writePatch has 140 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func writePatch(ctx context.Context, out io.Writer, gitDir, workTreeCacheDir string, withSubmodules bool, opts PatchOptions) (*PatchDescriptor, error) {
            var err error
        
            gitDir, err = filepath.Abs(gitDir)
            if err != nil {
        Severity: Major
        Found in pkg/true_git/patch.go - About 4 hrs to fix

          Function ReferencesToScan has 137 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func ReferencesToScan(ctx context.Context, gitRepository *git.Repository, keepPolicies []*config.MetaCleanupKeepPolicy) ([]*ReferenceToScan, error) {
              rs, err := gitRepository.References()
              if err != nil {
                  return nil, fmt.Errorf("get repository references failed: %w", err)
              }
          Severity: Major
          Found in pkg/cleaning/git_history_based_cleanup/reference_to_scan.go - About 4 hrs to fix

            Method FullDockerfileStage.dockerfileInstructionDependencies has 136 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (s *FullDockerfileStage) dockerfileInstructionDependencies(ctx context.Context, giterminismManager giterminism_manager.Interface, resolvedDockerMetaArgsHash, resolvedDependenciesArgsHash map[string]string, dockerStageID int, cmd interface{}, isOnbuildInstruction, isBaseImageOnbuildInstruction bool) ([]string, []string, error) {
                var dependencies []string
                var onBuildDependencies []string
            
                resolveValueFunc := func(value string) (string, error) {
            Severity: Major
            Found in pkg/build/stage/full_dockerfile.go - About 4 hrs to fix

              Function SecretEdit has a Cognitive Complexity of 44 (exceeds 20 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: Minor
              Found in cmd/werf/helm/secret/common/edit.go - About 4 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 NewCmd has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
              Open

              func NewCmd(ctx context.Context) (*cobra.Command, error) {
                  var namespace string
                  ctx = common.NewContextWithCmdData(ctx, &_commonCmdData)
                  cmd := common.SetCommandContext(ctx, &cobra.Command{
                      Use:          "helm",
              Severity: Minor
              Found in cmd/werf/helm/helm.go - About 4 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 RunGC has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
              Open

              func RunGC(ctx context.Context, allowedVolumeUsagePercentage, allowedVolumeUsageMarginPercentage float64) error {
                  if lock, err := lockGC(ctx, false); err != nil {
                      return err
                  } else {
                      defer werf.ReleaseHostLock(lock)
              Severity: Minor
              Found in pkg/git_repo/gitdata/gc.go - About 4 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 FileReader.walkFilesWithPathMatcher has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
              Open

              func (r FileReader) walkFilesWithPathMatcher(ctx context.Context, relDir string, pathMatcher path_matcher.PathMatcher, skipFileFunc func(ctx context.Context, r FileReader, existingRelPath string) (bool, error), fileFunc func(notResolvedPath string) error) error {
                  if !pathMatcher.IsDirOrSubmodulePathMatched(relDir) {
                      return nil
                  }
              
              
              Severity: Minor
              Found in pkg/giterminism_manager/file_reader/fs.go - About 4 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 runCleanup has 130 lines of code (exceeds 50 allowed). Consider refactoring.
              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 4 hrs to fix

                Method StorageManager.FetchStage has 129 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (m *StorageManager) FetchStage(ctx context.Context, containerBackend container_backend.ContainerBackend, stg stage.Interface) error {
                    logboek.Context(ctx).Debug().LogF("-- StagesManager.FetchStage %s\n", stg.LogDetailedName())
                
                    if err := m.LockStageImage(ctx, stg.GetStageImage().Image.Name()); err != nil {
                        return fmt.Errorf("error locking stage image %q: %w", stg.GetStageImage().Image.Name(), err)
                Severity: Major
                Found in pkg/storage/manager/storage_manager.go - About 4 hrs to fix

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

                  func run(ctx context.Context, pod, secret, namespace string, werfConfig *config.WerfConfig, containerBackend container_backend.ContainerBackend, giterminismManager giterminism_manager.Interface) error {
                      projectName := werfConfig.Meta.Project
                  
                      userExtraAnnotations, err := common.GetUserExtraAnnotations(&commonCmdData)
                      if err != nil {
                  Severity: Minor
                  Found in cmd/werf/kube_run/kube_run.go - About 4 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  func (waiter *ResourcesWaiter) WatchUntilReady(ctx context.Context, resources helm_kube.ResourceList, timeout time.Duration) error {
                      if os.Getenv("WERF_DISABLE_RESOURCES_WAITER") == "1" {
                          return nil
                      }
                  
                  
                  Severity: Major
                  Found in pkg/deploy/helm/resources_waiter.go and 1 other location - About 4 hrs to fix
                  pkg/deploy/helm/resources_waiter.go on lines 66..97

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 313.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  func (waiter *ResourcesWaiter) Wait(ctx context.Context, resources helm_kube.ResourceList, timeout time.Duration) error {
                      if os.Getenv("WERF_DISABLE_RESOURCES_WAITER") == "1" {
                          return nil
                      }
                  
                  
                  Severity: Major
                  Found in pkg/deploy/helm/resources_waiter.go and 1 other location - About 4 hrs to fix
                  pkg/deploy/helm/resources_waiter.go on lines 315..346

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 313.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                  func run(ctx context.Context, pod, secret, namespace string, werfConfig *config.WerfConfig, containerBackend container_backend.ContainerBackend, giterminismManager giterminism_manager.Interface) error {
                      projectName := werfConfig.Meta.Project
                  
                      userExtraAnnotations, err := common.GetUserExtraAnnotations(&commonCmdData)
                      if err != nil {
                  Severity: Major
                  Found in cmd/werf/kube_run/kube_run.go - About 3 hrs to fix

                    Function runGetServiceValues has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func runGetServiceValues(ctx context.Context, imagesToProcess build.ImagesToProcess) error {
                        logboek.SetAcceptedLevel(level.Error)
                    
                        if err := werf.Init(*getAutogeneratedValuedCmdData.TmpDir, *getAutogeneratedValuedCmdData.HomeDir); err != nil {
                            return fmt.Errorf("initialization error: %w", err)
                    Severity: Minor
                    Found in cmd/werf/helm/get_autogenerated_values.go - About 3 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 runCleanup has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
                    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: Minor
                    Found in cmd/werf/cleanup/cleanup.go - About 3 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 RepoStagesStorage.GetStagesIDsByDigest has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (storage *RepoStagesStorage) GetStagesIDsByDigest(ctx context.Context, _, digest string, opts ...Option) ([]image.StageID, error) {
                        var res []image.StageID
                    
                        o := makeOptions(opts...)
                        if tags, err := storage.DockerRegistry.Tags(ctx, storage.RepoAddress, o.dockerRegistryOptions...); err != nil {
                    Severity: Minor
                    Found in pkg/storage/repo_stages_storage.go - About 3 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