diff --git a/.golangci.yml b/.golangci.yml index 2770dea477..809c31990d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,8 @@ service: run: timeout: 5m modules-download-mode: vendor + skip-dirs: + - store/storetest/mocks linters-settings: gofmt: @@ -39,4 +41,4 @@ issues: - linters: # ignore golint error for a lot of packages for now - golint - path: "api4|app|cmd|einterface|enterprise|imports|jobs|manualtesting|migrations|mlog|model|testlib|services|store|utils|web|wsapi|plugin/api.go|plugin/context.go|plugin/client.go|plugin/client_rpc.go|plugin/environment.go|plugin/health_check.go|plugin/hooks.go|plugin/supervisor.go|plugin/valid.go" + path: "api4|app|cmd|einterface|enterprise|imports|jobs|manualtesting|migrations|mlog|model|testlib|services|store|utils|web|wsapi|plugin/plugintest/api.go|plugin/api.go|plugin/context.go|plugin/client.go|plugin/client_rpc.go|plugin/client_rpc_generated.go|plugin/environment.go|plugin/health_check.go|plugin/hooks.go|plugin/supervisor.go|plugin/valid.go" diff --git a/store/layer_generators/main.go b/store/layer_generators/main.go index 5adfda8914..25915c298a 100644 --- a/store/layer_generators/main.go +++ b/store/layer_generators/main.go @@ -10,11 +10,11 @@ import ( "go/format" "go/parser" "go/token" - "html/template" "io/ioutil" "os" "path" "strings" + "text/template" ) func main() { @@ -253,8 +253,12 @@ func (s *{{$.Name}}{{$substoreName}}Store) {{$index}}({{$element.Params | joinPa success = "true" } s.Root.Metrics.ObserveStoreMethodDuration("{{$substoreName}}Store.{{$index}}", success, elapsed) + {{ with ($element.Results | genResultsVars) -}} } - return {{$element.Results | genResultsVars}} + return {{ . }} + {{- else -}} + } + {{- end }} } {{end}} {{end}} diff --git a/store/timer_layer.go b/store/timer_layer.go index 4626d4a8e9..dc76a5539f 100644 --- a/store/timer_layer.go +++ b/store/timer_layer.go @@ -549,7 +549,6 @@ func (s *TimerLayerChannelStore) ClearCaches() { } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ClearCaches", success, elapsed) } - return } func (s *TimerLayerChannelStore) CountPostsAfter(channelId string, timestamp int64, userId string) (int, *model.AppError) { @@ -1237,7 +1236,6 @@ func (s *TimerLayerChannelStore) InvalidateAllChannelMembersForUser(userId strin } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateAllChannelMembersForUser", success, elapsed) } - return } func (s *TimerLayerChannelStore) InvalidateCacheForChannelMembersNotifyProps(channelId string) { @@ -1253,7 +1251,6 @@ func (s *TimerLayerChannelStore) InvalidateCacheForChannelMembersNotifyProps(cha } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateCacheForChannelMembersNotifyProps", success, elapsed) } - return } func (s *TimerLayerChannelStore) InvalidateChannel(id string) { @@ -1269,7 +1266,6 @@ func (s *TimerLayerChannelStore) InvalidateChannel(id string) { } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateChannel", success, elapsed) } - return } func (s *TimerLayerChannelStore) InvalidateChannelByName(teamId string, name string) { @@ -1285,7 +1281,6 @@ func (s *TimerLayerChannelStore) InvalidateChannelByName(teamId string, name str } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateChannelByName", success, elapsed) } - return } func (s *TimerLayerChannelStore) InvalidateGuestCount(channelId string) { @@ -1301,7 +1296,6 @@ func (s *TimerLayerChannelStore) InvalidateGuestCount(channelId string) { } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateGuestCount", success, elapsed) } - return } func (s *TimerLayerChannelStore) InvalidateMemberCount(channelId string) { @@ -1317,7 +1311,6 @@ func (s *TimerLayerChannelStore) InvalidateMemberCount(channelId string) { } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateMemberCount", success, elapsed) } - return } func (s *TimerLayerChannelStore) InvalidatePinnedPostCount(channelId string) { @@ -1333,7 +1326,6 @@ func (s *TimerLayerChannelStore) InvalidatePinnedPostCount(channelId string) { } s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidatePinnedPostCount", success, elapsed) } - return } func (s *TimerLayerChannelStore) IsUserInChannelUseCache(userId string, channelId string) bool { @@ -2085,7 +2077,6 @@ func (s *TimerLayerCommandWebhookStore) Cleanup() { } s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Cleanup", success, elapsed) } - return } func (s *TimerLayerCommandWebhookStore) Get(id string) (*model.CommandWebhook, *model.AppError) { @@ -2373,7 +2364,6 @@ func (s *TimerLayerFileInfoStore) ClearCaches() { } s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.ClearCaches", success, elapsed) } - return } func (s *TimerLayerFileInfoStore) DeleteForPost(postId string) (string, *model.AppError) { @@ -2469,7 +2459,6 @@ func (s *TimerLayerFileInfoStore) InvalidateFileInfosForPostCache(postId string) } s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.InvalidateFileInfosForPostCache", success, elapsed) } - return } func (s *TimerLayerFileInfoStore) PermanentDelete(fileId string) *model.AppError { @@ -3861,7 +3850,6 @@ func (s *TimerLayerPostStore) ClearCaches() { } s.Root.Metrics.ObserveStoreMethodDuration("PostStore.ClearCaches", success, elapsed) } - return } func (s *TimerLayerPostStore) Delete(postId string, time int64, deleteByID string) *model.AppError { @@ -4229,7 +4217,6 @@ func (s *TimerLayerPostStore) InvalidateLastPostTimeCache(channelId string) { } s.Root.Metrics.ObserveStoreMethodDuration("PostStore.InvalidateLastPostTimeCache", success, elapsed) } - return } func (s *TimerLayerPostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError) { @@ -4821,7 +4808,6 @@ func (s *TimerLayerSessionStore) Cleanup(expiryTime int64, batchSize int64) { } s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Cleanup", success, elapsed) } - return } func (s *TimerLayerSessionStore) Get(sessionIdOrToken string) (*model.Session, *model.AppError) { @@ -5285,7 +5271,6 @@ func (s *TimerLayerTeamStore) ClearCaches() { } s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ClearCaches", success, elapsed) } - return } func (s *TimerLayerTeamStore) Get(id string) (*model.Team, *model.AppError) { @@ -5685,7 +5670,6 @@ func (s *TimerLayerTeamStore) InvalidateAllTeamIdsForUser(userId string) { } s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.InvalidateAllTeamIdsForUser", success, elapsed) } - return } func (s *TimerLayerTeamStore) MigrateTeamMembers(fromTeamId string, fromUserId string) (map[string]string, *model.AppError) { @@ -6021,7 +6005,6 @@ func (s *TimerLayerTokenStore) Cleanup() { } s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Cleanup", success, elapsed) } - return } func (s *TimerLayerTokenStore) Delete(token string) *model.AppError { @@ -6165,7 +6148,6 @@ func (s *TimerLayerUserStore) ClearCaches() { } s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ClearCaches", success, elapsed) } - return } func (s *TimerLayerUserStore) Count(options model.UserCountOptions) (int64, *model.AppError) { @@ -6741,7 +6723,6 @@ func (s *TimerLayerUserStore) InvalidateProfileCacheForUser(userId string) { } s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfileCacheForUser", success, elapsed) } - return } func (s *TimerLayerUserStore) InvalidateProfilesInChannelCache(channelId string) { @@ -6757,7 +6738,6 @@ func (s *TimerLayerUserStore) InvalidateProfilesInChannelCache(channelId string) } s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfilesInChannelCache", success, elapsed) } - return } func (s *TimerLayerUserStore) InvalidateProfilesInChannelCacheByUser(userId string) { @@ -6773,7 +6753,6 @@ func (s *TimerLayerUserStore) InvalidateProfilesInChannelCacheByUser(userId stri } s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfilesInChannelCacheByUser", success, elapsed) } - return } func (s *TimerLayerUserStore) PermanentDelete(userId string) *model.AppError { @@ -7317,7 +7296,6 @@ func (s *TimerLayerWebhookStore) ClearCaches() { } s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.ClearCaches", success, elapsed) } - return } func (s *TimerLayerWebhookStore) DeleteIncoming(webhookId string, time int64) *model.AppError { @@ -7573,7 +7551,6 @@ func (s *TimerLayerWebhookStore) InvalidateWebhookCache(webhook string) { } s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.InvalidateWebhookCache", success, elapsed) } - return } func (s *TimerLayerWebhookStore) PermanentDeleteIncomingByChannel(channelId string) *model.AppError {