* 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>
Этот коммит содержится в:
Agniva De Sarker
2020-03-13 08:44:39 +05:30
коммит произвёл GitHub
родитель 4ac0619c90
Коммит c8b60c2d75
7 изменённых файлов: 22 добавлений и 2 удалений

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

@@ -23,6 +23,7 @@ linters:
- gosimple
- govet
- ineffassign
- scopelint
- structcheck
- unconvert
- unused
@@ -38,6 +39,11 @@ issues:
- unused
text: "RedisSupplier|LocalCacheSupplier|Enterprise"
- linters:
- scopelint
# ignore warnings from table tests. https://github.com/kyoh86/scopelint/issues/4
path: ".*_test.go|store/storetest"
- linters:
# ignore golint error for a lot of packages for now
- golint

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

@@ -1557,6 +1557,7 @@ func (a *App) GetChannelMembersForUserWithPagination(teamId, userId string, page
members := make([]*model.ChannelMember, 0)
if m != nil {
for _, member := range *m {
member := member
members = append(members, &member)
}
}

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

@@ -855,6 +855,7 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
var err *model.AppError
usernames := []string{}
for _, replyData := range data {
replyData := replyData
if err = validateReplyImportData(&replyData, post.CreateAt, a.MaxPostSize()); err != nil {
return err
}
@@ -871,6 +872,7 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
postsForOverwriteList := []*model.Post{}
for _, replyData := range data {
replyData := replyData
user := users[*replyData.User]
// Check if this post already exists.
@@ -1144,6 +1146,7 @@ func (a *App) importMultiplePosts(data []*PostImportData, dryRun bool) *model.Ap
var lastPostWithData *postAndData
repliesBulk := []ReplyImportData{}
for _, postWithData := range postsWithData {
postWithData := postWithData
if postWithData.postData.FlaggedBy != nil {
var preferences model.Preferences
@@ -1167,6 +1170,7 @@ func (a *App) importMultiplePosts(data []*PostImportData, dryRun bool) *model.Ap
if postWithData.postData.Reactions != nil {
for _, reaction := range *postWithData.postData.Reactions {
reaction := reaction
if err := a.importReaction(&reaction, postWithData.post, dryRun); err != nil {
return err
}
@@ -1204,6 +1208,7 @@ func (a *App) uploadAttachments(attachments *[]AttachmentImportData, post *model
}
fileIds := make(map[string]bool)
for _, attachment := range *attachments {
attachment := attachment
fileInfo, err := a.importAttachment(&attachment, post, teamId, dryRun)
if err != nil {
return nil, err
@@ -1432,6 +1437,7 @@ func (a *App) importMultipleDirectPosts(data []*DirectPostImportData, dryRun boo
if postWithData.directPostData.Reactions != nil {
for _, reaction := range *postWithData.directPostData.Reactions {
reaction := reaction
if err := a.importReaction(&reaction, postWithData.post, dryRun); err != nil {
return err
}

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

@@ -434,12 +434,14 @@ func validatePostImportData(data *PostImportData, maxPostSize int) *model.AppErr
if data.Reactions != nil {
for _, reaction := range *data.Reactions {
reaction := reaction
validateReactionImportData(&reaction, *data.CreateAt)
}
}
if data.Replies != nil {
for _, reply := range *data.Replies {
reply := reply
validateReplyImportData(&reply, *data.CreateAt, maxPostSize)
}
}
@@ -528,12 +530,14 @@ func validateDirectPostImportData(data *DirectPostImportData, maxPostSize int) *
if data.Reactions != nil {
for _, reaction := range *data.Reactions {
reaction := reaction
validateReactionImportData(&reaction, *data.CreateAt)
}
}
if data.Replies != nil {
for _, reply := range *data.Replies {
reply := reply
validateReplyImportData(&reply, *data.CreateAt, maxPostSize)
}
}

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

@@ -2545,7 +2545,8 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
return nil, nil
}
for _, member := range channelMembers {
for i := range channelMembers {
member := channelMembers[i]
roles := strings.Fields(member.Roles)
var newRoles []string
if !member.SchemeAdmin.Valid {

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

@@ -63,6 +63,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) *model.AppError
defer finalizeTransaction(transaction)
for _, preference := range *preferences {
preference := preference
if upsertErr := s.save(transaction, &preference); upsertErr != nil {
return upsertErr
}

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

@@ -913,7 +913,8 @@ func (s SqlTeamStore) MigrateTeamMembers(fromTeamId string, fromUserId string) (
return nil, nil
}
for _, member := range teamMembers {
for i := range teamMembers {
member := teamMembers[i]
roles := strings.Fields(member.Roles)
var newRoles []string
if !member.SchemeAdmin.Valid {