sascha-andres/go-template

View on GitHub

Showing 9 of 9 total issues

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

func copyDir(src string, dst string) (err error) {
    src = filepath.Clean(src)
    dst = filepath.Clean(dst)

    si, err := os.Stat(src)
Severity: Major
Found in copy_dir.go - About 55 mins to fix

    Method Engine.AddRepository has 8 return statements (exceeds 4 allowed).
    Open

    func (e *Engine) AddRepository(url, branch string) (*Repository, error) {
        logger := e.logger.WithField("method", "AddRepository")
        logger.Debugf("add from [%s]", url)
        temporaryDirectory, err := ioutil.TempDir("", "go-template")
        if err != nil {
    Severity: Major
    Found in repo_add.go - About 50 mins to fix

      Method Engine.handleReplacements has 7 return statements (exceeds 4 allowed).
      Open

      func (e *Engine) handleReplacements(replacements FromToInformation, workingDirectory, name string, arguments map[string]string) {
          if e.err != nil {
              return
          }
          localTo, err := applyVariables(replacements.To, name, arguments)
      Severity: Major
      Found in new_handle_replacements.go - About 45 mins to fix

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

        func copyFile(src, dst string) (err error) {
            in, err := os.Open(src)
            if err != nil {
                return
            }
        Severity: Major
        Found in copy_dir.go - About 45 mins to fix

          Method Engine.setupDirectories has 6 return statements (exceeds 4 allowed).
          Open

          func (e *Engine) setupDirectories(name, templateName string) (string, string, string, func()) {
              if e.err != nil {
                  return "", "", "", nil
              }
              logger := e.logger.WithField("method", "setupDirectories")
          Severity: Major
          Found in new_setup_directories.go - About 40 mins to fix

            Method Engine.handleExplicitTemplate has 6 return statements (exceeds 4 allowed).
            Open

            func (e *Engine) handleExplicitTemplate(workingDirectory, explicitTemplateFile, name string, arguments map[string]string) {
                if e.err != nil {
                    return
                }
                fileToProcess := path.Join(workingDirectory, explicitTemplateFile)
            Severity: Major
            Found in new_handle_explicit_template.go - About 40 mins to fix

              Method Engine.ensureStorage has 6 return statements (exceeds 4 allowed).
              Open

              func (e *Engine) ensureStorage() error {
                  logger := e.logger.WithField("method", "ensureStorage")
                  logger.Debugf("checking [%s]", e.storageDirectory)
                  // Find home directory.
                  home, err := homedir.Dir()
              Severity: Major
              Found in storage.go - About 40 mins to fix

                Function startAndWait has 6 return statements (exceeds 4 allowed).
                Open

                func startAndWait(command *exec.Cmd) (int, error) {
                    var err error
                    if err = command.Start(); err != nil {
                        return -1, errors.Wrap(err, "could not start command")
                    }
                Severity: Major
                Found in wrapper/git.go - About 40 mins to fix

                  Function copyDir has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func copyDir(src string, dst string) (err error) {
                      src = filepath.Clean(src)
                      dst = filepath.Clean(dst)
                  
                      si, err := os.Stat(src)
                  Severity: Minor
                  Found in copy_dir.go - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language