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

Integrate GolangCI-Lint #100

Merged
merged 4 commits into from
May 26, 2020
Merged

Integrate GolangCI-Lint #100

merged 4 commits into from
May 26, 2020

Conversation

hanzei
Copy link
Contributor

@hanzei hanzei commented Apr 27, 2020

Summary

Downstream the golangci-lint config from mattermost/mattermost-plugin-starter-template#90 and sync build.

Most changes are straightforward and just style wise. I did comment on the more tricky ones.

Ticket Link

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

@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Apr 27, 2020
@hanzei hanzei requested a review from jfrerich as a code owner April 27, 2020 14:55
@@ -73,10 +73,10 @@ func TestOnConfigurationChange(t *testing.T) {
"same configuration": {
SetupAPI: func() *plugintest.API {
api := &plugintest.API{}
api.On("LoadPluginConfiguration", mock.Anything).Return(nil)
api.On("GetTeams").Return([]*model.Team{&model.Team{Id: teamId}}, nil)
api.On("LoadPluginConfiguration", mock.AnythingOfType("*main.configuration")).Return(nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using mock.AnythingOfType("*main.configuration") is a bit more specific then mock.Anything

Copy link
Member

@agarciamontoro agarciamontoro left a comment

Choose a reason for hiding this comment

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

LGTM! I added a couple of questions below, but nothing blocking.

Comment on lines -88 to +94
return fmt.Errorf("Failed to upload plugin bundle: %s", resp.Error.Error())
return errors.Wrap(resp.Error, "failed to upload plugin bundle")
}

log.Print("Enabling plugin.")
_, resp = client.EnablePlugin(pluginID)
if resp.Error != nil {
return fmt.Errorf("Failed to enable plugin: %s", resp.Error.Error())
return errors.Wrap(resp.Error, "Failed to enable plugin")
Copy link
Member

Choose a reason for hiding this comment

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

Are we enforcing errors.Wrap instead of fmt.Errorf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not, we are not enforcing this, but you are bringing up another great points.

The complain from golangci-lint for the original message is:
error strings should not be capitalized or end with punctuation or a newline (golint), which is actually not fixed with the change. golangci-lint just doesn't find the capitalized message.

But given that build is just a copy from https://github.com/mattermost/mattermost-plugin-starter-template I leaning towards not fixing it in this PR.

server/configuration.go Outdated Show resolved Hide resolved
@@ -47,6 +47,7 @@ func TestServeHTTP(t *testing.T) {

result := w.Result()
require.NotNil(t, result)
defer result.Body.Close()
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@jfrerich jfrerich left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@jfrerich
Copy link
Contributor

@hanzei, I just ran make check-style on this branch and I actually see a failure.

image

@jfrerich jfrerich self-requested a review April 28, 2020 18:37
@hanzei
Copy link
Contributor Author

hanzei commented Apr 28, 2020

@jfrerich What does golangci-lint version say?

@jfrerich
Copy link
Contributor

I've got version 1.25.1. It was released yesterday https://github.com/golangci/golangci-lint/releases

@hanzei
Copy link
Contributor Author

hanzei commented Apr 29, 2020

@jfrerich I'm fairly confident that the failure you are reporting was introduced with golangci/golangci-lint@dfb2278, which is part of v1.25.1 but not v1.25.0. Given that CI is using v1.24.0 and the code in question is part of https://github.com/mattermost/mattermost-plugin-starter-template, I'm leaning toward ignoring the error in this PR and fixing it in https://github.com/mattermost/mattermost-plugin-starter-template.

@jfrerich
Copy link
Contributor

@hanzei, I agree that ignoring is ok if fine. I've added the //nolint comment to ignore the bookmarks plugin repo.

@hanzei
Copy link
Contributor Author

hanzei commented May 1, 2020

@jfrerich Would you please report the gosec issue on https://github.com/mattermost/mattermost-plugin-starter-template?

@jfrerich
Copy link
Contributor

jfrerich commented May 1, 2020

@hanzei. Done.

@hanzei
Copy link
Contributor Author

hanzei commented May 2, 2020

@jfrerich Is there anything that needs to be done in this PR before you approve it?

@jfrerich jfrerich removed the 2: Dev Review Requires review by a core committer label May 4, 2020
@hanzei hanzei requested a review from DHaussermann May 4, 2020 19:14
@hanzei hanzei added this to the v0.7.0 milestone May 25, 2020
@hanzei
Copy link
Contributor Author

hanzei commented May 25, 2020

@DHaussermann This is the last PR that should go into v0.7.0. Maybe it's fine to merge it and do proper testing as part of #106?

@hanzei
Copy link
Contributor Author

hanzei commented May 25, 2020

/update-branch

@codecov-commenter
Copy link

Codecov Report

Merging #100 into master will decrease coverage by 0.02%.
The diff coverage is 47.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
- Coverage   17.10%   17.07%   -0.03%     
==========================================
  Files          14       14              
  Lines        1175     1177       +2     
==========================================
  Hits          201      201              
- Misses        934      935       +1     
- Partials       40       41       +1     
Impacted Files Coverage Δ
server/file_hooks.go 0.00% <0.00%> (ø)
server/http_hooks.go 8.85% <0.00%> (ø)
server/login_hooks.go 0.00% <0.00%> (ø)
server/message_hooks.go 0.00% <0.00%> (ø)
server/user_hooks.go 0.00% <0.00%> (ø)
server/command_hooks.go 9.03% <20.00%> (ø)
server/job.go 50.00% <75.00%> (ø)
server/configuration.go 50.65% <89.47%> (-0.68%) ⬇️
server/activate_hooks.go 75.86% <100.00%> (ø)
server/plugin_message.go 69.23% <100.00%> (ø)

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 3ed574f...c950f8b. Read the comment docs.

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.

I agree with @hanzei
Tested and passed.

  • Ensured there where no build errors
  • Enabled plugin and briefly tested core functionality
  • We can rely on end to end testing pre-release for more thorough test coverage

LGTM!

@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 25, 2020
@hanzei hanzei merged commit 560ea0b into master May 26, 2020
@hanzei hanzei deleted the golangci-lint branch May 26, 2020 11:21
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.

6 participants