Showing 107 of 107 total issues

Function updateCmd has 9 return statements (exceeds 4 allowed).
Open

func updateCmd() *cobra.Command {
    var noSelfUpdate bool
    var autoclean bool
    var inBackground bool
    var backgroundStdoutFile string
Severity: Major
Found in client/cmd/trdl/update.go - About 55 mins to fix

    Function buildReleaseArtifacts has 9 return statements (exceeds 4 allowed).
    Open

    func buildReleaseArtifacts(ctx context.Context, tarWriter *nio.PipeWriter, gitRepo *git.Repository, fromImage string, runCommands []string, logger hclog.Logger) (error, func() error) {
        cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
        if err != nil {
            return fmt.Errorf("unable to create docker client: %w", err), nil
        }
    Severity: Major
    Found in server/path_release.go - About 55 mins to fix

      Function VerifyTagSignatures has 9 return statements (exceeds 4 allowed).
      Open

      func VerifyTagSignatures(repo *git.Repository, tagName string, trustedPGPPublicKeys []string, requiredNumberOfVerifiedSignatures int, logger hclog.Logger) error {
          tr, err := repo.Tag(tagName)
          if err != nil {
              return fmt.Errorf("unable to get tag: %w", err)
          }
      Severity: Major
      Found in server/pkg/git/signatures.go - About 55 mins to fix

        Method Publisher.setRepositoryKeys has 9 return statements (exceeds 4 allowed).
        Open

        func (publisher *Publisher) setRepositoryKeys(ctx context.Context, storage logical.Storage, repository RepositoryInterface, opts setRepositoryKeysOptions) error {
            entry, err := storage.Get(ctx, storageKeyTufRepositoryKeys)
            if err != nil {
                return fmt.Errorf("error getting storage private keys json entry by the key %q: %w", storageKeyTufRepositoryKeys, err)
            }
        Severity: Major
        Found in server/pkg/publisher/publisher.go - About 55 mins to fix

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

          func getConfiguration(ctx context.Context, storage logical.Storage) (*configuration, error) {
              raw, err := storage.Get(ctx, storageKeyConfiguration)
              if err != nil {
                  return nil, err
              }
          Severity: Minor
          Found in server/path_configure.go and 1 other location - About 55 mins to fix
          server/pkg/tasks_manager/config_storage.go on lines 9..24

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

          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

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

          func getConfiguration(ctx context.Context, storage logical.Storage) (*configuration, error) {
              raw, err := storage.Get(ctx, storageKeyConfiguration)
              if err != nil {
                  return nil, err
              }
          Severity: Minor
          Found in server/pkg/tasks_manager/config_storage.go and 1 other location - About 55 mins to fix
          server/path_configure.go on lines 186..201

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

          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 Publisher.fetchPGPSigningKey has 8 return statements (exceeds 4 allowed).
          Open

          func (publisher *Publisher) fetchPGPSigningKey(ctx context.Context, storage logical.Storage, initializeKey bool) (*pgp.RSASigningKey, error) {
              entry, err := storage.Get(ctx, storageKeyPGPSigningKey)
              if err != nil {
                  return nil, fmt.Errorf("error getting storage pgp signing key json entry by storage key %q: %w", storageKeyPGPSigningKey, err)
              }
          Severity: Major
          Found in server/pkg/publisher/publisher.go - About 50 mins to fix

            Function switchTaskToCompletedInStorage has 8 return statements (exceeds 4 allowed).
            Open

            func switchTaskToCompletedInStorage(ctx context.Context, storage logical.Storage, status taskStatus, uuid string, opts switchTaskToCompletedInStorageOptions) error {
                // validate new status
                if !isCompletedTaskStatus(status) {
                    return fmt.Errorf("runtime error: task in completed state cannot be with status %q", status)
                }
            Severity: Major
            Found in server/pkg/tasks_manager/task.go - About 50 mins to fix

              Method Client.DoSelfUpdate has 8 return statements (exceeds 4 allowed).
              Open

              func (c Client) DoSelfUpdate(autocleanReleases bool) error {
                  acquired, lock, err := c.locker.Acquire(selfUpdateLockFilename, lockgate.AcquireOptions{Shared: false, NonBlocking: true})
                  if err != nil {
                      return fmt.Errorf("unable to acquire lock: %w", err)
                  }
              Severity: Major
              Found in client/pkg/client/client.go - About 50 mins to fix

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

                    {
                        rotateAt, err := rotator.GetTargetsRotateAt()
                        if err != nil {
                            return fmt.Errorf("unable to get targets.json rotation time: %w", err)
                        }
                Severity: Minor
                Found in server/pkg/publisher/tuf_repo_rotator.go and 1 other location - About 50 mins to fix
                server/pkg/publisher/tuf_repo_rotator.go on lines 23..37

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

                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

                    {
                        rotateAt, err := rotator.GetRootRotateAt()
                        if err != nil {
                            return fmt.Errorf("unable to get root.json rotation time: %w", err)
                        }
                Severity: Minor
                Found in server/pkg/publisher/tuf_repo_rotator.go and 1 other location - About 50 mins to fix
                server/pkg/publisher/tuf_repo_rotator.go on lines 39..53

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

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

                func ValidatePublishConfig(ctx context.Context, publisher publisher.Interface, publisherRepository publisher.RepositoryInterface, config *config.TrdlChannels, logger hclog.Logger) error {
                    existingReleases, err := publisher.GetExistingReleases(ctx, publisherRepository)
                    if err != nil {
                        return fmt.Errorf("error getting existing targets: %w", err)
                    }
                Severity: Major
                Found in server/path_publish.go - About 50 mins to fix

                  Function useCmd has 8 return statements (exceeds 4 allowed).
                  Open

                  func useCmd() *cobra.Command {
                      var noSelfUpdate bool
                      var shell string
                  
                      cmd := &cobra.Command{
                  Severity: Major
                  Found in client/cmd/trdl/use.go - About 50 mins to fix

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

                        if now.Sub(w.LastProgressAt) > time.Second && durSecs > 0 {
                            logboek.Context(w.Context).Default().LogF("[%s] Writer processed durSecs=%d %d bytes, speed %d Mb/min\n", w.LogName, durSecs, w.ProcessedBytes, int(60*(float64(w.ProcessedBytes)/float64(durSecs))/1024.0/1024.0))
                            w.LastProgressAt = now
                        }
                    Severity: Minor
                    Found in server/pkg/util/throughput_io.go and 1 other location - About 50 mins to fix
                    server/pkg/util/throughput_io.go on lines 68..71

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

                    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

                            if now.Sub(r.LastProgressAt) > time.Second && durSecs > 0 {
                                logboek.Context(r.Context).Default().LogF("[%s] Reader processed durSecs=%d %d bytes, speed %d Mb/min\n", r.LogName, durSecs, r.ProcessedBytes, int(60*(float64(r.ProcessedBytes)/float64(durSecs))/1024.0/1024.0))
                                r.LastProgressAt = now
                            }
                    Severity: Minor
                    Found in server/pkg/util/throughput_io.go and 1 other location - About 50 mins to fix
                    server/pkg/util/throughput_io.go on lines 34..37

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

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

                    func binPathCmd() *cobra.Command {
                        cmd := &cobra.Command{
                            Use:                   "bin-path REPO GROUP [CHANNEL]",
                            Short:                 "Get the directory with software binaries",
                            DisableFlagsInUseLine: true,
                    Severity: Major
                    Found in client/cmd/trdl/bin_path.go - About 45 mins to fix

                      Function objectSignaturesFromNotes has 7 return statements (exceeds 4 allowed).
                      Open

                      func objectSignaturesFromNotes(repo *git.Repository, objectID string) ([]string, error) {
                          ref, err := repo.Reference(notesReferenceName, true)
                          if err != nil {
                              if err == plumbing.ErrReferenceNotFound {
                                  return nil, nil
                      Severity: Major
                      Found in server/pkg/git/signatures.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if len(artifactsTarStopReadCode) > codeCursor+1 {
                                                    codeCursor++
                                                } else {
                                                    return nil
                                                }
                        Severity: Major
                        Found in server/pkg/docker/image_build_response.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if len(artifactsTarStartReadCode) > codeCursor+1 {
                                                      codeCursor++
                          
                                                      startReadCodeSuspectedBytes = append(startReadCodeSuspectedBytes, b)
                                                  } else {
                          Severity: Major
                          Found in server/pkg/docker/image_build_response.go - About 45 mins to fix

                            Method Publisher.StageReleaseTarget has 7 return statements (exceeds 4 allowed).
                            Open

                            func (publisher *Publisher) StageReleaseTarget(ctx context.Context, repository RepositoryInterface, releaseName, releaseFilePath string, data io.Reader) error {
                                publisher.mu.Lock()
                                defer publisher.mu.Unlock()
                            
                                pathParts := SplitFilepath(filepath.Clean(releaseFilePath))
                            Severity: Major
                            Found in server/pkg/publisher/publisher.go - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language