MM-52532: Fix golangci warnings (#23709)

https://mattermost.atlassian.net/browse/MM-52532

- Replace golint with revive
- Add makezero linter
- Fix all the required linter failures

Some issues in enterprise and public modules
are yet to be fixed. We send this to expediate things.
Этот коммит содержится в:
Agniva De Sarker
2023-06-13 14:08:36 +05:30
коммит произвёл GitHub
родитель 62a3ee8adc
Коммит c249ba4a66
49 изменённых файлов: 145 добавлений и 140 удалений

Просмотреть файл

@@ -47,7 +47,7 @@ func (s LocalCacheTermsOfServiceStore) Save(termsOfService *model.TermsOfService
func (s LocalCacheTermsOfServiceStore) GetLatest(allowFromCache bool) (*model.TermsOfService, error) {
if allowFromCache {
if len, err := s.rootStore.termsOfServiceCache.Len(); err == nil && len != 0 {
if l, err := s.rootStore.termsOfServiceCache.Len(); err == nil && l != 0 {
var cacheItem *model.TermsOfService
if err := s.rootStore.doStandardReadCache(s.rootStore.termsOfServiceCache, LatestKey, &cacheItem); err == nil {
return cacheItem, nil

Просмотреть файл

@@ -301,7 +301,7 @@ func (th *SearchTestHelper) createDirectChannel(teamID, name, displayName string
}
func (th *SearchTestHelper) createGroupChannel(teamID, displayName string, users []*model.User) (*model.Channel, error) {
userIDS := make([]string, len(users))
userIDS := make([]string, 0, len(users))
for _, user := range users {
userIDS = append(userIDS, user.Id)
}
@@ -464,7 +464,7 @@ func (th *SearchTestHelper) assertUsersMatchInAnyOrder(t *testing.T, expected, a
func (th *SearchTestHelper) checkPostInSearchResults(t *testing.T, postID string, searchResults map[string]*model.Post) {
t.Helper()
postIDS := make([]string, len(searchResults))
postIDS := make([]string, 0, len(searchResults))
for ID := range searchResults {
postIDS = append(postIDS, ID)
}
@@ -473,7 +473,7 @@ func (th *SearchTestHelper) checkPostInSearchResults(t *testing.T, postID string
func (th *SearchTestHelper) checkFileInfoInSearchResults(t *testing.T, fileID string, searchResults map[string]*model.FileInfo) {
t.Helper()
fileIDS := make([]string, len(searchResults))
fileIDS := make([]string, 0, len(searchResults))
for ID := range searchResults {
fileIDS = append(fileIDS, ID)
}

Просмотреть файл

@@ -355,13 +355,13 @@ func testReactionGetForPostSince(t *testing.T, ss store.Store, s SqlStore) {
}
for _, reaction := range reactions {
delete := reaction.DeleteAt
del := reaction.DeleteAt
update := reaction.UpdateAt
_, err := ss.Reaction().Save(reaction)
require.NoError(t, err)
if delete > 0 {
if del > 0 {
_, err = ss.Reaction().Delete(reaction)
require.NoError(t, err)
}

Просмотреть файл

@@ -458,7 +458,7 @@ func testRetentionPolicyStoreAddChannels(t *testing.T, ss store.Store, s SqlStor
err := ss.RetentionPolicy().AddChannels(policy.ID, channelIDs)
require.NoError(t, err)
// verify that the channels were actually added
copy := copyRetentionPolicyWithTeamAndChannelIds(policy)
copy := copyRetentionPolicyWithTeamAndChannelIds(policy) //nolint:revive
copy.ChannelIDs = append(copy.ChannelIDs, channelIDs...)
checkRetentionPolicyLikeThisExists(t, ss, copy)
restoreRetentionPolicy(t, ss, policy)
@@ -492,7 +492,7 @@ func testRetentionPolicyStoreRemoveChannels(t *testing.T, ss store.Store, s SqlS
err := ss.RetentionPolicy().RemoveChannels(policy.ID, []string{channelID})
require.NoError(t, err)
// verify that the channel was actually removed
copy := copyRetentionPolicyWithTeamAndChannelIds(policy)
copy := copyRetentionPolicyWithTeamAndChannelIds(policy) //nolint:revive
copy.ChannelIDs = make([]string, 0)
for _, oldChannelID := range policy.ChannelIDs {
if oldChannelID != channelID {
@@ -554,7 +554,7 @@ func testRetentionPolicyStoreAddTeams(t *testing.T, ss store.Store, s SqlStore)
err := ss.RetentionPolicy().AddTeams(policy.ID, teamIDs)
require.NoError(t, err)
// verify that the teams were actually added
copy := copyRetentionPolicyWithTeamAndChannelIds(policy)
copy := copyRetentionPolicyWithTeamAndChannelIds(policy) //nolint:revive
copy.TeamIDs = append(copy.TeamIDs, teamIDs...)
checkRetentionPolicyLikeThisExists(t, ss, copy)
restoreRetentionPolicy(t, ss, policy)
@@ -588,7 +588,7 @@ func testRetentionPolicyStoreRemoveTeams(t *testing.T, ss store.Store, s SqlStor
err := ss.RetentionPolicy().RemoveTeams(policy.ID, []string{teamID})
require.NoError(t, err)
// verify that the team was actually removed
copy := copyRetentionPolicyWithTeamAndChannelIds(policy)
copy := copyRetentionPolicyWithTeamAndChannelIds(policy) //nolint:revive
copy.TeamIDs = make([]string, 0)
for _, oldTeamID := range policy.TeamIDs {
if oldTeamID != teamID {