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 #108

Merged
merged 1 commit into from Apr 23, 2020
Merged

Integrate GolangCI-Lint #108

merged 1 commit into from Apr 23, 2020

Conversation

hanzei
Copy link
Contributor

@hanzei hanzei commented Apr 16, 2020

Summary

This PR copies most of the golangci-lint configuration from mattermost/mattermost-plugin-starter-template#90 into this repo. This helps with a consistent code style and should improve code quality over time.

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

This is an example PR on how to integrate GolangCI-Lint. It should be used as an example for other plugins also adopting the tool.

@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Apr 16, 2020
@hanzei hanzei added this to the v1.3.0 milestone Apr 16, 2020
@hanzei hanzei requested review from iomodo and levb as code owners April 16, 2020 11:27
@hanzei hanzei added this to Submitted in Integrations Team via automation Apr 16, 2020
Comment on lines -58 to -70
func (h *Handler) handleErrorWithCode(w http.ResponseWriter, code int, errTitle string, err error) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
b, _ := json.Marshal(struct {
Error string `json:"error"`
Details string `json:"details"`
}{
Error: errTitle,
Details: err.Error(),
})
_, _ = w.Write(b)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused code

Comment on lines 200 to +206
func (p *Plugin) MessageWillBeUpdated(c *plugin.Context, post *model.Post, _ *model.Post) (*model.Post, string) {
conf := p.getConfig()
if conf.EnableOnUpdate {
return p.ProcessPost(c, post)
} else {
if !conf.EnableOnUpdate {
return post, ""
}

return p.ProcessPost(c, post)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Invested the logic here to make it more readable

@codecov-io
Copy link

Codecov Report

Merging #108 into master will increase coverage by 0.64%.
The diff coverage is 56.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #108      +/-   ##
==========================================
+ Coverage   41.98%   42.62%   +0.64%     
==========================================
  Files           6        6              
  Lines         574      563      -11     
==========================================
- Hits          241      240       -1     
+ Misses        313      303      -10     
  Partials       20       20              
Impacted Files Coverage Δ
server/autolinkplugin/command.go 0.00% <0.00%> (ø)
server/api/api.go 63.23% <50.00%> (+8.80%) ⬆️
server/autolinkplugin/plugin.go 69.64% <58.82%> (-0.90%) ⬇️
server/autolink/autolink.go 51.06% <60.00%> (ø)
server/autolinkclient/client.go 72.00% <60.00%> (ø)
server/autolinkplugin/config.go 73.61% <80.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 66c32e8...65bee85. Read the comment docs.

Copy link
Contributor

@iomodo iomodo left a comment

Choose a reason for hiding this comment

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

LGTM!👌

@iomodo iomodo removed the 2: Dev Review Requires review by a core committer label Apr 20, 2020
@hanzei
Copy link
Contributor Author

hanzei commented Apr 20, 2020

@DHaussermann Please do a smoke test on the changes

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 Build errors
  • Smoke test admin side config and granting access to non-sysadmin users
  • Tested various patterns in posts

No issues found
LGTM!

@jwilander jwilander removed this from Done in Integrations Team Apr 26, 2024
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 QA Review Done PR has been approved by QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants