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
11 changes: 5 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,38 @@ linters-settings:
simplify: true
goimports:
local-prefixes: github.com/mattermost/mattermost-plugin-github
golint:
min-confidence: 0
govet:
check-shadowing: true
enable-all: true
disable:
- 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:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions server/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package client

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions server/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"bytes"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions server/plugin/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package plugin

import (
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/plugin/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions server/plugin/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const mdCommentRegexPattern string = `(<!--[\S\s]+?-->)`

// 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.
Expand Down
1 change: 1 addition & 0 deletions webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module.exports = {
},
externals: {
react: 'React',
'react-dom': 'ReactDOM',
redux: 'Redux',
'react-redux': 'ReactRedux',
'prop-types': 'PropTypes',
Expand Down