Fix some lint problems
This commit is contained in:
parent
06167eef18
commit
1582dfe44e
@ -26,7 +26,7 @@ linters:
|
|||||||
# - wsl
|
# - wsl
|
||||||
# - wrapcheck
|
# - wrapcheck
|
||||||
- lll
|
- lll
|
||||||
# - godox
|
- godox
|
||||||
# - errorlint
|
# - errorlint
|
||||||
|
|
||||||
|
|
||||||
@ -97,10 +97,6 @@ linters-settings:
|
|||||||
# # Exclude godoc examples from forbidigo checks. Default is true.
|
# # Exclude godoc examples from forbidigo checks. Default is true.
|
||||||
# exclude_godoc_examples: false
|
# exclude_godoc_examples: false
|
||||||
|
|
||||||
# funlen:
|
|
||||||
# lines: 60
|
|
||||||
# statements: 40
|
|
||||||
|
|
||||||
# gci:
|
# gci:
|
||||||
# # put imports beginning with prefix after 3rd-party packages;
|
# # put imports beginning with prefix after 3rd-party packages;
|
||||||
# # only support one prefix
|
# # only support one prefix
|
||||||
@ -111,10 +107,6 @@ linters-settings:
|
|||||||
# # minimal code complexity to report, 30 by default (but we recommend 10-20)
|
# # minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
# min-complexity: 10
|
# min-complexity: 10
|
||||||
|
|
||||||
# nestif:
|
|
||||||
# # minimal complexity of if statements to report, 5 by default
|
|
||||||
# min-complexity: 4
|
|
||||||
|
|
||||||
# goconst:
|
# goconst:
|
||||||
# # minimal length of string constant, 3 by default
|
# # minimal length of string constant, 3 by default
|
||||||
# min-len: 3
|
# min-len: 3
|
||||||
@ -205,11 +197,11 @@ linters-settings:
|
|||||||
# # check that each sentence starts with a capital letter
|
# # check that each sentence starts with a capital letter
|
||||||
# capital: false
|
# capital: false
|
||||||
|
|
||||||
# godox:
|
godox:
|
||||||
# # report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
||||||
# # might be left in the code accidentally and should be resolved before merging
|
# might be left in the code accidentally and should be resolved before merging
|
||||||
# keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
|
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
|
||||||
# - XXX
|
- XXX
|
||||||
|
|
||||||
# gofmt:
|
# gofmt:
|
||||||
# # simplify code: gofmt with `-s` option, true by default
|
# # simplify code: gofmt with `-s` option, true by default
|
||||||
@ -329,27 +321,27 @@ linters-settings:
|
|||||||
# # https://staticcheck.io/docs/options#checks
|
# # https://staticcheck.io/docs/options#checks
|
||||||
# checks: [ "all" ]
|
# checks: [ "all" ]
|
||||||
|
|
||||||
# govet:
|
govet:
|
||||||
# # report about shadowed variables
|
# report about shadowed variables
|
||||||
# check-shadowing: true
|
check-shadowing: true
|
||||||
|
|
||||||
# # settings per analyzer
|
# settings per analyzer
|
||||||
# settings:
|
# settings:
|
||||||
# printf: # analyzer name, run `go tool vet help` to see all analyzers
|
# printf: # analyzer name, run `go tool vet help` to see all analyzers
|
||||||
# funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
# funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
||||||
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
|
||||||
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
# enable or disable analyzers by name
|
||||||
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
# run `go tool vet help` to see all analyzers
|
||||||
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
# enable:
|
||||||
|
# - atomicalign
|
||||||
|
enable-all: true
|
||||||
|
# disable-all: false
|
||||||
|
disable:
|
||||||
|
# - shadow
|
||||||
|
- fieldalignment
|
||||||
|
- composites
|
||||||
|
- shadow
|
||||||
|
|
||||||
# # enable or disable analyzers by name
|
|
||||||
# # run `go tool vet help` to see all analyzers
|
|
||||||
# enable:
|
|
||||||
# - atomicalign
|
|
||||||
# enable-all: false
|
|
||||||
# disable:
|
|
||||||
# - shadow
|
|
||||||
# disable-all: false
|
|
||||||
|
|
||||||
# depguard:
|
# depguard:
|
||||||
# list-type: blacklist
|
# list-type: blacklist
|
||||||
|
@ -97,7 +97,9 @@ func parse_user_from_row(row *sql.Row) (scraper.User, error) {
|
|||||||
var u scraper.User
|
var u scraper.User
|
||||||
var joinDate int64
|
var joinDate int64
|
||||||
|
|
||||||
err := row.Scan(&u.ID, &u.DisplayName, &u.Handle, &u.Bio, &u.FollowingCount, &u.FollowersCount, &u.Location, &u.Website, &joinDate, &u.IsPrivate, &u.IsVerified, &u.IsBanned, &u.ProfileImageUrl, &u.ProfileImageLocalPath, &u.BannerImageUrl, &u.BannerImageLocalPath, &u.PinnedTweetID, &u.IsContentDownloaded, &u.IsFollowed)
|
err := row.Scan(&u.ID, &u.DisplayName, &u.Handle, &u.Bio, &u.FollowingCount, &u.FollowersCount, &u.Location, &u.Website, &joinDate,
|
||||||
|
&u.IsPrivate, &u.IsVerified, &u.IsBanned, &u.ProfileImageUrl, &u.ProfileImageLocalPath, &u.BannerImageUrl,
|
||||||
|
&u.BannerImageLocalPath, &u.PinnedTweetID, &u.IsContentDownloaded, &u.IsFollowed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return u, err
|
return u, err
|
||||||
}
|
}
|
||||||
@ -120,7 +122,9 @@ func (p Profile) GetUserByHandle(handle scraper.UserHandle) (scraper.User, error
|
|||||||
db := p.DB
|
db := p.DB
|
||||||
|
|
||||||
stmt, err := db.Prepare(`
|
stmt, err := db.Prepare(`
|
||||||
select id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified, is_banned, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path, pinned_tweet_id, is_content_downloaded, is_followed
|
select id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified,
|
||||||
|
is_banned, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path, pinned_tweet_id,
|
||||||
|
is_content_downloaded, is_followed
|
||||||
from users
|
from users
|
||||||
where lower(handle) = lower(?)
|
where lower(handle) = lower(?)
|
||||||
`)
|
`)
|
||||||
@ -151,7 +155,9 @@ func (p Profile) GetUserByID(id scraper.UserID) (scraper.User, error) {
|
|||||||
db := p.DB
|
db := p.DB
|
||||||
|
|
||||||
stmt, err := db.Prepare(`
|
stmt, err := db.Prepare(`
|
||||||
select id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified, is_banned, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path, pinned_tweet_id, is_content_downloaded, is_followed
|
select id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified,
|
||||||
|
is_banned, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path, pinned_tweet_id,
|
||||||
|
is_content_downloaded, is_followed
|
||||||
from users
|
from users
|
||||||
where id = ?
|
where id = ?
|
||||||
`)
|
`)
|
||||||
|
@ -48,7 +48,10 @@ func (api API) GetFeedFor(user_id UserID, cursor string) (TweetResponse, error)
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
content, _ := ioutil.ReadAll(resp.Body)
|
content, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
s := ""
|
s := ""
|
||||||
for header := range resp.Header {
|
for header := range resp.Header {
|
||||||
s += fmt.Sprintf(" %s: %s\n", header, resp.Header.Get(header))
|
s += fmt.Sprintf(" %s: %s\n", header, resp.Header.Get(header))
|
||||||
@ -133,7 +136,10 @@ func (api API) GetTweet(id TweetID, cursor string) (TweetResponse, error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if !(resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusForbidden) {
|
if !(resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusForbidden) {
|
||||||
content, _ := ioutil.ReadAll(resp.Body)
|
content, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
return TweetResponse{}, fmt.Errorf("Error getting %q. HTTP %s: %s", req.URL, resp.Status, content)
|
return TweetResponse{}, fmt.Errorf("Error getting %q. HTTP %s: %s", req.URL, resp.Status, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +212,10 @@ func (api API) GetUser(handle UserHandle) (APIUser, error) {
|
|||||||
// Sometimes it randomly gives 403 Forbidden. API's fault, not ours
|
// Sometimes it randomly gives 403 Forbidden. API's fault, not ours
|
||||||
// We check for this below
|
// We check for this below
|
||||||
if !(resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusForbidden) {
|
if !(resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusForbidden) {
|
||||||
content, _ := ioutil.ReadAll(resp.Body)
|
content, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
return APIUser{}, fmt.Errorf("response status %s: %s", resp.Status, content)
|
return APIUser{}, fmt.Errorf("response status %s: %s", resp.Status, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +273,10 @@ func (api API) Search(query string, cursor string) (TweetResponse, error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
content, _ := ioutil.ReadAll(resp.Body)
|
content, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
return TweetResponse{}, fmt.Errorf("Error while searching for %q. HTTP %s: %s", req.URL, resp.Status, content)
|
return TweetResponse{}, fmt.Errorf("Error while searching for %q. HTTP %s: %s", req.URL, resp.Status, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,10 @@ func (api API) GetGraphqlFeedFor(user_id UserID, cursor string) (APIV2Response,
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
content, _ := ioutil.ReadAll(resp.Body)
|
content, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
s := ""
|
s := ""
|
||||||
for header := range resp.Header {
|
for header := range resp.Header {
|
||||||
s += fmt.Sprintf(" %s: %s\n", header, resp.Header.Get(header))
|
s += fmt.Sprintf(" %s: %s\n", header, resp.Header.Get(header))
|
||||||
|
@ -34,7 +34,10 @@ func GetGuestToken() (string, error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
content, _ := ioutil.ReadAll(resp.Body)
|
content, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
return "", fmt.Errorf("HTTP %s: %s", resp.Status, content)
|
return "", fmt.Errorf("HTTP %s: %s", resp.Status, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user