Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

WIP go report card #224

Merged
merged 13 commits into from
Mar 25, 2023
Merged

WIP go report card #224

merged 13 commits into from
Mar 25, 2023

Conversation

scottleedavis
Copy link
Owner

gofmt, go vet, changes

@scottleedavis scottleedavis self-assigned this Mar 14, 2023
Copy link
Collaborator

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Nice one 👍

@scottleedavis scottleedavis removed the request for review from lieut-data March 23, 2023 15:40
@mickmister
Copy link

Hi @scottleedavis! Just so I can understand better, what version of Go are you using? You can find out by running go version

I've cloned the project and ran into some issues running make dist:

i18n.go:13:2: no required module provides package github.com/nicksnyder/go-i18n/i18n; to add it:
        go get github.com/nicksnyder/go-i18n/i18n
../../../go/pkg/mod/github.com/mattermost/mattermost-server/[email protected]/utils/markdown.go:11:2: missing go.sum entry for module providing package github.com/yuin/goldmark (imported by github.com/mattermost/mattermost-server/v6/utils); to add:
        go get github.com/mattermost/mattermost-server/v6/[email protected]
../../../go/pkg/mod/github.com/mattermost/mattermost-server/[email protected]/utils/markdown.go:12:2: missing go.sum entry for module providing package github.com/yuin/goldmark/ast (imported by github.com/mattermost/mattermost-server/v6/utils); to add:

Running go mod tidy solved this issue by updating go.mod and go.sum.

After doing that, I receive these errors from make dist:

./activate.go:45:22: undefined: plugin.EnsureBotOption
./activate.go:46:10: undefined: plugin.ProfileImagePath
./activate.go:49:11: p.Helpers undefined (type *Plugin has no field or method Helpers)
./http.go:46:19: undefined: model.SubmitDialogRequestFromJson
./http.go:179:19: undefined: model.PostActionIntegrationRequestFromJson
./http.go:195:19: undefined: model.PostActionIntegrationRequestFromJson
./http.go:276:19: undefined: model.PostActionIntegrationRequestFromJson
./http.go:311:19: undefined: model.PostActionIntegrationRequestFromJson
./http.go:345:19: undefined: model.PostActionIntegrationRequestFromJson
./http.go:462:19: undefined: model.PostActionIntegrationRequestFromJson
./http.go:462:19: too many errors

Let's dissect these errors

./activate.go:45:22: undefined: plugin.EnsureBotOption
./activate.go:46:10: undefined: plugin.ProfileImagePath

The API for this has changed a bit, as you point out, it's common to use https://github.com/mattermost/mattermost-plugin-api now for things like this. In order to use this library, you'll need to import it, and instantiate a client like so: https://github.com/mattermost/mattermost-plugin-github/blob/757c9c1b18713035e3216ec96b6be1453a4c7478/server/plugin/plugin.go#L220

Then you can have access to the methods on the new client, such as client.Bot.EnsureBot:

bot := &model.Bot{
	Username:    botUserName,
	DisplayName: botDisplayName,
}

p.client.Bot.EnsureBot(bot, pluginapi.ProfileImagePath("assets/icon.png"))

Another error:

./http.go:46:19: undefined: model.SubmitDialogRequestFromJson
./http.go:179:19: undefined: model.PostActionIntegrationRequestFromJson

Instead of using these functions that no longer exist you'll need to manually unmarshal into locally declared model.SubmitDialogRequest and model.PostActionIntegrationRequest structs.

@codecov
Copy link

codecov bot commented Mar 25, 2023

Codecov Report

Patch coverage: 56.74% and project coverage change: +69.08 🎉

Comparison is base (1f98568) 0.00% compared to head (5a147c0) 69.08%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #224       +/-   ##
===========================================
+ Coverage        0   69.08%   +69.08%     
===========================================
  Files           0       11       +11     
  Lines           0     3254     +3254     
===========================================
+ Hits            0     2248     +2248     
- Misses          0      736      +736     
- Partials        0      270      +270     
Impacted Files Coverage Δ
server/main.go 0.00% <ø> (ø)
server/parse.go 66.76% <ø> (ø)
server/utils.go 100.00% <ø> (ø)
server/plugin.go 14.81% <4.16%> (ø)
server/occurrence.go 59.47% <36.84%> (ø)
server/reminder.go 67.24% <56.00%> (ø)
server/list.go 81.61% <65.00%> (ø)
server/http.go 71.25% <66.37%> (ø)
server/command.go 72.72% <80.00%> (ø)
server/i18n.go 86.20% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@scottleedavis
Copy link
Owner Author

thank you for your help @mickmister !
thank you for approval @hanzei !

@scottleedavis scottleedavis merged commit eadcedd into master Mar 25, 2023
@scottleedavis scottleedavis deleted the goreportcard branch March 25, 2023 19:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants