mattermost icon indicating copy to clipboard operation
mattermost copied to clipboard

fixed most init errors in channels/store/storetest dir | 24 files edited

Open TealWater opened this issue 1 year ago • 14 comments

Summary

Fixed all initialism errors in 14 files in accordance with the golang style doc found here.

List of warnings fixed:

variable naming conventions --> abbreviations like ID need to be capitalized

var-naming: var user_ID should be useID (revive)
var-naming: var teanId should be teamID (revive)
func-naming: func getId should be getID

Ticket Link

Fix for: https://github.com/mattermost/mattermost/issues/16623

Screenshots

Release Note

none

TealWater avatar Mar 19 '24 22:03 TealWater

Hello @TealWater,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

mattermost-build avatar Mar 19 '24 22:03 mattermost-build

@hanzei

I re-forked it and used the revive linter.

I then created a vscode-workspace in the /server/ directory.

If there are more issues beyond a merge conflict or a var-naming, we may need to have a longer convo because clearly, I am doing something wrong with my setup.

TealWater avatar Mar 19 '24 22:03 TealWater

@TealWater Can you please run go vet ./... inside your local server directory? That will give you a list of complier errors directly on your local system.

hanzei avatar Mar 25 '24 08:03 hanzei

@hanzei

Matthews-MBP-4:storetest matthewstraughn$ pwd
/Users/matthewstraughn/Code/mattermost/server/channels/store/storetest
Matthews-MBP-4:storetest matthewstraughn$ go vet ./...
# github.com/mattermost/mattermost/server/v8/channels/store
../store.go:1039:48: undefined: model.ChannelBookmarkWithFileInfo
../store.go:1040:23: undefined: model.ChannelBookmark
../store.go:1040:74: undefined: model.ChannelBookmarkWithFileInfo
../store.go:1041:25: undefined: model.ChannelBookmark
../store.go:1042:74: undefined: model.ChannelBookmarkWithFileInfo
../store.go:1044:71: undefined: model.ChannelBookmarkWithFileInfo

It's looking for ChannelBookmark methods in this import: "github.com/mattermost/mattermost/server/public/model".

I've checked the Golang package dev docs and I cannot find them either.

Am I missing some internal dependency in my go.mod file or is my versioning incorrect?

TealWater avatar Mar 25 '24 14:03 TealWater

@TealWater What go version are you using? Does make modules-tidy run without issues on your branch?

hanzei avatar Mar 25 '24 15:03 hanzei

@hanzei

go version: 1.21.5

unable to run go make modules-tidy

I can run go mod tidy but there are some issues:

TLDR: There is an issue with finding the enterprise imports

Matthews-MBP-4:storetest matthewstraughn$ go mod tidy
go: finding module for package github.com/mattermost/enterprise/cluster
go: finding module for package github.com/mattermost/enterprise/account_migration
go: finding module for package github.com/mattermost/mattermost/server/public/utils/sql
go: finding module for package github.com/mattermost/enterprise/cloud
go: downloading github.com/mattermost/mattermost/server/public v0.1.0
go: downloading github.com/mattermost/mattermost v9.6.1+incompatible
go: finding module for package github.com/mattermost/enterprise/compliance
go: finding module for package github.com/mattermost/enterprise/data_retention
go: finding module for package github.com/mattermost/enterprise/elasticsearch
go: finding module for package github.com/mattermost/enterprise/ip_filtering
go: finding module for package github.com/mattermost/enterprise/ldap
go: finding module for package github.com/mattermost/enterprise/license
go: finding module for package github.com/mattermost/enterprise/message_export
go: finding module for package github.com/mattermost/enterprise/message_export/actiance_export
go: finding module for package github.com/mattermost/enterprise/message_export/csv_export
go: finding module for package github.com/mattermost/enterprise/notification
go: finding module for package github.com/mattermost/enterprise/message_export/global_relay_export
go: finding module for package github.com/mattermost/enterprise/oauth/google
go: finding module for package github.com/mattermost/enterprise/oauth/office365
go: finding module for package github.com/mattermost/enterprise/oauth/openid
go: finding module for package github.com/mattermost/enterprise/outgoing_oauth_connections
go: finding module for package github.com/mattermost/enterprise/saml
go: found github.com/mattermost/mattermost/server/public/utils/sql in github.com/mattermost/mattermost/server/public v0.1.0
go: finding module for package github.com/mattermost/enterprise/account_migration
go: finding module for package github.com/mattermost/enterprise/compliance
go: finding module for package github.com/mattermost/enterprise/cluster
go: finding module for package github.com/mattermost/enterprise/data_retention
go: finding module for package github.com/mattermost/enterprise/cloud
go: finding module for package github.com/mattermost/enterprise/elasticsearch
go: finding module for package github.com/mattermost/enterprise/ip_filtering
go: finding module for package github.com/mattermost/enterprise/ldap
go: finding module for package github.com/mattermost/enterprise/license
go: finding module for package github.com/mattermost/enterprise/message_export
go: finding module for package github.com/mattermost/enterprise/message_export/actiance_export
go: finding module for package github.com/mattermost/enterprise/message_export/csv_export
go: finding module for package github.com/mattermost/enterprise/message_export/global_relay_export
go: finding module for package github.com/mattermost/enterprise/notification
go: finding module for package github.com/mattermost/enterprise/oauth/google
go: finding module for package github.com/mattermost/enterprise/oauth/openid
go: finding module for package github.com/mattermost/enterprise/oauth/office365
go: finding module for package github.com/mattermost/enterprise/outgoing_oauth_connections
go: finding module for package github.com/mattermost/enterprise/saml
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/account_migration: cannot find module providing package github.com/mattermost/enterprise/account_migration: module github.com/mattermost/enterprise/account_migration: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/cloud: cannot find module providing package github.com/mattermost/enterprise/cloud: module github.com/mattermost/enterprise/cloud: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/cluster: cannot find module providing package github.com/mattermost/enterprise/cluster: module github.com/mattermost/enterprise/cluster: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/compliance: cannot find module providing package github.com/mattermost/enterprise/compliance: module github.com/mattermost/enterprise/compliance: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/data_retention: cannot find module providing package github.com/mattermost/enterprise/data_retention: module github.com/mattermost/enterprise/data_retention: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/elasticsearch: cannot find module providing package github.com/mattermost/enterprise/elasticsearch: module github.com/mattermost/enterprise/elasticsearch: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/ip_filtering: cannot find module providing package github.com/mattermost/enterprise/ip_filtering: module github.com/mattermost/enterprise/ip_filtering: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/ldap: cannot find module providing package github.com/mattermost/enterprise/ldap: module github.com/mattermost/enterprise/ldap: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/license: cannot find module providing package github.com/mattermost/enterprise/license: module github.com/mattermost/enterprise/license: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/message_export: cannot find module providing package github.com/mattermost/enterprise/message_export: module github.com/mattermost/enterprise/message_export: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/message_export/actiance_export: cannot find module providing package github.com/mattermost/enterprise/message_export/actiance_export: module github.com/mattermost/enterprise/message_export/actiance_export: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/message_export/csv_export: cannot find module providing package github.com/mattermost/enterprise/message_export/csv_export: module github.com/mattermost/enterprise/message_export/csv_export: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/message_export/global_relay_export: cannot find module providing package github.com/mattermost/enterprise/message_export/global_relay_export: module github.com/mattermost/enterprise/message_export/global_relay_export: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/notification: cannot find module providing package github.com/mattermost/enterprise/notification: module github.com/mattermost/enterprise/notification: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/oauth/google: cannot find module providing package github.com/mattermost/enterprise/oauth/google: module github.com/mattermost/enterprise/oauth/google: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/oauth/office365: cannot find module providing package github.com/mattermost/enterprise/oauth/office365: module github.com/mattermost/enterprise/oauth/office365: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/oauth/openid: cannot find module providing package github.com/mattermost/enterprise/oauth/openid: module github.com/mattermost/enterprise/oauth/openid: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/outgoing_oauth_connections: cannot find module providing package github.com/mattermost/enterprise/outgoing_oauth_connections: module github.com/mattermost/enterprise/outgoing_oauth_connections: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
go: github.com/mattermost/mattermost/server/v8/enterprise imports
        github.com/mattermost/enterprise/saml: cannot find module providing package github.com/mattermost/enterprise/saml: module github.com/mattermost/enterprise/saml: git ls-remote -q origin in /Users/matthewstraughn/go/pkg/mod/cache/vcs/0b5f7c685717c1d3f2168e56e365c1950986976fe637f8c1bc341dc16f2b2190: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/mattermost/enterprise/' not found
Matthews-MBP-4:storetest matthewstraughn$ 

TealWater avatar Mar 25 '24 15:03 TealWater

go mod tidy doesn't work due to the enterprise repo. What error does make modules-tidy produce?

hanzei avatar Mar 25 '24 15:03 hanzei

I'm not sure how to run that command so I did this:

Matthews-MBP-4:storetest matthewstraughn$ pwd
/Users/matthewstraughn/Code/mattermost/server/channels/store/storetest
Matthews-MBP-4:storetest matthewstraughn$ make modules-tidy
make: *** No rule to make target `modules-tidy'.  Stop.
Matthews-MBP-4:storetest matthewstraughn$ go make modules-tidy
go make: unknown command
Run 'go help' for usage.
Matthews-MBP-4:storetest matthewstraughn$ 

TealWater avatar Mar 25 '24 15:03 TealWater

This PR has been automatically labelled "stale" because it hasn't had recent activity. A core team member will check in on the status of the PR to help with questions. Thank you for your contribution!

mattermost-build avatar Apr 08 '24 01:04 mattermost-build

@TealWater CI is running. Let's see if there are any issues.

hanzei avatar Aug 30 '24 04:08 hanzei

@hanzei Need you to run the CI when you have a chance. Thanks. 🙂

TealWater avatar Aug 30 '24 05:08 TealWater

CI is running

hanzei avatar Aug 30 '24 05:08 hanzei

@hanzei making some progress slowly 😆 .

please start CI when able. Thanks.

TealWater avatar Aug 30 '24 05:08 TealWater

@hanzei we have finally made some real progress! Not sure where to go from here. 😞

TealWater avatar Aug 30 '24 06:08 TealWater

@TealWater I've merged master into your branch and re-generated some files using make generated. Let's see what CI reports.

hanzei avatar Sep 16 '24 13:09 hanzei

Restarting CI

hanzei avatar Sep 17 '24 06:09 hanzei

CI is green :tada:

hanzei avatar Sep 17 '24 07:09 hanzei

There doesn't seem to be any changes to .golangci.yml.

agnivade avatar Sep 17 '24 08:09 agnivade

How can I go about creating those .yml file changes?

TealWater avatar Sep 17 '24 08:09 TealWater

How can I go about creating those .yml file changes?

https://github.com/mattermost/mattermost/issues/16623#issue-777852169

agnivade avatar Sep 17 '24 08:09 agnivade

@TealWater - I am going to push some changes to the PR. The .golangci.yml file is still not quite right.

agnivade avatar Sep 23 '24 07:09 agnivade

I am unassigning myself until the changes for .golangci.yml are in.

hanzei avatar Sep 23 '24 09:09 hanzei

I removed the channels/store/storetest/mocks exception. But it looks like I am having some trouble excluding some specific files for the var-naming|error-naming rules. @hanzei - Does the linter not accept directories? I see your errcheck exclusion rules, and I am not sure if that was done to ease contributors fix small chunks of code or golangci did not allow directories to be excluded.

agnivade avatar Oct 10 '24 05:10 agnivade

@agnivade The path option does accept directories and file names. What is the exact issue that you are running into?

hanzei avatar Oct 11 '24 08:10 hanzei

It wasn't matching them. Maybe I am doing something silly. What I want to do is move out var-naming|error-naming| from global exclude and create a separate rule just for these 2 and scope them to a set of directories, and then fix the directories one by one in future PRs.

agnivade avatar Oct 11 '24 08:10 agnivade

AFAIK, golangci-lint only supports exclude rules, not include ones. Hence, you need to list every directory that doesn't match a linter's standard.

hanzei avatar Oct 11 '24 08:10 hanzei

That's what I was doing. It wasn't working.

agnivade avatar Oct 11 '24 09:10 agnivade

This PR has been automatically labelled "stale" because it hasn't had recent activity. A core team member will check in on the status of the PR to help with questions. Thank you for your contribution!

mattermost-build avatar Oct 23 '24 01:10 mattermost-build

@agnivade The diff on this PR is already huge. I wonder if we should merge it as it is and defer the linter changes for a future PR to avoid merge conflicts.

hanzei avatar Oct 24 '24 18:10 hanzei

Sure.

agnivade avatar Oct 25 '24 08:10 agnivade