Showing 9 of 9 total issues
Function copyDir
has 9 return statements (exceeds 4 allowed). Open
Open
func copyDir(src string, dst string) (err error) {
src = filepath.Clean(src)
dst = filepath.Clean(dst)
si, err := os.Stat(src)
Method Engine.AddRepository
has 8 return statements (exceeds 4 allowed). Open
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 {
Method Engine.handleReplacements
has 7 return statements (exceeds 4 allowed). Open
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)
Function copyFile
has 7 return statements (exceeds 4 allowed). Open
Open
func copyFile(src, dst string) (err error) {
in, err := os.Open(src)
if err != nil {
return
}
Method Engine.handleExplicitTemplate
has 6 return statements (exceeds 4 allowed). Open
Open
func (e *Engine) handleExplicitTemplate(workingDirectory, explicitTemplateFile, name string, arguments map[string]string) {
if e.err != nil {
return
}
fileToProcess := path.Join(workingDirectory, explicitTemplateFile)
Function startAndWait
has 6 return statements (exceeds 4 allowed). Open
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")
}
Method Engine.ensureStorage
has 6 return statements (exceeds 4 allowed). Open
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()
Method Engine.setupDirectories
has 6 return statements (exceeds 4 allowed). Open
Open
func (e *Engine) setupDirectories(name, templateName string) (string, string, string, func()) {
if e.err != nil {
return "", "", "", nil
}
logger := e.logger.WithField("method", "setupDirectories")
Function copyDir
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func copyDir(src string, dst string) (err error) {
src = filepath.Clean(src)
dst = filepath.Clean(dst)
si, err := os.Stat(src)
- Read upRead up
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"