MM-31064: Simplify indentation (#16565)
* MM-31064: Simplify indentation Reduce indentation where possible. ```release-note NONE ``` Command ran to verify: golangci-lint run --disable-all --enable golint --max-issues-per-linter=10000 --max-same-issues=100000 ./... | grep "block ends with a return state" https://mattermost.atlassian.net/browse/MM-31064 * incorporate review comments * enable golint for outdent rule * fix remaining issues Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7419898449
Коммит
1a131b54af
@@ -43,11 +43,11 @@ func NewHTMLTemplateWatcher(directory string) (*HTMLTemplateWatcher, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if htmlTemplates, err := template.ParseGlob(filepath.Join(templatesDir, "*.html")); err != nil {
|
||||
htmlTemplates, err := template.ParseGlob(filepath.Join(templatesDir, "*.html"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
ret.templates.Store(htmlTemplates)
|
||||
}
|
||||
ret.templates.Store(htmlTemplates)
|
||||
|
||||
go func() {
|
||||
defer close(ret.stopped)
|
||||
|
||||
@@ -87,12 +87,12 @@ func GetAndValidateLicenseFileFromDisk(location string) (*model.License, []byte)
|
||||
mlog.Info("License key has not been uploaded. Loading license key from disk at", mlog.String("filename", fileName))
|
||||
licenseBytes := GetLicenseFileFromDisk(fileName)
|
||||
|
||||
if success, licenseStr := ValidateLicense(licenseBytes); !success {
|
||||
success, licenseStr := ValidateLicense(licenseBytes)
|
||||
if !success {
|
||||
mlog.Error("Found license key at %v but it appears to be invalid.", mlog.String("filename", fileName))
|
||||
return nil, nil
|
||||
} else {
|
||||
return model.LicenseFromJson(strings.NewReader(licenseStr)), licenseBytes
|
||||
}
|
||||
return model.LicenseFromJson(strings.NewReader(licenseStr)), licenseBytes
|
||||
}
|
||||
|
||||
func GetLicenseFileFromDisk(fileName string) []byte {
|
||||
@@ -116,9 +116,8 @@ func GetLicenseFileLocation(fileLocation string) string {
|
||||
if fileLocation == "" {
|
||||
configDir, _ := fileutils.FindDir("config")
|
||||
return filepath.Join(configDir, "mattermost.mattermost-license")
|
||||
} else {
|
||||
return fileLocation
|
||||
}
|
||||
return fileLocation
|
||||
}
|
||||
|
||||
func GetClientLicense(l *model.License) map[string]string {
|
||||
|
||||
@@ -406,10 +406,9 @@ func (p *inlineParser) lookForLinkOrImage() {
|
||||
}
|
||||
p.delimiterStack.Remove(element)
|
||||
return
|
||||
} else {
|
||||
p.delimiterStack.Remove(element)
|
||||
break
|
||||
}
|
||||
p.delimiterStack.Remove(element)
|
||||
break
|
||||
}
|
||||
absPos := relativeToAbsolutePosition(p.ranges, p.position)
|
||||
p.inlines = append(p.inlines, &Text{
|
||||
|
||||
@@ -120,13 +120,13 @@ func UpdateAssetsSubpathInDir(subpath, directory string) error {
|
||||
// Rewrite the manifest.json and *.css references to `/static/*` (or a previously rewritten subpath).
|
||||
err = filepath.Walk(staticDir, func(walkPath string, info os.FileInfo, err error) error {
|
||||
if filepath.Base(walkPath) == "manifest.json" || filepath.Ext(walkPath) == ".css" {
|
||||
if old, err := ioutil.ReadFile(walkPath); err != nil {
|
||||
old, err := ioutil.ReadFile(walkPath)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to open %s", walkPath)
|
||||
} else {
|
||||
new := strings.Replace(string(old), pathToReplace, newPath, -1)
|
||||
if err = ioutil.WriteFile(walkPath, []byte(new), 0); err != nil {
|
||||
return errors.Wrapf(err, "failed to update %s with subpath %s", walkPath, subpath)
|
||||
}
|
||||
}
|
||||
new := strings.Replace(string(old), pathToReplace, newPath, -1)
|
||||
if err = ioutil.WriteFile(walkPath, []byte(new), 0); err != nil {
|
||||
return errors.Wrapf(err, "failed to update %s with subpath %s", walkPath, subpath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,8 @@ func ReadTestFile(name string) ([]byte, error) {
|
||||
data := &bytes.Buffer{}
|
||||
if _, err := io.Copy(data, file); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return data.Bytes(), nil
|
||||
}
|
||||
return data.Bytes(), nil
|
||||
}
|
||||
|
||||
// GetInterface returns the best match of an interface that might be listening on a given port.
|
||||
|
||||
Ссылка в новой задаче
Block a user