Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the errcheck failures and try to solve them #257

Closed
tboerger opened this issue Nov 25, 2016 · 7 comments
Closed

Check the errcheck failures and try to solve them #257

tboerger opened this issue Nov 25, 2016 · 7 comments
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality

Comments

@tboerger
Copy link
Member

tboerger commented Nov 25, 2016

# make errcheck
errcheck code.gitea.io/gitea code.gitea.io/gitea/cmd code.gitea.io/gitea/models code.gitea.io/gitea/models/migrations code.gitea.io/gitea/modules/auth code.gitea.io/gitea/modules/auth/ldap code.gitea.io/gitea/modules/auth/pam code.gitea.io/gitea/modules/avatar code.gitea.io/gitea/modules/base code.gitea.io/gitea/modules/bindata code.gitea.io/gitea/modules/context code.gitea.io/gitea/modules/cron code.gitea.io/gitea/modules/httplib code.gitea.io/gitea/modules/log code.gitea.io/gitea/modules/mailer code.gitea.io/gitea/modules/markdown code.gitea.io/gitea/modules/process code.gitea.io/gitea/modules/setting code.gitea.io/gitea/modules/ssh code.gitea.io/gitea/modules/sync code.gitea.io/gitea/modules/template code.gitea.io/gitea/modules/template/highlight code.gitea.io/gitea/modules/user code.gitea.io/gitea/routers code.gitea.io/gitea/routers/admin code.gitea.io/gitea/routers/api/v1 code.gitea.io/gitea/routers/api/v1/admin code.gitea.io/gitea/routers/api/v1/convert code.gitea.io/gitea/routers/api/v1/misc code.gitea.io/gitea/routers/api/v1/org code.gitea.io/gitea/routers/api/v1/repo code.gitea.io/gitea/routers/api/v1/user code.gitea.io/gitea/routers/dev code.gitea.io/gitea/routers/org code.gitea.io/gitea/routers/repo code.gitea.io/gitea/routers/user
cmd/admin.go:76:18:	models.SetEngine()
cmd/dump.go:52:18:	models.SetEngine()
cmd/dump.go:82:12:	os.Remove(fileName)
cmd/dump.go:105:12:	os.Remove(fileName)
cmd/dump.go:114:14:	os.RemoveAll(TmpWorkDir)
cmd/serve.go:54:11:	os.Chdir(workDir)
cmd/serve.go:57:18:	models.SetEngine()
cmd/serve.go:128:18:	resp.Body.Close()
cmd/serve.go:260:11:	os.Setenv("uuid", uuid)
cmd/web.go:337:18:	defer fr.Close()
cmd/web.go:660:12:	os.Remove(listenAddr)
main.go:40:9:	app.Run(os.Args)
models/git_diff.go:353:12:	io.Copy(ioutil.Discard, reader)
models/issue.go:1741:16:	defer fw.Close()
models/issue_comment.go:256:27:	comment.MailParticipants(act.OpType, opts.Issue)
models/login_source.go:411:15:	defer c.Close()
models/migrations/migrations.go:127:16:	sess.Rollback()
models/migrations/migrations.go:323:19:	ioutil.WriteFile(dumpPath, buf.Bytes(), 0666)
models/models.go:42:16:	sess.Rollback()
models/models.go:183:13:	os.MkdirAll(path.Dir(logPath), os.ModePerm)
models/org.go:126:26:	org.GenerateRandomAvatar()
models/org.go:382:16:	sess.Rollback()
models/org.go:385:16:	sess.Rollback()
models/org_team.go:247:16:	sess.Rollback()
models/org_team.go:253:16:	sess.Rollback()
models/pull.go:211:13:	os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm)
models/pull.go:212:20:	defer os.RemoveAll(path.Dir(tmpBasePath))
models/pull.go:571:27:	headGitRepo.RemoveRemote(tmpRemote)
models/pull.go:610:32:	defer headGitRepo.RemoveRemote(tmpRemoteName)
models/pull.go:615:11:	os.Remove(path.Join(pr.BaseRepo.RepoPath(), headFile))
models/pull.go:764:11:	x.Iterate(PullRequest{
models/repo.go:523:13:	os.MkdirAll(filepath.Dir(patchPath), os.ModePerm)
models/repo.go:632:14:	os.RemoveAll(repoPath)
models/repo.go:643:15:	os.RemoveAll(wikiPath)
models/repo.go:864:14:	os.MkdirAll(tmpDir, os.ModePerm)
models/repo.go:865:21:	defer os.RemoveAll(tmpDir)
models/repo.go:1158:13:	os.MkdirAll(UserPath(newOwner.Name), os.ModePerm)
models/repo.go:1259:12:	f.Close()
models/repo_editor.go:104:13:	os.MkdirAll(path.Dir(filePath), os.ModePerm)
models/repo_editor.go:185:13:	os.MkdirAll(filepath.Dir(filePath), os.ModePerm)
models/repo_editor.go:339:16:	defer fw.Close()
models/repo_editor.go:466:13:	os.MkdirAll(dirPath, os.ModePerm)
models/ssh_key.go:173:21:	defer tmpFile.Close()
models/ssh_key.go:192:17:	defer os.Remove(tmpName)
models/ssh_key.go:325:15:	defer f.Close()
models/ssh_key.go:370:13:	os.MkdirAll(path.Dir(tmpPath), os.ModePerm)
models/ssh_key.go:529:17:	defer os.Remove(tmpPath)
models/ssh_key.go:535:9:	f.Close()
models/user.go:250:16:	defer fw.Close()
models/user.go:371:13:	os.MkdirAll(setting.AvatarUploadPath, os.ModePerm)
models/user.go:376:16:	defer fw.Close()
models/user.go:388:11:	os.Remove(u.CustomAvatarPath())
models/user.go:844:14:	os.RemoveAll(UserPath(u.Name))
models/user.go:845:11:	os.Remove(u.CustomAvatarPath())
models/webhook.go:592:23:	defer resp.Body.Close()
models/webhook.go:615:10:	Iterate(new(HookTask),
models/wiki.go:115:12:	os.Remove(path.Join(localPath, oldTitle+".md"))
models/wiki.go:123:11:	os.Remove(filename)
models/wiki.go:171:11:	os.Remove(filename)
modules/base/tool.go:35:9:	m.Write([]byte(str))
modules/base/tool.go:42:9:	h.Write([]byte(str))
modules/base/tool.go:89:11:	rand.Read(bytes)
modules/base/tool.go:115:12:	prf.Write(salt)
modules/base/tool.go:120:12:	prf.Write(buf[:4])
modules/base/tool.go:128:13:	prf.Write(U)
modules/base/tool.go:193:10:	sh.Write([]byte(data + setting.SecretKey + startStr + endStr + com.ToStr(minutes)))
modules/httplib/httplib.go:273:14:	fh.Close()
modules/httplib/httplib.go:279:27:	bodyWriter.WriteField(k, v)
modules/httplib/httplib.go:281:21:	bodyWriter.Close()
modules/httplib/httplib.go:282:13:	pw.Close()
modules/httplib/httplib.go:382:23:	defer resp.Body.Close()
modules/httplib/httplib.go:398:15:	defer f.Close()
modules/httplib/httplib.go:407:23:	defer resp.Body.Close()
modules/httplib/httplib.go:446:19:	conn.SetDeadline(time.Now().Add(rwTimeout))
modules/log/conn.go:52:29:	defer cw.innerWriter.Close()
modules/log/conn.go:66:22:	cw.innerWriter.Close()
modules/log/conn.go:71:23:	cw.innerWriter.Close()
modules/log/conn.go:81:23:	tcpConn.SetKeepAlive(true)
modules/log/file.go:63:13:	l.fd.Close()
modules/log/file.go:192:11:	fd.Close()
modules/log/file.go:213:15:	filepath.Walk(dir, func(path string, info os.FileInfo, err error) (returnErr error) {
modules/log/file.go:222:14:	os.Remove(path)
modules/log/file.go:231:15:	w.mw.fd.Close()
modules/log/file.go:238:14:	w.mw.fd.Sync()
modules/log/log.go:42:13:	os.MkdirAll(path.Dir(logPath), os.ModePerm)
modules/log/log.go:44:21:	GitLogger.SetLogger("file", fmt.Sprintf(`{"level":0,"filename":"%s","rotate":false}`, logPath))
modules/log/log.go:279:13:	l.writerMsg(0, TRACE, msg)
modules/log/log.go:284:13:	l.writerMsg(0, DEBUG, msg)
modules/log/log.go:289:13:	l.writerMsg(0, INFO, msg)
modules/log/log.go:294:13:	l.writerMsg(0, WARN, msg)
modules/log/log.go:299:13:	l.writerMsg(skip, ERROR, msg)
modules/log/log.go:304:13:	l.writerMsg(skip, CRITICAL, msg)
modules/log/log.go:309:13:	l.writerMsg(skip, FATAL, msg)
modules/mailer/mailer.go:115:18:	defer conn.Close()
modules/ssh/ssh.go:36:18:	newChan.Reject(ssh.UnknownChannelType, "unknown channel type")
modules/ssh/ssh.go:47:18:	defer ch.Close()
modules/ssh/ssh.go:94:15:	req.Reply(true, nil)
modules/ssh/ssh.go:95:16:	go io.Copy(input, ch)
modules/ssh/ssh.go:96:13:	io.Copy(ch, stdout)
modules/ssh/ssh.go:97:13:	io.Copy(ch.Stderr(), stderr)
modules/ssh/ssh.go:104:20:	ch.SendRequest("exit-status", false, []byte{0, 0, 0, 0})
modules/ssh/ssh.go:165:14:	os.MkdirAll(filepath.Dir(keyPath), os.ModePerm)
modules/user/user_test.go:9:11:	os.Setenv("USER", "")
modules/user/user_test.go:10:11:	os.Setenv("USERNAME", "foobar")
modules/user/user_test.go:17:11:	os.Setenv("USER", "gitea")
routers/api/v1/misc/markdown.go:23:12:	ctx.Write([]byte(""))
routers/api/v1/misc/markdown.go:29:12:	ctx.Write(markdown.Render([]byte(form.Text), form.Context, nil))
routers/api/v1/misc/markdown.go:31:12:	ctx.Write(markdown.RenderRaw([]byte(form.Text), ""))
routers/api/v1/misc/markdown.go:43:11:	ctx.Write(markdown.RenderRaw(body, ""))
routers/repo/download.go:33:16:	ctx.Resp.Write(buf)
routers/repo/editor.go:501:18:	defer file.Close()
routers/repo/http.go:342:22:	defer h.r.Body.Close()
routers/repo/http.go:431:12:	h.w.Write(packetWrite("# service=git-" + service + "\n"))
routers/repo/http.go:432:12:	h.w.Write([]byte("0000"))
routers/repo/http.go:433:12:	h.w.Write(refs)
routers/repo/http.go:486:13:	w.Write([]byte("Interacting with repositories by HTTP protocol is not allowed"))
routers/repo/http.go:492:14:	w.Write([]byte("Method Not Allowed"))
routers/repo/http.go:495:14:	w.Write([]byte("Bad Request"))
routers/repo/issue.go:472:18:	defer file.Close()
routers/user/auth.go:66:17:	ctx.Session.Set("uid", u.ID)
routers/user/auth.go:67:17:	ctx.Session.Set("uname", u.Name)
routers/user/auth.go:129:17:	ctx.Session.Set("uid", u.ID)
routers/user/auth.go:130:17:	ctx.Session.Set("uname", u.Name)
routers/user/auth.go:153:20:	ctx.Session.Delete("uid")
routers/user/auth.go:154:20:	ctx.Session.Delete("uname")
routers/user/auth.go:155:20:	ctx.Session.Delete("socialId")
routers/user/auth.go:156:20:	ctx.Session.Delete("socialName")
routers/user/auth.go:157:20:	ctx.Session.Delete("socialEmail")
routers/user/auth.go:304:18:	ctx.Session.Set("uid", user.ID)
routers/user/auth.go:305:18:	ctx.Session.Set("uname", user.Name)
routers/user/setting.go:121:17:	defer fr.Close()
make: *** [errcheck] Error 1
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/39529009-check-the-errcheck-failures-and-try-to-solve-them?utm_campaign=plugin&utm_content=tracker%2F47456670&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F47456670&utm_medium=issues&utm_source=github).
@tboerger tboerger added the type/enhancement An improvement of existing functionality label Nov 25, 2016
@tboerger tboerger added this to the 1.0.0 milestone Nov 25, 2016
@bkcsoft
Copy link
Member

bkcsoft commented Nov 28, 2016

I see a lot of false positives in there FYI (all the .Close() ones...)

@lunny
Copy link
Member

lunny commented Nov 28, 2016

Yes, and no idea about how to resolve them

@tboerger
Copy link
Member Author

There are ways to disable errors within the errcheck command, but we should catch as much errors as possible :)

@tboerger
Copy link
Member Author

tboerger commented Dec 3, 2016

Let's move the rest to 1.1.0

@tboerger tboerger modified the milestones: 1.1.0, 1.0.0 Dec 3, 2016
@lunny lunny modified the milestones: 1.2.0, 1.1.0 Feb 14, 2017
@lunny lunny modified the milestones: 1.x.x, 1.2.0 Apr 20, 2017
@stale
Copy link

stale bot commented Feb 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Feb 15, 2019
@stale
Copy link

stale bot commented Mar 1, 2019

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Mar 1, 2019
@lunny lunny added issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented and removed issue/stale labels Mar 1, 2019
@lunny lunny reopened this Mar 1, 2019
@lunny
Copy link
Member

lunny commented Jul 11, 2019

This should be fixed by #6418

@lunny lunny closed this as completed Jul 15, 2019
@lunny lunny removed this from the 1.x.x milestone Jul 15, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants