Fix empty string comparison issues in the codebase (#16686)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
200a56fa5a
Коммит
94c24eea20
@@ -352,7 +352,7 @@ func getPathsFromObjectInfos(in <-chan s3.ObjectInfo) <-chan s3.ObjectInfo {
|
||||
|
||||
func (b *S3FileBackend) ListDirectory(path string) ([]string, error) {
|
||||
path = filepath.Join(b.pathPrefix, path)
|
||||
if !strings.HasSuffix(path, "/") && len(path) > 0 {
|
||||
if !strings.HasSuffix(path, "/") && path != "" {
|
||||
// s3Clnt returns only the path itself when "/" is not present
|
||||
// appending "/" to make it consistent across all filesstores
|
||||
path = path + "/"
|
||||
@@ -408,12 +408,12 @@ func s3PutOptions(encrypted bool, contentType string) s3.PutObjectOptions {
|
||||
}
|
||||
|
||||
func CheckMandatoryS3Fields(settings *model.FileSettings) error {
|
||||
if settings.AmazonS3Bucket == nil || len(*settings.AmazonS3Bucket) == 0 {
|
||||
if settings.AmazonS3Bucket == nil || *settings.AmazonS3Bucket == "" {
|
||||
return errors.New("missing s3 bucket settings")
|
||||
}
|
||||
|
||||
// if S3 endpoint is not set call the set defaults to set that
|
||||
if settings.AmazonS3Endpoint == nil || len(*settings.AmazonS3Endpoint) == 0 {
|
||||
if settings.AmazonS3Endpoint == nil || *settings.AmazonS3Endpoint == "" {
|
||||
settings.SetDefaults(true)
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ func SendMailUsingConfig(to, subject, htmlBody string, config *model.Config, ena
|
||||
|
||||
// allows for sending an email with attachments and differing MIME/SMTP recipients
|
||||
func sendMailUsingConfigAdvanced(mail mailData, config *model.Config, enableComplianceFeatures bool) *model.AppError {
|
||||
if len(*config.EmailSettings.SMTPServer) == 0 {
|
||||
if *config.EmailSettings.SMTPServer == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -324,11 +324,11 @@ func SendMail(c smtpClient, mail mailData, fileBackend filesstore.FileBackend, d
|
||||
"Precedence": {"bulk"},
|
||||
}
|
||||
|
||||
if len(mail.replyTo.Address) > 0 {
|
||||
if mail.replyTo.Address != "" {
|
||||
headers["Reply-To"] = []string{mail.replyTo.String()}
|
||||
}
|
||||
|
||||
if len(mail.cc) > 0 {
|
||||
if mail.cc != "" {
|
||||
headers["CC"] = []string{mail.cc}
|
||||
}
|
||||
|
||||
|
||||
@@ -424,10 +424,10 @@ func TestSendMail(t *testing.T) {
|
||||
mail := mailData{"", "", mail.Address{}, "", tc.replyTo, "", "", nil, nil, nil}
|
||||
appErr = SendMail(mocm, mail, mockBackend, time.Now())
|
||||
require.Nil(t, appErr)
|
||||
if len(tc.contains) > 0 {
|
||||
if tc.contains != "" {
|
||||
require.Contains(t, string(mocm.data), tc.contains)
|
||||
}
|
||||
if len(tc.notContains) > 0 {
|
||||
if tc.notContains != "" {
|
||||
require.NotContains(t, string(mocm.data), tc.notContains)
|
||||
}
|
||||
mocm.data = []byte{}
|
||||
|
||||
@@ -43,7 +43,7 @@ func getIssuerFromUrl(uri string) string {
|
||||
issuer := "Mattermost"
|
||||
siteUrl := strings.TrimSpace(uri)
|
||||
|
||||
if len(siteUrl) > 0 {
|
||||
if siteUrl != "" {
|
||||
siteUrl = strings.TrimPrefix(siteUrl, "https://")
|
||||
siteUrl = strings.TrimPrefix(siteUrl, "http://")
|
||||
issuer = strings.TrimPrefix(siteUrl, "www.")
|
||||
|
||||
@@ -159,7 +159,7 @@ func (b *BleveEngine) SearchPosts(channels *model.ChannelList, searchParams []*m
|
||||
notTermQueries = append(notTermQueries, hashtagQ)
|
||||
}
|
||||
} else {
|
||||
if len(params.Terms) > 0 {
|
||||
if params.Terms != "" {
|
||||
terms := []string{}
|
||||
for _, term := range strings.Split(params.Terms, " ") {
|
||||
if strings.HasSuffix(term, "*") {
|
||||
@@ -179,7 +179,7 @@ func (b *BleveEngine) SearchPosts(channels *model.ChannelList, searchParams []*m
|
||||
}
|
||||
}
|
||||
|
||||
if len(params.ExcludedTerms) > 0 {
|
||||
if params.ExcludedTerms != "" {
|
||||
messageQ := bleve.NewMatchQuery(params.ExcludedTerms)
|
||||
messageQ.SetField("Message")
|
||||
messageQ.SetOperator(termOperator)
|
||||
@@ -654,7 +654,7 @@ func (b *BleveEngine) SearchFiles(channels *model.ChannelList, searchParams []*m
|
||||
}
|
||||
}
|
||||
|
||||
if len(params.Terms) > 0 {
|
||||
if params.Terms != "" {
|
||||
terms := []string{}
|
||||
for _, term := range strings.Split(params.Terms, " ") {
|
||||
if strings.HasSuffix(term, "*") {
|
||||
@@ -679,7 +679,7 @@ func (b *BleveEngine) SearchFiles(channels *model.ChannelList, searchParams []*m
|
||||
}
|
||||
}
|
||||
|
||||
if len(params.ExcludedTerms) > 0 {
|
||||
if params.ExcludedTerms != "" {
|
||||
nameQ := bleve.NewMatchQuery(params.ExcludedTerms)
|
||||
nameQ.SetField("Name")
|
||||
nameQ.SetOperator(termOperator)
|
||||
|
||||
@@ -126,7 +126,7 @@ func (ts *TelemetryService) ensureTelemetryID() {
|
||||
}
|
||||
|
||||
id := props[model.SYSTEM_TELEMETRY_ID]
|
||||
if len(id) == 0 {
|
||||
if id == "" {
|
||||
id = model.NewId()
|
||||
systemID := &model.System{Name: model.SYSTEM_TELEMETRY_ID, Value: id}
|
||||
ts.dbStore.System().Save(systemID)
|
||||
|
||||
Ссылка в новой задаче
Block a user