Add a lint check to close SQL resources (stmts and rows)

This commit is contained in:
Alessio 2023-08-19 16:12:46 -03:00
parent 4cabae45dd
commit 7f24bb7893
4 changed files with 5 additions and 0 deletions

View File

@ -30,6 +30,7 @@ linters:
- gofmt - gofmt
- errorlint - errorlint
- nolintlint - nolintlint
- sqlclosecheck
# Useless linters: # Useless linters:

View File

@ -226,6 +226,7 @@ func (p Profile) GetTweetDetail(id TweetID) (TweetDetailView, error) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer stmt.Close()
// Main tweet and parents // Main tweet and parents
var thread []Tweet var thread []Tweet
@ -257,6 +258,7 @@ func (p Profile) GetTweetDetail(id TweetID) (TweetDetailView, error) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer stmt.Close()
err = stmt.Select(&replies, id) err = stmt.Select(&replies, id)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -66,6 +66,7 @@ func (p Profile) GetSpaceById(id scraper.SpaceID) (space scraper.Space, err erro
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
err = nil err = nil
} }
defer rows.Close()
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -213,6 +213,7 @@ func (p Profile) GetAllFollowedUsers() []scraper.UserHandle {
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer rows.Close()
ret := []scraper.UserHandle{} ret := []scraper.UserHandle{}