MM-22783: Fix scopelint issues (#13969)
* Fix scopelint issues * Incorporating review comments * Keeping the order of linters alphabetical * Fix issues after merge Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4ac0619c90
Коммит
c8b60c2d75
@@ -23,6 +23,7 @@ linters:
|
|||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
|
- scopelint
|
||||||
- structcheck
|
- structcheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
@@ -38,6 +39,11 @@ issues:
|
|||||||
- unused
|
- unused
|
||||||
text: "RedisSupplier|LocalCacheSupplier|Enterprise"
|
text: "RedisSupplier|LocalCacheSupplier|Enterprise"
|
||||||
|
|
||||||
|
- linters:
|
||||||
|
- scopelint
|
||||||
|
# ignore warnings from table tests. https://github.com/kyoh86/scopelint/issues/4
|
||||||
|
path: ".*_test.go|store/storetest"
|
||||||
|
|
||||||
- linters:
|
- linters:
|
||||||
# ignore golint error for a lot of packages for now
|
# ignore golint error for a lot of packages for now
|
||||||
- golint
|
- golint
|
||||||
|
|||||||
@@ -1557,6 +1557,7 @@ func (a *App) GetChannelMembersForUserWithPagination(teamId, userId string, page
|
|||||||
members := make([]*model.ChannelMember, 0)
|
members := make([]*model.ChannelMember, 0)
|
||||||
if m != nil {
|
if m != nil {
|
||||||
for _, member := range *m {
|
for _, member := range *m {
|
||||||
|
member := member
|
||||||
members = append(members, &member)
|
members = append(members, &member)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -855,6 +855,7 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
|
|||||||
var err *model.AppError
|
var err *model.AppError
|
||||||
usernames := []string{}
|
usernames := []string{}
|
||||||
for _, replyData := range data {
|
for _, replyData := range data {
|
||||||
|
replyData := replyData
|
||||||
if err = validateReplyImportData(&replyData, post.CreateAt, a.MaxPostSize()); err != nil {
|
if err = validateReplyImportData(&replyData, post.CreateAt, a.MaxPostSize()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -871,6 +872,7 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
|
|||||||
postsForOverwriteList := []*model.Post{}
|
postsForOverwriteList := []*model.Post{}
|
||||||
|
|
||||||
for _, replyData := range data {
|
for _, replyData := range data {
|
||||||
|
replyData := replyData
|
||||||
user := users[*replyData.User]
|
user := users[*replyData.User]
|
||||||
|
|
||||||
// Check if this post already exists.
|
// Check if this post already exists.
|
||||||
@@ -1144,6 +1146,7 @@ func (a *App) importMultiplePosts(data []*PostImportData, dryRun bool) *model.Ap
|
|||||||
var lastPostWithData *postAndData
|
var lastPostWithData *postAndData
|
||||||
repliesBulk := []ReplyImportData{}
|
repliesBulk := []ReplyImportData{}
|
||||||
for _, postWithData := range postsWithData {
|
for _, postWithData := range postsWithData {
|
||||||
|
postWithData := postWithData
|
||||||
if postWithData.postData.FlaggedBy != nil {
|
if postWithData.postData.FlaggedBy != nil {
|
||||||
var preferences model.Preferences
|
var preferences model.Preferences
|
||||||
|
|
||||||
@@ -1167,6 +1170,7 @@ func (a *App) importMultiplePosts(data []*PostImportData, dryRun bool) *model.Ap
|
|||||||
|
|
||||||
if postWithData.postData.Reactions != nil {
|
if postWithData.postData.Reactions != nil {
|
||||||
for _, reaction := range *postWithData.postData.Reactions {
|
for _, reaction := range *postWithData.postData.Reactions {
|
||||||
|
reaction := reaction
|
||||||
if err := a.importReaction(&reaction, postWithData.post, dryRun); err != nil {
|
if err := a.importReaction(&reaction, postWithData.post, dryRun); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1204,6 +1208,7 @@ func (a *App) uploadAttachments(attachments *[]AttachmentImportData, post *model
|
|||||||
}
|
}
|
||||||
fileIds := make(map[string]bool)
|
fileIds := make(map[string]bool)
|
||||||
for _, attachment := range *attachments {
|
for _, attachment := range *attachments {
|
||||||
|
attachment := attachment
|
||||||
fileInfo, err := a.importAttachment(&attachment, post, teamId, dryRun)
|
fileInfo, err := a.importAttachment(&attachment, post, teamId, dryRun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1432,6 +1437,7 @@ func (a *App) importMultipleDirectPosts(data []*DirectPostImportData, dryRun boo
|
|||||||
|
|
||||||
if postWithData.directPostData.Reactions != nil {
|
if postWithData.directPostData.Reactions != nil {
|
||||||
for _, reaction := range *postWithData.directPostData.Reactions {
|
for _, reaction := range *postWithData.directPostData.Reactions {
|
||||||
|
reaction := reaction
|
||||||
if err := a.importReaction(&reaction, postWithData.post, dryRun); err != nil {
|
if err := a.importReaction(&reaction, postWithData.post, dryRun); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,12 +434,14 @@ func validatePostImportData(data *PostImportData, maxPostSize int) *model.AppErr
|
|||||||
|
|
||||||
if data.Reactions != nil {
|
if data.Reactions != nil {
|
||||||
for _, reaction := range *data.Reactions {
|
for _, reaction := range *data.Reactions {
|
||||||
|
reaction := reaction
|
||||||
validateReactionImportData(&reaction, *data.CreateAt)
|
validateReactionImportData(&reaction, *data.CreateAt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.Replies != nil {
|
if data.Replies != nil {
|
||||||
for _, reply := range *data.Replies {
|
for _, reply := range *data.Replies {
|
||||||
|
reply := reply
|
||||||
validateReplyImportData(&reply, *data.CreateAt, maxPostSize)
|
validateReplyImportData(&reply, *data.CreateAt, maxPostSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -528,12 +530,14 @@ func validateDirectPostImportData(data *DirectPostImportData, maxPostSize int) *
|
|||||||
|
|
||||||
if data.Reactions != nil {
|
if data.Reactions != nil {
|
||||||
for _, reaction := range *data.Reactions {
|
for _, reaction := range *data.Reactions {
|
||||||
|
reaction := reaction
|
||||||
validateReactionImportData(&reaction, *data.CreateAt)
|
validateReactionImportData(&reaction, *data.CreateAt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.Replies != nil {
|
if data.Replies != nil {
|
||||||
for _, reply := range *data.Replies {
|
for _, reply := range *data.Replies {
|
||||||
|
reply := reply
|
||||||
validateReplyImportData(&reply, *data.CreateAt, maxPostSize)
|
validateReplyImportData(&reply, *data.CreateAt, maxPostSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2545,7 +2545,8 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, member := range channelMembers {
|
for i := range channelMembers {
|
||||||
|
member := channelMembers[i]
|
||||||
roles := strings.Fields(member.Roles)
|
roles := strings.Fields(member.Roles)
|
||||||
var newRoles []string
|
var newRoles []string
|
||||||
if !member.SchemeAdmin.Valid {
|
if !member.SchemeAdmin.Valid {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) *model.AppError
|
|||||||
|
|
||||||
defer finalizeTransaction(transaction)
|
defer finalizeTransaction(transaction)
|
||||||
for _, preference := range *preferences {
|
for _, preference := range *preferences {
|
||||||
|
preference := preference
|
||||||
if upsertErr := s.save(transaction, &preference); upsertErr != nil {
|
if upsertErr := s.save(transaction, &preference); upsertErr != nil {
|
||||||
return upsertErr
|
return upsertErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -913,7 +913,8 @@ func (s SqlTeamStore) MigrateTeamMembers(fromTeamId string, fromUserId string) (
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, member := range teamMembers {
|
for i := range teamMembers {
|
||||||
|
member := teamMembers[i]
|
||||||
roles := strings.Fields(member.Roles)
|
roles := strings.Fields(member.Roles)
|
||||||
var newRoles []string
|
var newRoles []string
|
||||||
if !member.SchemeAdmin.Valid {
|
if !member.SchemeAdmin.Valid {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user