mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-11 03:28:07 -06:00
Enable stricter linting with golangci-lint (#316)
* update golangci-lint * add golangci config file w/ more linters * correct issues flagged by stricter linters * add more generous timeout for golangci-lint * add some style + formatting guidelines * move timeout to config file * go fmt
This commit is contained in:
parent
38d73f0316
commit
f8630348b4
47 changed files with 227 additions and 163 deletions
|
|
@ -127,7 +127,7 @@ func (t *timeline) GetXFromTop(ctx context.Context, amount int) ([]*apimodel.Sta
|
|||
return nil, errors.New("GetXFromTop: could not parse e as a preparedPostsEntry")
|
||||
}
|
||||
statuses = append(statuses, entry.prepared)
|
||||
served = served + 1
|
||||
served++
|
||||
if served >= amount {
|
||||
break
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ func (t *timeline) GetXBehindID(ctx context.Context, amount int, behindID string
|
|||
})
|
||||
|
||||
newAttempts := *attempts
|
||||
newAttempts = newAttempts + 1
|
||||
newAttempts++
|
||||
attempts = &newAttempts
|
||||
|
||||
// make a slice of statuses with the length we need to return
|
||||
|
|
@ -161,7 +161,7 @@ func (t *timeline) GetXBehindID(ctx context.Context, amount int, behindID string
|
|||
|
||||
findMarkLoop:
|
||||
for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() {
|
||||
position = position + 1
|
||||
position++
|
||||
entry, ok := e.Value.(*preparedPostsEntry)
|
||||
if !ok {
|
||||
return nil, errors.New("GetXBehindID: could not parse e as a preparedPostsEntry")
|
||||
|
|
@ -218,7 +218,7 @@ serveloop:
|
|||
|
||||
// serve up to the amount requested
|
||||
statuses = append(statuses, entry.prepared)
|
||||
served = served + 1
|
||||
served++
|
||||
if served >= amount {
|
||||
break serveloop
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ findMarkLoop:
|
|||
|
||||
// serve up to the amount requested
|
||||
statuses = append(statuses, entry.prepared)
|
||||
served = served + 1
|
||||
served++
|
||||
if served >= amount {
|
||||
break serveloopFromTop
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@ findMarkLoop:
|
|||
|
||||
// serve up to the amount requested
|
||||
statuses = append(statuses, entry.prepared)
|
||||
served = served + 1
|
||||
served++
|
||||
if served >= amount {
|
||||
break serveloopFromBottom
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ func (t *timeline) GetXBetweenID(ctx context.Context, amount int, behindID strin
|
|||
var behindIDMark *list.Element
|
||||
findMarkLoop:
|
||||
for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() {
|
||||
position = position + 1
|
||||
position++
|
||||
entry, ok := e.Value.(*preparedPostsEntry)
|
||||
if !ok {
|
||||
return nil, errors.New("GetXBetweenID: could not parse e as a preparedPostsEntry")
|
||||
|
|
@ -350,7 +350,7 @@ serveloop:
|
|||
|
||||
// serve up to the amount requested
|
||||
statuses = append(statuses, entry.prepared)
|
||||
served = served + 1
|
||||
served++
|
||||
if served >= amount {
|
||||
break serveloop
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func (t *timeline) IndexBefore(ctx context.Context, statusID string, include boo
|
|||
|
||||
i := 0
|
||||
grabloop:
|
||||
for ; len(filtered) < amount && i < 5; i = i + 1 { // try the grabloop 5 times only
|
||||
for ; len(filtered) < amount && i < 5; i++ { // try the grabloop 5 times only
|
||||
statuses, err := t.db.GetHomeTimeline(ctx, t.accountID, "", "", offsetStatus, amount, false)
|
||||
if err != nil {
|
||||
if err == db.ErrNoEntries {
|
||||
|
|
@ -129,7 +129,7 @@ positionLoop:
|
|||
|
||||
i := 0
|
||||
grabloop:
|
||||
for ; len(filtered) < amount && i < 5; i = i + 1 { // try the grabloop 5 times only
|
||||
for ; len(filtered) < amount && i < 5; i++ { // try the grabloop 5 times only
|
||||
l.Tracef("entering grabloop; i is %d; len(filtered) is %d", i, len(filtered))
|
||||
statuses, err := t.db.GetHomeTimeline(ctx, t.accountID, offsetStatus, "", "", amount, false)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func (p *postIndex) insertIndexed(i *postIndexEntry) (bool, error) {
|
|||
// We need to iterate through the index to make sure we put this post in the appropriate place according to when it was created.
|
||||
// We also need to make sure we're not inserting a duplicate post -- this can happen sometimes and it's not nice UX (*shudder*).
|
||||
for e := p.data.Front(); e != nil; e = e.Next() {
|
||||
position = position + 1
|
||||
position++
|
||||
|
||||
entry, ok := e.Value.(*postIndexEntry)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ prepareloop:
|
|||
// we're done
|
||||
break prepareloop
|
||||
}
|
||||
prepared = prepared + 1
|
||||
prepared++
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ prepareloop:
|
|||
// we're done
|
||||
break prepareloop
|
||||
}
|
||||
prepared = prepared + 1
|
||||
prepared++
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ prepareloop:
|
|||
continue
|
||||
}
|
||||
|
||||
prepared = prepared + 1
|
||||
prepared++
|
||||
if prepared == amount {
|
||||
// we're done
|
||||
l.Trace("leaving prepareloop")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func (p *preparedPosts) insertPrepared(i *preparedPostsEntry) error {
|
|||
// We need to iterate through the index to make sure we put this post in the appropriate place according to when it was created.
|
||||
// We also need to make sure we're not inserting a duplicate post -- this can happen sometimes and it's not nice UX (*shudder*).
|
||||
for e := p.data.Front(); e != nil; e = e.Next() {
|
||||
position = position + 1
|
||||
position++
|
||||
|
||||
entry, ok := e.Value.(*preparedPostsEntry)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func (t *timeline) Remove(ctx context.Context, statusID string) (int, error) {
|
|||
}
|
||||
for _, e := range removeIndexes {
|
||||
t.postIndex.data.Remove(e)
|
||||
removed = removed + 1
|
||||
removed++
|
||||
}
|
||||
|
||||
// remove entr(ies) from prepared posts
|
||||
|
|
@ -71,7 +71,7 @@ func (t *timeline) Remove(ctx context.Context, statusID string) (int, error) {
|
|||
}
|
||||
for _, e := range removePrepared {
|
||||
t.preparedPosts.data.Remove(e)
|
||||
removed = removed + 1
|
||||
removed++
|
||||
}
|
||||
|
||||
l.Debugf("removed %d entries", removed)
|
||||
|
|
@ -104,7 +104,7 @@ func (t *timeline) RemoveAllBy(ctx context.Context, accountID string) (int, erro
|
|||
}
|
||||
for _, e := range removeIndexes {
|
||||
t.postIndex.data.Remove(e)
|
||||
removed = removed + 1
|
||||
removed++
|
||||
}
|
||||
|
||||
// remove entr(ies) from prepared posts
|
||||
|
|
@ -123,7 +123,7 @@ func (t *timeline) RemoveAllBy(ctx context.Context, accountID string) (int, erro
|
|||
}
|
||||
for _, e := range removePrepared {
|
||||
t.preparedPosts.data.Remove(e)
|
||||
removed = removed + 1
|
||||
removed++
|
||||
}
|
||||
|
||||
l.Debugf("removed %d entries", removed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue