Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable more linters #252

Merged
merged 19 commits into from
May 22, 2020
Merged

Enable more linters #252

merged 19 commits into from
May 22, 2020

Conversation

hanzei
Copy link
Contributor

@hanzei hanzei commented Apr 25, 2020

Summary

This PR sync the golangci-lint config with the one from other repos. Hence, a lot of new linter got enabled. The config file is synced with mattermost/mattermost-plugin-starter-template#90.

Given the high number of changed lines, I tried to break the changes into multiple commits.

While most changes are just stylistic, I did comment on the more tricky one.

Ticket Link

Follow up on mattermost-community/mattermost-plugin-autolink#108

@hanzei hanzei added the Work In Progress Not yet ready for review label Apr 25, 2020
@hanzei hanzei added this to the v1.0.0 milestone Apr 25, 2020
@codecov-io
Copy link

codecov-io commented Apr 27, 2020

Codecov Report

Merging #252 into master will decrease coverage by 0.27%.
The diff coverage is 7.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #252      +/-   ##
==========================================
- Coverage   19.69%   19.42%   -0.28%     
==========================================
  Files          10       10              
  Lines        2178     2193      +15     
==========================================
- Hits          429      426       -3     
- Misses       1725     1742      +17     
- Partials       24       25       +1     
Impacted Files Coverage Δ
server/configuration.go 32.25% <0.00%> (ø)
server/permalinks.go 77.14% <ø> (ø)
server/plugin.go 4.30% <0.00%> (-0.36%) ⬇️
server/webhook.go 0.00% <0.00%> (ø)
server/command.go 10.11% <5.26%> (+0.05%) ⬆️
server/subscriptions.go 10.97% <9.09%> (+0.13%) ⬆️
server/api.go 6.88% <11.66%> (+0.15%) ⬆️
server/utils.go 61.32% <50.00%> (-0.64%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9fcc0ad...2b10008. Read the comment docs.

@hanzei hanzei changed the title Enable for linters Enable more linters Apr 27, 2020
Comment on lines +63 to +65
- path: server/webhook.go
linters:
- goconst
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are so many action types like "opened" in server/webhook.go that refactoring them into const's did make the code more readable.

go.mod Outdated
Comment on lines 5 to 12
require (
github.com/Masterminds/sprig/v3 v3.0.2
github.com/google/go-github/v25 v25.1.1
github.com/Masterminds/sprig/v3 v3.1.0
github.com/google/go-github/v31 v31.0.0
github.com/gorilla/mux v1.7.4
github.com/mattermost/mattermost-server/v5 v5.18.0
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.4.0
github.com/mattermost/mattermost-server/v5 v5.22.0
github.com/mholt/archiver/v3 v3.3.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.5.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did also include an dependency update into this PR to help keep the number of PRs QA has to review low.

func (p *Plugin) CreateBotDMPost(userID, message, postType string) *model.AppError {
// CreateBotDMPost posts a direct message using the bot account.
// Any error are not returned and instead logged.
func (p *Plugin) CreateBotDMPost(userID, message, postType string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omitting the returned error and logging it instead just make the caller code simplere.

@@ -360,7 +359,7 @@ func TestPushedCommitsTemplate(t *testing.T) {
Repo: &pushEventRepository,
Sender: &user,
Forced: bToP(true),
Commits: []github.PushEventCommit{
Commits: []*github.HeadCommit{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github.PushEventCommit was removed from github.com/google/go-github. It's just a naming change.

server/webhook.go Outdated Show resolved Hide resolved
@hanzei
Copy link
Contributor Author

hanzei commented Apr 27, 2020

@bakurits Given that you touched a lot of the code base lately, a review from you would be appreciated.

@hanzei hanzei requested a review from larkox April 27, 2020 15:12
@hanzei hanzei added 2: Dev Review Requires review by a core committer and removed Work In Progress Not yet ready for review labels Apr 27, 2020
@hanzei hanzei requested a review from agnivade April 27, 2020 15:12
server/api.go Outdated Show resolved Hide resolved
server/plugin.go Outdated Show resolved Hide resolved
server/subscriptions.go Outdated Show resolved Hide resolved
server/subscriptions.go Outdated Show resolved Hide resolved
server/subscriptions.go Outdated Show resolved Hide resolved
server/webhook.go Show resolved Hide resolved
Copy link
Member

@agnivade agnivade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Just some minor comments.

server/plugin.go Show resolved Hide resolved
server/subscriptions.go Outdated Show resolved Hide resolved
server/webhook.go Outdated Show resolved Hide resolved
build/deploy/main.go Show resolved Hide resolved
build/manifest/main.go Show resolved Hide resolved
@hanzei hanzei requested a review from agnivade May 2, 2020 11:21
@hanzei hanzei mentioned this pull request May 2, 2020
Copy link
Contributor

@larkox larkox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

server/api_test.go Show resolved Hide resolved
server/command.go Show resolved Hide resolved
@hanzei hanzei added Work In Progress Not yet ready for review and removed 2: Dev Review Requires review by a core committer labels May 11, 2020
@hanzei
Copy link
Contributor Author

hanzei commented May 11, 2020

Waiting to merge some community PRs to not cause to many merge conflicts.

@hanzei hanzei added 3: QA Review Requires review by a QA tester Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) and removed Work In Progress Not yet ready for review labels May 11, 2020
@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #252 into master will decrease coverage by 0.36%.
The diff coverage is 7.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #252      +/-   ##
==========================================
- Coverage   18.50%   18.13%   -0.37%     
==========================================
  Files          10       10              
  Lines        2340     2371      +31     
==========================================
- Hits          433      430       -3     
- Misses       1883     1916      +33     
- Partials       24       25       +1     
Impacted Files Coverage Δ
server/configuration.go 32.25% <0.00%> (ø)
server/plugin.go 4.27% <0.00%> (-0.18%) ⬇️
server/webhook.go 0.00% <0.00%> (ø)
server/command.go 10.11% <5.26%> (+0.05%) ⬆️
server/subscriptions.go 10.97% <9.09%> (+0.13%) ⬆️
server/api.go 5.72% <10.16%> (-0.13%) ⬇️
server/utils.go 61.32% <50.00%> (-0.64%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b124fd0...592a5e6. Read the comment docs.

@hanzei hanzei removed the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label May 19, 2020
@jfrerich jfrerich mentioned this pull request May 19, 2020
@hanzei hanzei requested a review from DHaussermann May 19, 2020 18:35
@hanzei
Copy link
Contributor Author

hanzei commented May 19, 2020

@DHaussermann This PR is ready for review. Given a lot of files got touched, please do a general test. Especially take a look at the interaction between the webapp and server, e.g. creating issue, RHS, LHS, etc.

@hanzei
Copy link
Contributor Author

hanzei commented May 20, 2020

@DHaussermann The testing for this PR and the testing for the release are basically the same: Test everything. With that in mind, I'm wondering if you would be fine merging the PR as it is. By merging early double testing gets avoided.

Copy link

@DHaussermann DHaussermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and passed

  • No issues with build or deploy
  • Briefly smoke tested focusing on LHS, RHS and post menu options
  • No issues found

LGTM!
No changes need to release testing.

@DHaussermann DHaussermann added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels May 21, 2020
@hanzei hanzei merged commit 553bdea into master May 22, 2020
@hanzei hanzei deleted the golangci-lint branch May 22, 2020 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants