Showing 915 of 915 total issues

Function doYamlValueSecretV2 has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
Open

func doYamlValueSecretV2(doFunc func([]byte) ([]byte, error), node *yaml_v3.Node, mode yamlProcessorMode) (*yaml_v3.Node, error) {
    switch node.Kind {
    case yaml_v3.DocumentNode:
        for pos := 0; pos < len(node.Content); pos += 1 {
            newValueNode, err := doYamlValueSecretV2(doFunc, deepCopyNode(node.Content[pos]), mode)
Severity: Minor
Found in pkg/secret/yaml_encoder.go - About 5 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

File full_dockerfile.go has 662 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package stage

import (
    "bytes"
    "context"
Severity: Minor
Found in pkg/build/stage/full_dockerfile.go - About 5 hrs to fix

    Function runPublish has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring.
    Open

    func runPublish(ctx context.Context, imagesToProcess build.ImagesToProcess) error {
        global_warnings.PostponeMultiwerfNotUpToDateWarning()
    
        if err := werf.Init(*commonCmdData.TmpDir, *commonCmdData.HomeDir); err != nil {
            return fmt.Errorf("initialization error: %w", err)
    Severity: Minor
    Found in cmd/werf/bundle/publish/publish.go - About 5 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 RunGCForLocalDockerServer has 168 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func RunGCForLocalDockerServer(ctx context.Context, allowedVolumeUsagePercentage, allowedVolumeUsageMarginPercentage float64, dockerServerStoragePath string, force, dryRun bool) error {
        if dockerServerStoragePath == "" {
            return nil
        }
    
    
    Severity: Major
    Found in pkg/host_cleaning/local_docker_server.go - About 5 hrs to fix

      RepoStagesStorage has 41 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type RepoStagesStorage struct {
          RepoAddress      string
          DockerRegistry   docker_registry.Interface
          ContainerBackend container_backend.ContainerBackend
      }
      Severity: Minor
      Found in pkg/storage/repo_stages_storage.go - About 5 hrs to fix

        Function NewCmd has 161 lines of code (exceeds 50 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: Major
        Found in cmd/werf/helm/helm.go - About 5 hrs to fix

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

          func (s *commitHistoryScanner) handleExtraStageIDsByLastWithIn(ctx context.Context, latestCommitStageIDs map[*object.Commit][]string, latestCommitList []*object.Commit) ([]string, []string, map[string][]string, error) {
              var latestCommitListByLast []*object.Commit
              var latestCommitListByIn []*object.Commit
              stageIDHitCommitList := map[string][]string{}
          
          
          Severity: Minor
          Found in pkg/cleaning/git_history_based_cleanup/scanner.go - About 5 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

          StorageManager has 40 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type StorageManager struct {
              parallel           bool
              parallelTasksLimit int
          
              ProjectName string
          Severity: Minor
          Found in pkg/storage/manager/storage_manager.go - About 5 hrs to fix

            File api.go has 636 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package docker_registry
            
            import (
                "context"
                "errors"
            Severity: Minor
            Found in pkg/docker_registry/api.go - About 5 hrs to fix

              File live.py has 385 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # -*- coding: utf-8 -*-
              # (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
              # (c) 2017 Ansible Project
              # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
              
              
              Severity: Minor
              Found in pkg/build/builder/ansible/callback/live.py - About 5 hrs to fix

                LocalStagesStorage has 39 methods (exceeds 20 allowed). Consider refactoring.
                Open

                type LocalStagesStorage struct {
                    ContainerBackend container_backend.ContainerBackend
                }
                Severity: Minor
                Found in pkg/storage/local_stages_storage.go - About 5 hrs to fix

                  Function runExport has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func runExport(ctx context.Context, imagesToProcess build.ImagesToProcess) error {
                      if err := werf.Init(*commonCmdData.TmpDir, *commonCmdData.HomeDir); err != nil {
                          return fmt.Errorf("initialization error: %w", err)
                      }
                  
                  
                  Severity: Minor
                  Found in cmd/werf/bundle/export/export.go - About 5 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 FullDockerfileStage.FetchDependencies has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (s *FullDockerfileStage) FetchDependencies(ctx context.Context, c Conveyor, containerBackend container_backend.ContainerBackend, dockerRegistry docker_registry.GenericApiInterface) error {
                      resolvedDependenciesArgsHash := ResolveDependenciesArgs(s.targetPlatform, s.dependencies, c)
                  
                      resolvedDockerMetaArgsHash, err := s.resolveDockerMetaArgs(resolvedDependenciesArgsHash)
                      if err != nil {
                  Severity: Minor
                  Found in pkg/build/stage/full_dockerfile.go - About 5 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 NewCmd(ctx context.Context) *cobra.Command {
                      ctx = common.NewContextWithCmdData(ctx, &commonCmdData)
                      cmd := common.SetCommandContext(ctx, &cobra.Command{
                          Use:                   "decrypt",
                          DisableFlagsInUseLine: true,
                  Severity: Major
                  Found in cmd/werf/helm/secret/decrypt/decrypt.go and 1 other location - About 5 hrs to fix
                  cmd/werf/helm/secret/encrypt/encrypt.go on lines 28..69

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

                  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 NewCmd(ctx context.Context) *cobra.Command {
                      ctx = common.NewContextWithCmdData(ctx, &commonCmdData)
                      cmd := common.SetCommandContext(ctx, &cobra.Command{
                          Use:                   "encrypt",
                          DisableFlagsInUseLine: true,
                  Severity: Major
                  Found in cmd/werf/helm/secret/encrypt/encrypt.go and 1 other location - About 5 hrs to fix
                  cmd/werf/helm/secret/decrypt/decrypt.go on lines 28..70

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

                  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

                  Method FullDockerfileStage.GetDependencies has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  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: Minor
                  Found in pkg/build/stage/full_dockerfile.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

                  BaseStage has 37 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  type BaseStage struct {
                      name             StageName
                      logName          string
                      targetPlatform   string
                      imageName        string
                  Severity: Minor
                  Found in pkg/build/stage/base.go - About 4 hrs to fix

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