unparam lint (#16771)
* fixed: `identifier` is unused lint error * make saveMultipleMembersT method saveMultipleMembers Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
78ccf8a775
Коммит
a63dea6c55
@@ -109,7 +109,8 @@ func channelMemberToSlice(member *model.ChannelMember) []interface{} {
|
||||
|
||||
type channelMemberWithSchemeRolesList []channelMemberWithSchemeRoles
|
||||
|
||||
func getChannelRoles(schemeGuest, schemeUser, schemeAdmin bool, defaultTeamGuestRole, defaultTeamUserRole, defaultTeamAdminRole, defaultChannelGuestRole, defaultChannelUserRole, defaultChannelAdminRole string, roles []string) rolesInfo {
|
||||
func getChannelRoles(schemeGuest, schemeUser, schemeAdmin bool, defaultTeamGuestRole, defaultTeamUserRole, defaultTeamAdminRole, defaultChannelGuestRole, defaultChannelUserRole, defaultChannelAdminRole string,
|
||||
roles []string) rolesInfo {
|
||||
result := rolesInfo{
|
||||
roles: []string{},
|
||||
explicitRoles: []string{},
|
||||
@@ -606,9 +607,9 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1
|
||||
member2.ChannelId = newChannel.Id
|
||||
|
||||
if member1.UserId != member2.UserId {
|
||||
_, err = s.saveMultipleMembersT(transaction, []*model.ChannelMember{member1, member2})
|
||||
_, err = s.saveMultipleMembers([]*model.ChannelMember{member1, member2})
|
||||
} else {
|
||||
_, err = s.saveMemberT(transaction, member2)
|
||||
_, err = s.saveMemberT(member2)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -729,6 +730,7 @@ func (s SqlChannelStore) GetChannelUnread(channelId, userId string) (*model.Chan
|
||||
return &unreadChannel, nil
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) InvalidateChannel(id string) {
|
||||
}
|
||||
|
||||
@@ -739,8 +741,9 @@ func (s SqlChannelStore) InvalidateChannelByName(teamId, name string) {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) Get(id string, allowFromCache bool) (*model.Channel, error) {
|
||||
return s.get(id, false, allowFromCache)
|
||||
return s.get(id, false)
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetPinnedPosts(channelId string) (*model.PostList, error) {
|
||||
@@ -758,10 +761,10 @@ func (s SqlChannelStore) GetPinnedPosts(channelId string) (*model.PostList, erro
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetFromMaster(id string) (*model.Channel, error) {
|
||||
return s.get(id, true, false)
|
||||
return s.get(id, true)
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) get(id string, master bool, allowFromCache bool) (*model.Channel, error) {
|
||||
func (s SqlChannelStore) get(id string, master bool) (*model.Channel, error) {
|
||||
var db *gorp.DbMap
|
||||
|
||||
if master {
|
||||
@@ -1392,7 +1395,7 @@ func (s SqlChannelStore) SaveMultipleMembers(members []*model.ChannelMember) ([]
|
||||
}
|
||||
defer finalizeTransaction(transaction)
|
||||
|
||||
newMembers, err := s.saveMultipleMembersT(transaction, members)
|
||||
newMembers, err := s.saveMultipleMembers(members)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1412,7 +1415,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) (*model.Channel
|
||||
return newMembers[0], nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) saveMultipleMembersT(transaction *gorp.Transaction, members []*model.ChannelMember) ([]*model.ChannelMember, error) {
|
||||
func (s SqlChannelStore) saveMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) {
|
||||
newChannelMembers := map[string]int{}
|
||||
users := map[string]bool{}
|
||||
for _, member := range members {
|
||||
@@ -1553,8 +1556,8 @@ func (s SqlChannelStore) saveMultipleMembersT(transaction *gorp.Transaction, mem
|
||||
return newMembers, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) saveMemberT(transaction *gorp.Transaction, member *model.ChannelMember) (*model.ChannelMember, error) {
|
||||
members, err := s.saveMultipleMembersT(transaction, []*model.ChannelMember{member})
|
||||
func (s SqlChannelStore) saveMemberT(member *model.ChannelMember) (*model.ChannelMember, error) {
|
||||
members, err := s.saveMultipleMembers([]*model.ChannelMember{member})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1843,6 +1846,7 @@ func (s SqlChannelStore) GetAllChannelMembersNotifyPropsForChannel(channelId str
|
||||
return props, nil
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) InvalidateMemberCount(channelId string) {
|
||||
}
|
||||
|
||||
@@ -1851,6 +1855,7 @@ func (s SqlChannelStore) GetMemberCountFromCache(channelId string) int64 {
|
||||
return count
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) GetMemberCount(channelId string, allowFromCache bool) (int64, error) {
|
||||
count, err := s.GetReplica().SelectInt(`
|
||||
SELECT
|
||||
@@ -1939,9 +1944,11 @@ func (s SqlChannelStore) GetMemberCountsByGroup(channelID string, includeTimezon
|
||||
return data, nil
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) InvalidatePinnedPostCount(channelId string) {
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) GetPinnedPostCount(channelId string, allowFromCache bool) (int64, error) {
|
||||
count, err := s.GetReplica().SelectInt(`
|
||||
SELECT count(*)
|
||||
@@ -1958,9 +1965,11 @@ func (s SqlChannelStore) GetPinnedPostCount(channelId string, allowFromCache boo
|
||||
return count, nil
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) InvalidateGuestCount(channelId string) {
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) GetGuestCount(channelId string, allowFromCache bool) (int64, error) {
|
||||
count, err := s.GetReplica().SelectInt(`
|
||||
SELECT
|
||||
|
||||
@@ -324,7 +324,7 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
|
||||
}
|
||||
|
||||
// now we re-order the categories according to the new order
|
||||
if err = s.updateSidebarCategoryOrderT(transaction, userId, teamId, newOrder); err != nil {
|
||||
if err = s.updateSidebarCategoryOrderT(transaction, newOrder); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ func (s SqlChannelStore) GetSidebarCategoryOrder(userId, teamId string) ([]strin
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) updateSidebarCategoryOrderT(transaction *gorp.Transaction, userId, teamId string, categoryOrder []string) error {
|
||||
func (s SqlChannelStore) updateSidebarCategoryOrderT(transaction *gorp.Transaction, categoryOrder []string) error {
|
||||
var newOrder []interface{}
|
||||
runningOrder := 0
|
||||
for _, categoryId := range categoryOrder {
|
||||
@@ -595,7 +595,7 @@ func (s SqlChannelStore) UpdateSidebarCategoryOrder(userId, teamId string, categ
|
||||
}
|
||||
}
|
||||
|
||||
if err = s.updateSidebarCategoryOrderT(transaction, userId, teamId, categoryOrder); err != nil {
|
||||
if err = s.updateSidebarCategoryOrderT(transaction, categoryOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -606,6 +606,7 @@ func (s SqlChannelStore) UpdateSidebarCategoryOrder(userId, teamId string, categ
|
||||
return nil
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
||||
transaction, err := s.GetMaster().Begin()
|
||||
if err != nil {
|
||||
@@ -943,6 +944,7 @@ func (s SqlChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.P
|
||||
return nil
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s SqlChannelStore) UpdateSidebarChannelCategoryOnMove(channel *model.Channel, newTeamId string) error {
|
||||
// if channel is being moved, remove it from the categories, since it's possible that there's no matching category in the new team
|
||||
if _, err := s.GetMaster().Exec("DELETE FROM SidebarChannels WHERE ChannelId=:ChannelId", map[string]interface{}{"ChannelId": channel.Id}); err != nil {
|
||||
|
||||
@@ -58,11 +58,11 @@ func (es SqlEmojiStore) Save(emoji *model.Emoji) (*model.Emoji, error) {
|
||||
}
|
||||
|
||||
func (es SqlEmojiStore) Get(id string, allowFromCache bool) (*model.Emoji, error) {
|
||||
return es.getBy("Id", id, allowFromCache)
|
||||
return es.getBy("Id", id)
|
||||
}
|
||||
|
||||
func (es SqlEmojiStore) GetByName(name string, allowFromCache bool) (*model.Emoji, error) {
|
||||
return es.getBy("Name", name, allowFromCache)
|
||||
return es.getBy("Name", name)
|
||||
}
|
||||
|
||||
func (es SqlEmojiStore) GetMultipleByName(names []string) ([]*model.Emoji, error) {
|
||||
@@ -146,7 +146,7 @@ func (es SqlEmojiStore) Search(name string, prefixOnly bool, limit int) ([]*mode
|
||||
}
|
||||
|
||||
// getBy returns one active (not deleted) emoji, found by any one column (what/key).
|
||||
func (es SqlEmojiStore) getBy(what, key string, addToCache bool) (*model.Emoji, error) {
|
||||
func (es SqlEmojiStore) getBy(what, key string) (*model.Emoji, error) {
|
||||
var emoji *model.Emoji
|
||||
|
||||
err := es.GetReplica().SelectOne(&emoji,
|
||||
|
||||
@@ -998,7 +998,7 @@ func (s *SqlGroupStore) groupsBySyncableBaseQuery(st model.GroupSyncableType, t
|
||||
return query
|
||||
}
|
||||
|
||||
func (s *SqlGroupStore) getGroupsAssociatedToChannelsByTeam(st model.GroupSyncableType, teamID string, opts model.GroupSearchOpts) sq.SelectBuilder {
|
||||
func (s *SqlGroupStore) getGroupsAssociatedToChannelsByTeam(teamID string, opts model.GroupSearchOpts) sq.SelectBuilder {
|
||||
query := s.getQueryBuilder().
|
||||
Select("gc.ChannelId, ug.*, gc.SchemeAdmin AS SyncableSchemeAdmin").
|
||||
From("UserGroups ug").
|
||||
@@ -1103,7 +1103,7 @@ func (s *SqlGroupStore) GetGroupsByTeam(teamId string, opts model.GroupSearchOpt
|
||||
}
|
||||
|
||||
func (s *SqlGroupStore) GetGroupsAssociatedToChannelsByTeam(teamId string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, error) {
|
||||
query := s.getGroupsAssociatedToChannelsByTeam(model.GroupSyncableTypeTeam, teamId, opts)
|
||||
query := s.getGroupsAssociatedToChannelsByTeam(teamId, opts)
|
||||
|
||||
if opts.PageOpts != nil {
|
||||
offset := uint64(opts.PageOpts.Page * opts.PageOpts.PerPage)
|
||||
|
||||
@@ -297,7 +297,7 @@ func createStatus(ss store.Store, userId string) *model.Status {
|
||||
return &m
|
||||
}
|
||||
|
||||
func createTeam(ss store.Store, userId string) *model.Team {
|
||||
func createTeam(ss store.Store) *model.Team {
|
||||
m := model.Team{}
|
||||
m.DisplayName = "DisplayName"
|
||||
m.Type = model.TEAM_OPEN
|
||||
@@ -972,7 +972,7 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||
team := createTeam(ss, model.NewId())
|
||||
team := createTeam(ss)
|
||||
member := createTeamMember(ss, team.Id, model.NewId())
|
||||
dbmap.Delete(team)
|
||||
result := checkTeamsTeamMembersIntegrity(store)
|
||||
@@ -1569,7 +1569,7 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
||||
|
||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||
user := createUser(ss)
|
||||
team := createTeam(ss, user.Id)
|
||||
team := createTeam(ss)
|
||||
member := createTeamMember(ss, team.Id, user.Id)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersTeamMembersIntegrity(store)
|
||||
|
||||
@@ -519,15 +519,18 @@ type etagPosts struct {
|
||||
UpdateAt int64
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s *SqlPostStore) InvalidateLastPostTimeCache(channelId string) {
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s *SqlPostStore) GetEtag(channelId string, allowFromCache, collapsedThreads bool) string {
|
||||
q := s.getQueryBuilder().Select("Id", "UpdateAt").From("Posts").Where(sq.Eq{"ChannelId": channelId}).OrderBy("UpdateAt DESC").Limit(1)
|
||||
if collapsedThreads {
|
||||
q.Where(sq.Eq{"RootId": ""})
|
||||
}
|
||||
sql, args, _ := q.ToSql()
|
||||
|
||||
var et etagPosts
|
||||
err := s.GetReplica().SelectOne(&et, sql, args...)
|
||||
var result string
|
||||
@@ -558,7 +561,7 @@ func (s *SqlPostStore) Delete(postId string, time int64, deleteByID string) erro
|
||||
return errors.Wrap(err, "failed to update Posts")
|
||||
}
|
||||
|
||||
return s.cleanupThreads(post.Id, post.RootId, post.UserId, false)
|
||||
return s.cleanupThreads(post.Id, post.RootId, false)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) permanentDelete(postId string) error {
|
||||
@@ -567,7 +570,7 @@ func (s *SqlPostStore) permanentDelete(postId string) error {
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return errors.Wrapf(err, "failed to get Post with id=%s", postId)
|
||||
}
|
||||
if err = s.cleanupThreads(post.Id, post.RootId, post.UserId, true); err != nil {
|
||||
if err = s.cleanupThreads(post.Id, post.RootId, true); err != nil {
|
||||
return errors.Wrapf(err, "failed to cleanup threads for Post with id=%s", postId)
|
||||
}
|
||||
|
||||
@@ -592,7 +595,7 @@ func (s *SqlPostStore) permanentDeleteAllCommentByUser(userId string) error {
|
||||
}
|
||||
|
||||
for _, ids := range results {
|
||||
if err = s.cleanupThreads(ids.Id, ids.RootId, userId, true); err != nil {
|
||||
if err = s.cleanupThreads(ids.Id, ids.RootId, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -648,7 +651,7 @@ func (s *SqlPostStore) PermanentDeleteByChannel(channelId string) error {
|
||||
}
|
||||
|
||||
for _, ids := range results {
|
||||
if err = s.cleanupThreads(ids.Id, ids.RootId, ids.UserId, true); err != nil {
|
||||
if err = s.cleanupThreads(ids.Id, ids.RootId, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -825,10 +828,12 @@ func (s *SqlPostStore) getPostsSinceCollapsedThreads(options model.GetPostsSince
|
||||
return s.prepareThreadedResponse(posts, options.CollapsedThreadsExtended, false)
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
if options.CollapsedThreads {
|
||||
return s.getPostsSinceCollapsedThreads(options)
|
||||
}
|
||||
|
||||
var posts []*model.Post
|
||||
|
||||
replyCountQuery1 := ""
|
||||
@@ -2026,6 +2031,7 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
//nolint:unparam
|
||||
func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, error) {
|
||||
// Since we don't support paging for DB search, we just return nothing for later pages
|
||||
if page > 0 {
|
||||
@@ -2093,7 +2099,7 @@ func (s *SqlPostStore) GetOldestEntityCreationTime() (int64, error) {
|
||||
return oldest, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) cleanupThreads(postId, rootId, userId string, permanent bool) error {
|
||||
func (s *SqlPostStore) cleanupThreads(postId, rootId string, permanent bool) error {
|
||||
if permanent {
|
||||
if _, err := s.GetMaster().Exec("DELETE FROM Threads WHERE PostId = :Id", map[string]interface{}{"Id": postId}); err != nil {
|
||||
return errors.Wrap(err, "failed to delete Threads")
|
||||
|
||||
@@ -1055,7 +1055,7 @@ func (s SqlTeamStore) GetMembers(teamId string, offset int, limit int, teamMembe
|
||||
query = query.OrderBy(model.USERNAME)
|
||||
}
|
||||
|
||||
query = applyTeamMemberViewRestrictionsFilter(query, teamId, teamMembersGetOptions.ViewRestrictions)
|
||||
query = applyTeamMemberViewRestrictionsFilter(query, teamMembersGetOptions.ViewRestrictions)
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
@@ -1082,7 +1082,7 @@ func (s SqlTeamStore) GetTotalMemberCount(teamId string, restrictions *model.Vie
|
||||
Where("TeamMembers.UserId = Users.Id").
|
||||
Where(sq.Eq{"TeamMembers.TeamId": teamId})
|
||||
|
||||
query = applyTeamMemberViewRestrictionsFilterForStats(query, teamId, restrictions)
|
||||
query = applyTeamMemberViewRestrictionsFilterForStats(query, restrictions)
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return int64(0), errors.Wrap(err, "team_tosql")
|
||||
@@ -1106,7 +1106,7 @@ func (s SqlTeamStore) GetActiveMemberCount(teamId string, restrictions *model.Vi
|
||||
Where("Users.DeleteAt = 0").
|
||||
Where(sq.Eq{"TeamMembers.TeamId": teamId})
|
||||
|
||||
query = applyTeamMemberViewRestrictionsFilterForStats(query, teamId, restrictions)
|
||||
query = applyTeamMemberViewRestrictionsFilterForStats(query, restrictions)
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "team_tosql")
|
||||
@@ -1132,7 +1132,7 @@ func (s SqlTeamStore) GetMembersByIds(teamId string, userIds []string, restricti
|
||||
Where(sq.Eq{"TeamMembers.UserId": userIds}).
|
||||
Where(sq.Eq{"TeamMembers.DeleteAt": 0})
|
||||
|
||||
query = applyTeamMemberViewRestrictionsFilter(query, teamId, restrictions)
|
||||
query = applyTeamMemberViewRestrictionsFilter(query, restrictions)
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
@@ -1408,6 +1408,7 @@ func (s SqlTeamStore) ResetAllTeamSchemes() error {
|
||||
func (s SqlTeamStore) ClearCaches() {}
|
||||
|
||||
// InvalidateAllTeamIdsForUser does not execute anything because the store does not handle the cache.
|
||||
//nolint:unparam
|
||||
func (s SqlTeamStore) InvalidateAllTeamIdsForUser(userId string) {}
|
||||
|
||||
// ClearAllCustomRoleAssignments removes all custom role assignments from TeamMembers.
|
||||
@@ -1505,6 +1506,7 @@ func (s SqlTeamStore) GetAllForExportAfter(limit int, afterId string) ([]*model.
|
||||
}
|
||||
|
||||
// GetUserTeamIds get the team ids to which the user belongs to. allowFromCache parameter does not have any effect in this Store
|
||||
//nolint:unparam
|
||||
func (s SqlTeamStore) GetUserTeamIds(userId string, allowFromCache bool) ([]string, error) {
|
||||
var teamIds []string
|
||||
query, args, err := s.getQueryBuilder().
|
||||
@@ -1585,7 +1587,7 @@ func (s SqlTeamStore) UpdateMembersRole(teamID string, userIDs []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyTeamMemberViewRestrictionsFilter(query sq.SelectBuilder, teamId string, restrictions *model.ViewUsersRestrictions) sq.SelectBuilder {
|
||||
func applyTeamMemberViewRestrictionsFilter(query sq.SelectBuilder, restrictions *model.ViewUsersRestrictions) sq.SelectBuilder {
|
||||
if restrictions == nil {
|
||||
return query
|
||||
}
|
||||
@@ -1615,7 +1617,7 @@ func applyTeamMemberViewRestrictionsFilter(query sq.SelectBuilder, teamId string
|
||||
return resultQuery.Distinct()
|
||||
}
|
||||
|
||||
func applyTeamMemberViewRestrictionsFilterForStats(query sq.SelectBuilder, teamId string, restrictions *model.ViewUsersRestrictions) sq.SelectBuilder {
|
||||
func applyTeamMemberViewRestrictionsFilterForStats(query sq.SelectBuilder, restrictions *model.ViewUsersRestrictions) sq.SelectBuilder {
|
||||
if restrictions == nil {
|
||||
return query
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user