Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
TERM: xterm
GO_VERSION: 1.19.6
GO_VERSION: 1.24.5
NODE_VERSION: 16.15.0

jobs:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
fi

- name: ci/upload-artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: dist
path: |
Expand Down
133 changes: 87 additions & 46 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,103 @@
version: "2"
run:
timeout: 5m
modules-download-mode: readonly

linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: github.com/mattermost/mattermost-plugin-apps
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
misspell:
locale: US

linters:
disable-all: true
default: none
enable:
- bodyclose
- errcheck
- gocritic
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- staticcheck
- stylecheck
- revive
- typecheck
- staticcheck
- unconvert
- unused
- unparam
- unused
- whitespace

issues:
exclude-rules:
- path: _test\.go
linters:
- bodyclose
- scopelint # https://github.com/kyoh86/scopelint/issues/4
- path: test/restapitest
linters:
- bodyclose
- unused
- unparam
- staticcheck
- path: /
linters:
- staticcheck
text: "BotJoined"
- path: /
linters:
- staticcheck
text: "BotLeft"


settings:
govet:
disable:
- fieldalignment
enable-all: true
misspell:
locale: US
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- bodyclose
- scopelint
path: _test\.go
- linters:
- bodyclose
- staticcheck
- unparam
- unused
path: test/restapitest
- linters:
- staticcheck
path: /
text: BotJoined
# The follow execptions got added as part of the migration to go1.24.
# We should revisit them in the future.
- linters:
- staticcheck
path: /
text: BotLeft
# Ignore QF1008: embedded field selector suggestions
- linters:
- staticcheck
text: "QF1008: could remove embedded field"
# Ignore unused parameter suggestions
- linters:
- revive
text: "unused-parameter:"
# Ignore receiver naming suggestions
- linters:
- revive
text: "receiver-naming:"
# Ignore unparam warnings about always receiving same value
- linters:
- unparam
text: "always receives"
# Ignore G115 integer overflow conversion warnings
- linters:
- gosec
text: "G115: integer overflow conversion"
# Ignore QF1008 selector simplification suggestions
- linters:
- staticcheck
text: "QF1008: could simplify selectors"
# Ignore var-naming warnings
- linters:
- revive
text: "var-naming: avoid meaningless package names"
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
goimports:
local-prefixes:
- github.com/mattermost/mattermost-plugin-apps
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ all: check-style test dist

.PHONY: deps
deps:
@$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
@$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.1
@$(GO) install github.com/nicksnyder/go-i18n/v2/goi18n@v2.2.0

## Runs eslint and golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion apps/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type OAuth2App struct {

// Data allows apps to store custom data in their OAuth configuration. A
// frequent use case is storing app-level service account credentials.
Data interface{} `json:"data,omitempty"`
Data any `json:"data,omitempty"`
}

// ListedApp is a Mattermost App listed in the Marketplace containing metadata.
Expand Down
13 changes: 6 additions & 7 deletions apps/appclient/mattermost_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package appclient

import (
"context"
"fmt"
"net/http"

"github.com/mattermost/mattermost/server/public/model"
Expand Down Expand Up @@ -45,7 +44,7 @@ func NewClient(token, mattermostSiteURL string) *Client {
return &c
}

func (c *Client) KVSet(prefix, id string, in interface{}) (bool, error) {
func (c *Client) KVSet(prefix, id string, in any) (bool, error) {
changed, res, err := c.ClientPP.KVSet(prefix, id, in)
if err != nil {
return false, err
Expand All @@ -58,7 +57,7 @@ func (c *Client) KVSet(prefix, id string, in interface{}) (bool, error) {
return changed, nil
}

func (c *Client) KVGet(prefix, id string, ref interface{}) error {
func (c *Client) KVGet(prefix, id string, ref any) error {
res, err := c.ClientPP.KVGet(prefix, id, ref)
if err != nil {
return err
Expand Down Expand Up @@ -149,7 +148,7 @@ func (c *Client) StoreOAuth2App(oauth2App apps.OAuth2App) error {
return nil
}

func (c *Client) StoreOAuth2User(ref interface{}) error {
func (c *Client) StoreOAuth2User(ref any) error {
res, err := c.ClientPP.StoreOAuth2User(ref)
if err != nil {
return err
Expand All @@ -162,7 +161,7 @@ func (c *Client) StoreOAuth2User(ref interface{}) error {
return nil
}

func (c *Client) GetOAuth2User(ref interface{}) error {
func (c *Client) GetOAuth2User(ref any) error {
res, err := c.ClientPP.GetOAuth2User(ref)
if err != nil {
return err
Expand Down Expand Up @@ -201,9 +200,9 @@ func (c *Client) CreatePost(ctx context.Context, post *model.Post) (*model.Post,
return createdPost, nil
}

func (c *Client) DM(ctx context.Context, userID string, format string, args ...interface{}) (*model.Post, error) {
func (c *Client) DM(ctx context.Context, userID string, msg string) (*model.Post, error) {
return c.DMPost(ctx, userID, &model.Post{
Message: fmt.Sprintf(format, args...),
Message: msg,
})
}

Expand Down
10 changes: 5 additions & 5 deletions apps/appclient/mattermost_client_pp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func (c *ClientPP) SetOAuthToken(token string) {
c.AuthType = model.HeaderBearer
}

func (c *ClientPP) KVSet(prefix, id string, in interface{}) (bool, *model.Response, error) {
func (c *ClientPP) KVSet(prefix, id string, in any) (bool, *model.Response, error) {
r, err := c.DoAPIPOST(c.kvpath(prefix, id), utils.ToJSON(in)) // nolint:bodyclose
if err != nil {
return false, model.BuildResponse(r), err
}
defer c.closeBody(r)

var out map[string]interface{}
var out map[string]any
if err := json.NewDecoder(r.Body).Decode(&out); err != nil {
return false, model.BuildResponse(r), errors.Wrap(err, "failed to decode response")
}
Expand All @@ -74,7 +74,7 @@ func (c *ClientPP) KVSet(prefix, id string, in interface{}) (bool, *model.Respon
return changed, model.BuildResponse(r), nil
}

func (c *ClientPP) KVGet(prefix, id string, ref interface{}) (*model.Response, error) {
func (c *ClientPP) KVGet(prefix, id string, ref any) (*model.Response, error) {
r, err := c.DoAPIGET(c.kvpath(prefix, id), "") // nolint:bodyclose
if err != nil {
return model.BuildResponse(r), err
Expand Down Expand Up @@ -172,7 +172,7 @@ func (c *ClientPP) StoreOAuth2App(oauth2App apps.OAuth2App) (*model.Response, er
return model.BuildResponse(r), nil
}

func (c *ClientPP) StoreOAuth2User(ref interface{}) (*model.Response, error) {
func (c *ClientPP) StoreOAuth2User(ref any) (*model.Response, error) {
r, err := c.DoAPIPOST(c.apipath(appspath.OAuth2User), utils.ToJSON(ref)) // nolint:bodyclose
if err != nil {
return model.BuildResponse(r), err
Expand All @@ -182,7 +182,7 @@ func (c *ClientPP) StoreOAuth2User(ref interface{}) (*model.Response, error) {
return model.BuildResponse(r), nil
}

func (c *ClientPP) GetOAuth2User(ref interface{}) (*model.Response, error) {
func (c *ClientPP) GetOAuth2User(ref any) (*model.Response, error) {
r, err := c.DoAPIGET(c.apipath(appspath.OAuth2User), "") // nolint:bodyclose
if err != nil {
return model.BuildResponse(r), err
Expand Down
18 changes: 9 additions & 9 deletions apps/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Call struct {
Expand *Expand `json:"expand,omitempty"`

// Custom data that will be passed to the function in JSON, "as is".
State interface{} `json:"state,omitempty"`
State any `json:"state,omitempty"`
}

func (c *Call) UnmarshalJSON(data []byte) error {
Expand All @@ -43,9 +43,9 @@ func (c *Call) UnmarshalJSON(data []byte) error {

// Need a type that is just like Call, but without UnmarshalJSON
structValue := struct {
Path string `json:"path,omitempty"`
Expand *Expand `json:"expand,omitempty"`
State interface{} `json:"state,omitempty"`
Path string `json:"path,omitempty"`
Expand *Expand `json:"expand,omitempty"`
State any `json:"state,omitempty"`
}{}
err = json.Unmarshal(data, &structValue)
if err != nil {
Expand Down Expand Up @@ -83,7 +83,7 @@ func (c Call) ExpandActingUserClient() *Call {
return &c
}

func (c Call) WithState(state interface{}) *Call {
func (c Call) WithState(state any) *Call {
c.State = state
return &c
}
Expand Down Expand Up @@ -126,8 +126,8 @@ func (c *Call) PartialCopy() *Call {
}

// Only know how to clone map values for State.
if state, ok := clone.State.(map[string]interface{}); ok {
cloneState := map[string]interface{}{}
if state, ok := clone.State.(map[string]any); ok {
cloneState := map[string]any{}
for k, v := range state {
cloneState[k] = v
}
Expand All @@ -154,8 +154,8 @@ func (c Call) String() string {
return s
}

func (c Call) Loggable() []interface{} {
props := []interface{}{"call_path", c.Path}
func (c Call) Loggable() []any {
props := []any{"call_path", c.Path}
if c.Expand != nil {
props = append(props, "call_expand", c.Expand.String())
}
Expand Down
Loading
Loading