diff --git a/.golangci.yml b/.golangci.yml index c46ed4dc8..c0e230a14 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,8 +7,6 @@ linters-settings: simplify: true goimports: local-prefixes: github.com/mattermost/mattermost-plugin-github - golint: - min-confidence: 0 govet: check-shadowing: true enable-all: true @@ -16,30 +14,31 @@ linters-settings: - fieldalignment misspell: locale: US + revive: + rules: + - name: error-strings + disabled: true linters: disable-all: true enable: - bodyclose - - deadcode - errcheck - gocritic - gofmt - goimports - - golint - gosec - gosimple - govet - ineffassign - misspell - nakedret + - revive - staticcheck - - structcheck - stylecheck - typecheck - unconvert - unused - - varcheck - whitespace issues: diff --git a/Makefile b/Makefile index 856a84456..128853f45 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,7 @@ endif ## Ensures NPM dependencies are installed without having to run this all the time. webapp/node_modules: $(wildcard webapp/package.json) ifneq ($(HAS_WEBAPP),) - cd webapp && $(NPM) install --verbose + cd webapp && $(NPM) install touch $@ endif diff --git a/plugin.json b/plugin.json index 5fdd86bc9..a1dc75688 100644 --- a/plugin.json +++ b/plugin.json @@ -4,9 +4,9 @@ "description": "GitHub plugin for Mattermost.", "homepage_url": "https://github.com/mattermost/mattermost-plugin-github", "support_url": "https://github.com/mattermost/mattermost-plugin-github/issues", - "release_notes_url": "https://github.com/mattermost/mattermost-plugin-github/releases/tag/v2.1.2", + "release_notes_url": "https://github.com/mattermost/mattermost-plugin-github/releases/tag/v2.1.3", "icon_path": "assets/icon.svg", - "version": "2.1.2", + "version": "2.1.3", "min_server_version": "6.5.0", "server": { "executables": { diff --git a/server/client/client.go b/server/client/client.go index b4c69fb45..4320c6542 100644 --- a/server/client/client.go +++ b/server/client/client.go @@ -2,7 +2,7 @@ package client import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" "strings" @@ -73,7 +73,7 @@ func (c *Client) GetConfiguration() (*plugin.Configuration, error) { } defer resp.Body.Close() - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, err } @@ -110,7 +110,7 @@ func (c *Client) GetToken(userID string) (*oauth2.Token, error) { } defer resp.Body.Close() - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/server/client/client_test.go b/server/client/client_test.go index 49b9f739c..a33a17f44 100644 --- a/server/client/client_test.go +++ b/server/client/client_test.go @@ -3,7 +3,7 @@ package client import ( "bytes" "encoding/json" - "io/ioutil" + "io" "net/http" "testing" @@ -57,7 +57,7 @@ func TestGetConfiguration(t *testing.T) { require.NoError(t, err) pluginAPI := &plugintest.API{} - pluginAPI.On("PluginHTTP", mock.AnythingOfType("*http.Request")).Return(&http.Response{StatusCode: http.StatusOK, Body: ioutil.NopCloser(b)}) + pluginAPI.On("PluginHTTP", mock.AnythingOfType("*http.Request")).Return(&http.Response{StatusCode: http.StatusOK, Body: io.NopCloser(b)}) defer pluginAPI.AssertExpectations(t) client := NewPluginClient(pluginAPI) @@ -91,7 +91,7 @@ func TestGetToken(t *testing.T) { require.NoError(t, err) pluginAPI := &plugintest.API{} - pluginAPI.On("PluginHTTP", mock.AnythingOfType("*http.Request")).Return(&http.Response{StatusCode: http.StatusOK, Body: ioutil.NopCloser(b)}) + pluginAPI.On("PluginHTTP", mock.AnythingOfType("*http.Request")).Return(&http.Response{StatusCode: http.StatusOK, Body: io.NopCloser(b)}) defer pluginAPI.AssertExpectations(t) client := NewPluginClient(pluginAPI) diff --git a/server/plugin/api_test.go b/server/plugin/api_test.go index fa6120ffc..8aaa5bd89 100644 --- a/server/plugin/api_test.go +++ b/server/plugin/api_test.go @@ -2,7 +2,6 @@ package plugin import ( "io" - "io/ioutil" "net/http" "net/http/httptest" "testing" @@ -48,7 +47,7 @@ func TestWithRecovery(t *testing.T) { resp := w.Result() if resp.Body != nil { defer resp.Body.Close() - _, err := io.Copy(ioutil.Discard, resp.Body) + _, err := io.Copy(io.Discard, resp.Body) require.NoError(t, err) } } diff --git a/server/plugin/subscriptions.go b/server/plugin/subscriptions.go index 8ecd651aa..9ea7c1e0e 100644 --- a/server/plugin/subscriptions.go +++ b/server/plugin/subscriptions.go @@ -121,7 +121,7 @@ func (p *Plugin) Subscribe(ctx context.Context, githubClient *github.Client, use } if flags.ExcludeOrgMembers && !p.isOrganizationLocked() { - return errors.Errorf("Unable to set --exclude-org-member flag. The GitHub plugin is not locked to a single organization.") + return errors.New("Unable to set --exclude-org-member flag. The GitHub plugin is not locked to a single organization.") } var err error diff --git a/server/plugin/template.go b/server/plugin/template.go index c59e32db5..7ec52bc89 100644 --- a/server/plugin/template.go +++ b/server/plugin/template.go @@ -15,12 +15,14 @@ const mdCommentRegexPattern string = `()` // There is no public documentation of what constitutes a GitHub username, but // according to the error messages returned in https://github.com/join, it must: -// 1. be between 1 and 39 characters long. -// 2. contain only alphanumeric characters or non-adjacent hyphens. -// 3. not begin or end with a hyphen. +// 1. be between 1 and 39 characters long. +// 2. contain only alphanumeric characters or non-adjacent hyphens. +// 3. not begin or end with a hyphen. +// // When matching a valid GitHub username in the body of messages, it must: -// 4. not be preceded by an underscore, a backtick (that cryptic \x60) or an -// alphanumeric character. +// 4. not be preceded by an underscore, a backtick (that cryptic \x60) or an +// alphanumeric character. +// // Ensuring the maximum length is not trivial without lookaheads, so this // regexp ensures only the minimum length, besides points 2, 3 and 4. // Note that the username, with the @ sign, is in the second capturing group. diff --git a/webapp/webpack.config.js b/webapp/webpack.config.js index 7875758ef..1e8352566 100644 --- a/webapp/webpack.config.js +++ b/webapp/webpack.config.js @@ -81,6 +81,7 @@ module.exports = { }, externals: { react: 'React', + 'react-dom': 'ReactDOM', redux: 'Redux', 'react-redux': 'ReactRedux', 'prop-types': 'PropTypes',