mirror of
1
Fork 0

[chore] Update versions, fix lint errors (#1860)

This commit is contained in:
tobi 2023-06-03 13:58:57 +02:00 committed by GitHub
parent 1d4137fb88
commit 21c1552daa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 66 additions and 57 deletions

View File

@ -12,7 +12,7 @@ steps:
# We use golangci-lint for linting. # We use golangci-lint for linting.
# See: https://golangci-lint.run/ # See: https://golangci-lint.run/
- name: lint - name: lint
image: golangci/golangci-lint:v1.51.2 image: golangci/golangci-lint:v1.53.1
volumes: volumes:
- name: go-build-cache - name: go-build-cache
path: /root/.cache/go-build path: /root/.cache/go-build
@ -28,7 +28,7 @@ steps:
- pull_request - pull_request
- name: test - name: test
image: golang:1.20.1-alpine image: golang:1.20.4-alpine
volumes: volumes:
- name: go-build-cache - name: go-build-cache
path: /root/.cache/go-build path: /root/.cache/go-build
@ -44,7 +44,7 @@ steps:
- pull_request - pull_request
- name: web-setup - name: web-setup
image: node:14-alpine image: node:18-alpine
when: when:
event: event:
include: include:
@ -57,7 +57,7 @@ steps:
- yarn --frozen-lockfile --cache-folder /tmp/cache - yarn --frozen-lockfile --cache-folder /tmp/cache
- name: web-lint - name: web-lint
image: node:14-alpine image: node:18-alpine
when: when:
event: event:
include: include:
@ -69,7 +69,7 @@ steps:
- yarn run lint - yarn run lint
- name: web-build - name: web-build
image: node:14-alpine image: node:18-alpine
when: when:
event: event:
include: include:
@ -81,7 +81,7 @@ steps:
- yarn run build - yarn run build
- name: snapshot - name: snapshot
image: superseriousbusiness/gotosocial-drone-build:0.1.0 # https://github.com/superseriousbusiness/gotosocial-drone-build image: superseriousbusiness/gotosocial-drone-build:0.2.0 # https://github.com/superseriousbusiness/gotosocial-drone-build
volumes: volumes:
- name: go-build-cache - name: go-build-cache
path: /root/.cache/go-build path: /root/.cache/go-build
@ -110,7 +110,7 @@ steps:
- main - main
- name: release - name: release
image: superseriousbusiness/gotosocial-drone-build:0.1.0 # https://github.com/superseriousbusiness/gotosocial-drone-build image: superseriousbusiness/gotosocial-drone-build:0.2.0 # https://github.com/superseriousbusiness/gotosocial-drone-build
volumes: volumes:
- name: go-build-cache - name: go-build-cache
path: /root/.cache/go-build path: /root/.cache/go-build
@ -169,7 +169,7 @@ clone:
steps: steps:
- name: mirror - name: mirror
image: superseriousbusiness/gotosocial-drone-build:0.1.0 image: superseriousbusiness/gotosocial-drone-build:0.2.0
environment: environment:
ORIGIN_REPO: https://github.com/superseriousbusiness/gotosocial ORIGIN_REPO: https://github.com/superseriousbusiness/gotosocial
TARGET_REPO: https://codeberg.org/superseriousbusiness/gotosocial TARGET_REPO: https://codeberg.org/superseriousbusiness/gotosocial
@ -182,6 +182,6 @@ steps:
--- ---
kind: signature kind: signature
hmac: b894a72d5912045f74b9c046c7ecd49f2d36bead2a139d85af66a441aa2bc435 hmac: 946c2ffd4e79de07a767ec06ebac0a8ca70a03ce5666aae093c9b0af455041d1
... ...

View File

@ -23,7 +23,9 @@ linters:
- nilerr - nilerr
- revive - revive
# https://golangci-lint.run/usage/linters/#linters-configuration
linters-settings: linters-settings:
# https://golangci-lint.run/usage/linters/#goheader
goheader: goheader:
template: |- template: |-
GoToSocial GoToSocial
@ -42,11 +44,44 @@ linters-settings:
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
# https://golangci-lint.run/usage/linters/#govet
govet: govet:
disable: disable:
- composites - composites
# https://golangci-lint.run/usage/linters/#revive
revive:
rules:
# Enable most default rules.
# See: https://github.com/mgechev/revive/blob/master/defaults.toml
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-naming
- name: error-return
- name: error-strings
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unreachable-code
# Disable below rules.
- name: redefines-builtin-id
disabled: true # This one is just annoying.
- name: unused-parameter
disabled: true # We often pass parameters to fulfil interfaces.
# https://golangci-lint.run/usage/linters/#staticcheck
staticcheck: staticcheck:
# Enable all checks # Enable all checks, but disable SA1012: nil context passing.
# Disable: # See: https://staticcheck.io/docs/configuration/options/#checks
# - SA1012: nil context passing
checks: ["all", "-SA1012"] checks: ["all", "-SA1012"]

View File

@ -3,6 +3,9 @@
"go.lintFlags": [ "go.lintFlags": [
"--fast" "--fast"
], ],
"go.vetFlags": [
"-composites=false ."
],
"eslint.workingDirectories": ["web/source"], "eslint.workingDirectories": ["web/source"],
"eslint.lintTask.enable": true, "eslint.lintTask.enable": true,
"eslint.lintTask.options": "${workspaceFolder}/web/source" "eslint.lintTask.options": "${workspaceFolder}/web/source"

View File

@ -353,9 +353,5 @@ var Password action.GTSAction = func(ctx context.Context) error {
} }
u.EncryptedPassword = string(pw) u.EncryptedPassword = string(pw)
if err := dbConn.UpdateUser(ctx, u, "encrypted_password"); err != nil { return dbConn.UpdateUser(ctx, u, "encrypted_password")
return err
}
return nil
} }

View File

@ -141,9 +141,5 @@ func validateCreateAccount(form *apimodel.AccountCreateRequest) error {
return err return err
} }
if err := validate.SignUpReason(form.Reason, config.GetAccountsReasonRequired()); err != nil { return validate.SignUpReason(form.Reason, config.GetAccountsReasonRequired())
return err
}
return nil
} }

View File

@ -117,7 +117,8 @@ func ErrorHandler(c *gin.Context, errWithCode gtserror.WithCode, instanceGet fun
// or if we should just use a json. Normally we would want to // or if we should just use a json. Normally we would want to
// check for a returned error, but if an error occurs here we // check for a returned error, but if an error occurs here we
// can just fall back to default behavior (serve json error). // can just fall back to default behavior (serve json error).
accept, _ := NegotiateAccept(c, JSONOrHTMLAcceptHeaders...) // Prefer provided offers, fall back to JSON or HTML.
accept, _ := NegotiateAccept(c, append(offers, JSONOrHTMLAcceptHeaders...)...)
if errWithCode.Code() == http.StatusNotFound { if errWithCode.Code() == http.StatusNotFound {
// Use our special not found handler with useful status text. // Use our special not found handler with useful status text.

View File

@ -36,6 +36,7 @@ var SentinelError = errors.New("BUG: error should not be returned") //nolint:rev
// caches, which specifically catches and ignores our sentinel error type. // caches, which specifically catches and ignores our sentinel error type.
func ignoreErrors(err error) bool { func ignoreErrors(err error) bool {
return errorsv2.Comparable( return errorsv2.Comparable(
err,
SentinelError, SentinelError,
context.DeadlineExceeded, context.DeadlineExceeded,
context.Canceled, context.Canceled,

View File

@ -160,7 +160,7 @@ func (b *basicDB) DropTable(ctx context.Context, i interface{}) db.Error {
} }
func (b *basicDB) IsHealthy(ctx context.Context) db.Error { func (b *basicDB) IsHealthy(ctx context.Context) db.Error {
return b.conn.Ping() return b.conn.PingContext(ctx)
} }
func (b *basicDB) Stop(ctx context.Context) db.Error { func (b *basicDB) Stop(ctx context.Context) db.Error {

View File

@ -70,11 +70,7 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
return errors.New("Reject: follow object account and inbox account were not the same") return errors.New("Reject: follow object account and inbox account were not the same")
} }
if err := f.state.DB.RejectFollowRequest(ctx, followReq.AccountID, followReq.TargetAccountID); err != nil { return f.state.DB.RejectFollowRequest(ctx, followReq.AccountID, followReq.TargetAccountID)
return err
}
return nil
} }
} }
@ -90,20 +86,19 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
if !ok { if !ok {
return errors.New("Reject: couldn't parse follow into vocab.ActivityStreamsFollow") return errors.New("Reject: couldn't parse follow into vocab.ActivityStreamsFollow")
} }
// convert the follow to something we can understand // convert the follow to something we can understand
gtsFollow, err := f.typeConverter.ASFollowToFollow(ctx, asFollow) gtsFollow, err := f.typeConverter.ASFollowToFollow(ctx, asFollow)
if err != nil { if err != nil {
return fmt.Errorf("Reject: error converting asfollow to gtsfollow: %s", err) return fmt.Errorf("Reject: error converting asfollow to gtsfollow: %s", err)
} }
// make sure the addressee of the original follow is the same as whatever inbox this landed in // make sure the addressee of the original follow is the same as whatever inbox this landed in
if gtsFollow.AccountID != receivingAccount.ID { if gtsFollow.AccountID != receivingAccount.ID {
return errors.New("Reject: follow object account and inbox account were not the same") return errors.New("Reject: follow object account and inbox account were not the same")
} }
if err := f.state.DB.RejectFollowRequest(ctx, gtsFollow.AccountID, gtsFollow.TargetAccountID); err != nil {
return err
}
return nil return f.state.DB.RejectFollowRequest(ctx, gtsFollow.AccountID, gtsFollow.TargetAccountID)
} }
} }

View File

@ -72,8 +72,6 @@ func (gts *gotosocial) Stop(ctx context.Context) error {
if err := gts.apiRouter.Stop(ctx); err != nil { if err := gts.apiRouter.Stop(ctx); err != nil {
return err return err
} }
if err := gts.db.Stop(ctx); err != nil {
return err return gts.db.Stop(ctx)
}
return nil
} }

View File

@ -434,11 +434,7 @@ func (p *Processor) wipeStatus(ctx context.Context, statusToDelete *gtsmodel.Sta
} }
// delete the status itself // delete the status itself
if err := p.state.DB.DeleteStatusByID(ctx, statusToDelete.ID); err != nil { return p.state.DB.DeleteStatusByID(ctx, statusToDelete.ID)
return err
}
return nil
} }
// deleteStatusFromTimelines completely removes the given status from all timelines. // deleteStatusFromTimelines completely removes the given status from all timelines.

View File

@ -167,11 +167,7 @@ func (p *Processor) processCreateStatusFromFederator(ctx context.Context, federa
} }
} }
if err := p.timelineAndNotifyStatus(ctx, status); err != nil { return p.timelineAndNotifyStatus(ctx, status)
return err
}
return nil
} }
// processCreateFaveFromFederator handles Activity Create and Object Like // processCreateFaveFromFederator handles Activity Create and Object Like
@ -208,11 +204,7 @@ func (p *Processor) processCreateFaveFromFederator(ctx context.Context, federato
incomingFave.Account = a incomingFave.Account = a
} }
if err := p.notifyFave(ctx, incomingFave); err != nil { return p.notifyFave(ctx, incomingFave)
return err
}
return nil
} }
// processCreateFollowRequestFromFederator handles Activity Create and Object Follow // processCreateFollowRequestFromFederator handles Activity Create and Object Follow
@ -327,11 +319,7 @@ func (p *Processor) processCreateAnnounceFromFederator(ctx context.Context, fede
return err return err
} }
if err := p.notifyAnnounce(ctx, incomingAnnounce); err != nil { return p.notifyAnnounce(ctx, incomingAnnounce)
return err
}
return nil
} }
// processCreateBlockFromFederator handles Activity Create and Object Block // processCreateBlockFromFederator handles Activity Create and Object Block