mirror of
https://github.com/gogs/gogs.git
synced 2026-03-04 11:11:03 +01:00
autofix: function call can be replaced with helper function (#6805)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
deec3516d5
commit
5afca6ca8e
@@ -112,10 +112,10 @@ func parseKeyString(content string) (string, error) {
|
||||
// Transform all legal line endings to a single "\n"
|
||||
|
||||
// Replace all windows full new lines ("\r\n")
|
||||
content = strings.Replace(content, "\r\n", "\n", -1)
|
||||
content = strings.ReplaceAll(content, "\r\n", "\n")
|
||||
|
||||
// Replace all windows half new lines ("\r"), if it happen not to match replace above
|
||||
content = strings.Replace(content, "\r", "\n", -1)
|
||||
content = strings.ReplaceAll(content, "\r", "\n")
|
||||
|
||||
// Replace ending new line as its may cause unwanted behaviour (extra line means not a single line key | OpenSSH key)
|
||||
content = strings.TrimRight(content, "\n")
|
||||
@@ -374,8 +374,7 @@ func checkKeyContent(content string) error {
|
||||
|
||||
func addKey(e Engine, key *PublicKey) (err error) {
|
||||
// Calculate fingerprint.
|
||||
tmpPath := strings.Replace(path.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().Nanosecond()),
|
||||
"id_rsa.pub"), "\\", "/", -1)
|
||||
tmpPath := strings.ReplaceAll(path.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().Nanosecond()), "id_rsa.pub"), "\\", "/")
|
||||
_ = os.MkdirAll(path.Dir(tmpPath), os.ModePerm)
|
||||
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil {
|
||||
return err
|
||||
|
||||
@@ -51,18 +51,18 @@ func (p *SlackPayload) JSONPayload() ([]byte, error) {
|
||||
// see: https://api.slack.com/docs/formatting
|
||||
func SlackTextFormatter(s string) string {
|
||||
// replace & < >
|
||||
s = strings.Replace(s, "&", "&", -1)
|
||||
s = strings.Replace(s, "<", "<", -1)
|
||||
s = strings.Replace(s, ">", ">", -1)
|
||||
s = strings.ReplaceAll(s, "&", "&")
|
||||
s = strings.ReplaceAll(s, "<", "<")
|
||||
s = strings.ReplaceAll(s, ">", ">")
|
||||
return s
|
||||
}
|
||||
|
||||
func SlackShortTextFormatter(s string) string {
|
||||
s = strings.Split(s, "\n")[0]
|
||||
// replace & < >
|
||||
s = strings.Replace(s, "&", "&", -1)
|
||||
s = strings.Replace(s, "<", "<", -1)
|
||||
s = strings.Replace(s, ">", ">", -1)
|
||||
s = strings.ReplaceAll(s, "&", "&")
|
||||
s = strings.ReplaceAll(s, "<", "<")
|
||||
s = strings.ReplaceAll(s, ">", ">")
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func ToWikiPageURL(name string) string {
|
||||
// that are not belong to wiki repository.
|
||||
func ToWikiPageName(urlString string) string {
|
||||
name, _ := url.QueryUnescape(urlString)
|
||||
return strings.Replace(strings.TrimLeft(path.Clean("/"+name), "/"), "/", " ", -1)
|
||||
return strings.ReplaceAll(strings.TrimLeft(path.Clean("/"+name), "/"), "/", " ")
|
||||
}
|
||||
|
||||
// WikiCloneLink returns clone URLs of repository wiki.
|
||||
|
||||
Reference in New Issue
Block a user