MM-57378: Bump up golangci version (#26535)

https://mattermost.atlassian.net/browse/MM-57378
```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Agniva De Sarker
2024-03-22 10:23:21 +05:30
коммит произвёл GitHub
родитель 7bae6c57f9
Коммит 9431239b2e
14 изменённых файлов: 51 добавлений и 63 удалений

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

@@ -1,13 +1,10 @@
run: run:
timeout: 10m timeout: 10m
skip-dirs:
- channels/store/storetest/mocks
linters-settings: linters-settings:
gofmt: gofmt:
simplify: true simplify: true
govet: govet:
check-shadowing: true
enable-all: true enable-all: true
disable: disable:
- fieldalignment - fieldalignment
@@ -33,6 +30,8 @@ linters:
# - errcheck # - errcheck
issues: issues:
skip-dirs:
- channels/store/storetest/mocks
exclude-rules: exclude-rules:
- linters: - linters:
# ignore unused warnings from enterprise code # ignore unused warnings from enterprise code

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

@@ -285,7 +285,7 @@ else
endif endif
golangci-lint: ## Run golangci-lint on codebase golangci-lint: ## Run golangci-lint on codebase
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.1
@echo Running golangci-lint @echo Running golangci-lint
$(GOBIN)/golangci-lint run ./... $(GOBIN)/golangci-lint run ./...

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

@@ -842,10 +842,9 @@ func (a *App) parseLinkMetadata(requestURL string, body io.Reader, contentType s
return og, nil, nil return og, nil, nil
} }
return nil, nil, nil return nil, nil, nil
} else {
// Not an image or web page with OpenGraph information
return nil, nil, nil
} }
// Not an image or web page with OpenGraph information
return nil, nil, nil
} }
func parseImages(body io.Reader) (*model.PostImage, error) { func parseImages(body io.Reader) (*model.PostImage, error) {

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

@@ -103,10 +103,9 @@ func (s SqlChannelMemberHistoryStore) hasDataAtOrBefore(time int64) (bool, error
return false, err return false, err
} else if result.Min.Valid { } else if result.Min.Valid {
return result.Min.Int64 <= time, nil return result.Min.Int64 <= time, nil
} else {
// if the result was null, there are no rows in the table, so there is no data from before
return false, nil
} }
// if the result was null, there are no rows in the table, so there is no data from before
return false, nil
} }
func (s SqlChannelMemberHistoryStore) getFromChannelMemberHistoryTable(startTime int64, endTime int64, channelId string) ([]*model.ChannelMemberHistoryResult, error) { func (s SqlChannelMemberHistoryStore) getFromChannelMemberHistoryTable(startTime int64, endTime int64, channelId string) ([]*model.ChannelMemberHistoryResult, error) {

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

@@ -172,9 +172,8 @@ func (ps SqlPluginStore) CompareAndSet(kv *model.PluginKeyValue, oldValue []byte
return false, nil return false, nil
} else if count == 1 { } else if count == 1 {
return true, nil return true, nil
} else {
return false, errors.Wrapf(err, "got too many rows when counting PluginKeyValue with pluginId=%s, key=%s, rows=%d", kv.PluginId, kv.Key, count)
} }
return false, errors.Wrapf(err, "got too many rows when counting PluginKeyValue with pluginId=%s, key=%s, rows=%d", kv.PluginId, kv.Key, count)
} }
// No rows were affected by the update, where condition was not satisfied, // No rows were affected by the update, where condition was not satisfied,

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

@@ -637,10 +637,9 @@ func (ss *SqlStore) DoesTableExist(tableName string) bool {
} }
return count > 0 return count > 0
} else {
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
} }
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
} }
func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool { func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool {
@@ -685,10 +684,9 @@ func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool {
} }
return count > 0 return count > 0
} else {
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
} }
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
} }
func (ss *SqlStore) DoesTriggerExist(triggerName string) bool { func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
@@ -725,10 +723,9 @@ func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
} }
return count > 0 return count > 0
} else {
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
} }
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
} }
func (ss *SqlStore) CreateColumnIfNotExists(tableName string, columnName string, mySqlColType string, postgresColType string, defaultValue string) bool { func (ss *SqlStore) CreateColumnIfNotExists(tableName string, columnName string, mySqlColType string, postgresColType string, defaultValue string) bool {
@@ -750,10 +747,9 @@ func (ss *SqlStore) CreateColumnIfNotExists(tableName string, columnName string,
} }
return true return true
} else {
mlog.Fatal("Failed to create column because of missing driver")
return false
} }
mlog.Fatal("Failed to create column because of missing driver")
return false
} }
func (ss *SqlStore) RemoveTableIfExists(tableName string) bool { func (ss *SqlStore) RemoveTableIfExists(tableName string) bool {

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

@@ -14,12 +14,11 @@ func JoinList(items []string) string {
return "" return ""
} else if len(items) == 1 { } else if len(items) == 1 {
return items[0] return items[0]
} else {
return i18n.T(
"humanize.list_join",
map[string]any{
"OtherItems": strings.Join(items[:len(items)-1], ", "),
"LastItem": items[len(items)-1],
})
} }
return i18n.T(
"humanize.list_join",
map[string]any{
"OtherItems": strings.Join(items[:len(items)-1], ", "),
"LastItem": items[len(items)-1],
})
} }

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

@@ -343,9 +343,9 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
}) })
utils.RenderMobileAuthComplete(w, redirectURL) utils.RenderMobileAuthComplete(w, redirectURL)
return return
} else { // For web
c.App.AttachSessionCookies(c.AppContext, w, r)
} }
// For web
c.App.AttachSessionCookies(c.AppContext, w, r)
desktopToken := "" desktopToken := ""
if val, ok := props["desktop_token"]; ok { if val, ok := props["desktop_token"]; ok {

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

@@ -661,7 +661,8 @@ func HTTPGet(url string, httpClient *http.Client, authToken string, followRedire
} }
} }
if rp, err := httpClient.Do(rq); err != nil { rp, err := httpClient.Do(rq)
if err != nil {
return nil, err return nil, err
} else if rp.StatusCode == 304 { } else if rp.StatusCode == 304 {
return rp, nil return rp, nil
@@ -670,9 +671,8 @@ func HTTPGet(url string, httpClient *http.Client, authToken string, followRedire
} else if rp.StatusCode >= 300 { } else if rp.StatusCode >= 300 {
defer closeBody(rp) defer closeBody(rp)
return rp, model.AppErrorFromJSON(rp.Body) return rp, model.AppErrorFromJSON(rp.Body)
} else {
return rp, nil
} }
return rp, nil
} }
func closeBody(r *http.Response) { func closeBody(r *http.Response) {

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

@@ -4507,9 +4507,8 @@ func isSafeLink(link *string) bool {
return true return true
} else if strings.HasPrefix(*link, "/") { } else if strings.HasPrefix(*link, "/") {
return true return true
} else {
return false
} }
return false
} }
return true return true

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

@@ -750,9 +750,8 @@ func (u *User) GetFullName() string {
return u.FirstName return u.FirstName
} else if u.LastName != "" { } else if u.LastName != "" {
return u.LastName return u.LastName
} else {
return ""
} }
return ""
} }
func (u *User) getDisplayName(baseName, nameFormat string) string { func (u *User) getDisplayName(baseName, nameFormat string) string {

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

@@ -16,15 +16,15 @@ const (
// //
// Call this when your plugin is ready to start. // Call this when your plugin is ready to start.
func ClientMain(pluginImplementation any) { func ClientMain(pluginImplementation any) {
if impl, ok := pluginImplementation.(interface { impl, ok := pluginImplementation.(interface {
SetAPI(api API) SetAPI(api API)
SetDriver(driver Driver) SetDriver(driver Driver)
}); !ok { })
if !ok {
panic("Plugin implementation given must embed plugin.MattermostPlugin") panic("Plugin implementation given must embed plugin.MattermostPlugin")
} else {
impl.SetAPI(nil)
impl.SetDriver(nil)
} }
impl.SetAPI(nil)
impl.SetDriver(nil)
pluginMap := map[string]plugin.Plugin{ pluginMap := map[string]plugin.Plugin{
"hooks": &hooksPlugin{hooks: pluginImplementation}, "hooks": &hooksPlugin{hooks: pluginImplementation},

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

@@ -196,30 +196,30 @@ func (s *hooksRPCServer) Implemented(args struct{}, reply *[]string) error {
var methods []string var methods []string
for i := 0; i < ifaceType.NumMethod(); i++ { for i := 0; i < ifaceType.NumMethod(); i++ {
method := ifaceType.Method(i) method := ifaceType.Method(i)
if m, ok := implType.MethodByName(method.Name); !ok { m, ok := implType.MethodByName(method.Name)
if !ok {
continue continue
} else if m.Type.NumIn() != method.Type.NumIn()+1 { } else if m.Type.NumIn() != method.Type.NumIn()+1 {
continue continue
} else if m.Type.NumOut() != method.Type.NumOut() { } else if m.Type.NumOut() != method.Type.NumOut() {
continue continue
} else { }
match := true match := true
for j := 0; j < method.Type.NumIn(); j++ { for j := 0; j < method.Type.NumIn(); j++ {
if m.Type.In(j+1) != method.Type.In(j) { if m.Type.In(j+1) != method.Type.In(j) {
match = false match = false
break break
}
} }
for j := 0; j < method.Type.NumOut(); j++ { }
if m.Type.Out(j) != method.Type.Out(j) { for j := 0; j < method.Type.NumOut(); j++ {
match = false if m.Type.Out(j) != method.Type.Out(j) {
break match = false
} break
}
if !match {
continue
} }
} }
if !match {
continue
}
if _, ok := selfType.MethodByName(method.Name); !ok { if _, ok := selfType.MethodByName(method.Name); !ok {
continue continue
} }

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

@@ -28,9 +28,8 @@ func HumanizeJSONError(err error, data []byte) error {
return NewHumanizedJSONError(syntaxError, data, syntaxError.Offset) return NewHumanizedJSONError(syntaxError, data, syntaxError.Offset)
} else if unmarshalError, ok := err.(*json.UnmarshalTypeError); ok { } else if unmarshalError, ok := err.(*json.UnmarshalTypeError); ok {
return NewHumanizedJSONError(unmarshalError, data, unmarshalError.Offset) return NewHumanizedJSONError(unmarshalError, data, unmarshalError.Offset)
} else {
return err
} }
return err
} }
func NewHumanizedJSONError(err error, data []byte, offset int64) *HumanizedJSONError { func NewHumanizedJSONError(err error, data []byte, offset int64) *HumanizedJSONError {