1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-04 18:19:54 +00:00

Please staticcheck

I ignored ST1005: error strings should not be capitalized and some others
This commit is contained in:
Timur Ismagilov 2022-04-02 11:09:37 +03:00
parent cc01a3551d
commit 75ded17a03
8 changed files with 12 additions and 33 deletions

View File

@ -193,7 +193,7 @@ func ReadConfigFile(path string) error {
TelegramEnabled = (TelegramBotToken != "") && (TelegramBotName != "")
// This URL makes much more sense. If no URL is set or the protocol is forgotten, assume HTTP.
if (URL == "") || (strings.Index(URL, ":") == -1) {
if (URL == "") || !strings.Contains(URL, ":") {
URL = "http://" + ListenAddr
}

View File

@ -175,7 +175,7 @@ func (rev *Revision) hyphaeAffected() (hyphae []string) {
filesAffected = rev.filesAffected()
)
for _, filename := range filesAffected {
if strings.IndexRune(filename, '.') >= 0 {
if strings.ContainsRune(filename, '.') {
dotPos := strings.LastIndexByte(filename, '.')
hyphaName := string([]byte(filename)[0:dotPos]) // is it safe?
if isNewName(hyphaName) {

View File

@ -3,21 +3,11 @@
"register": "Register",
"title_search": "Search by title",
"admin_panel": "Admin panel",
"search_results_title": "Search: {{.query}}",
"search_results_query": "Search results for {{.query}}",
"search_results_desc": "Every hypha name has been compared with the query. Hyphae that have matched the query are listed below.",
"backlinks_title": "Backlinks to {{.hypha_name}}",
"backlinks_heading": "Backlinks to {{.hypha_link}}",
"backlinks_desc": "Hyphae which have a link to this hypha, embed it as an image or transclude it are listed below.",
"list_title": "List of pages",
"list_heading": "List of hyphae",
"list_desc": "This wiki has {{.n}} %s.",
"list_desc+one": "hypha",
"list_desc+other": "hyphae",
"edit_link": "Edit text",
"logout_link": "Log out",
"history_link": "View history",

View File

@ -118,7 +118,7 @@ func (t Localizer) GetWithLocale(locale, key string, replacements ...*Replacemen
// If the str doesn't have any substitutions, no need to
// template.Execute.
if strings.Index(str, "}}") == -1 {
if strings.Contains(str, "}}") {
return str
}
@ -145,7 +145,7 @@ func (t Localizer) GetPlural(key string, n int, replacements ...*Replacements) s
// As in the original, we skip templating if have nothing to replace
// (however, it's strange case for plurals)
if strings.Index(str, "}}") == -1 {
if strings.Contains(str, "}}") {
return str
}
@ -164,7 +164,7 @@ func (t Localizer) GetPlural64(key string, n int64, replacements ...*Replacement
// As in the original, we skip templating if have nothing to replace
// (however, it's strange case for plurals)
if strings.Index(str, "}}") == -1 {
if strings.Contains(str, "}}") {
return str
}

View File

@ -3,21 +3,10 @@
"register": "Регистрация",
"title_search": "Поиск по названию",
"admin_panel": "Администрирование",
"search_results_title": "Поиск: {{.query}}",
"search_results_query": "Результаты поиска для «{{.query}}»",
"search_results_desc": "Название каждой из существующих гиф сопоставлено с запросом. Подходящие гифы приведены ниже.",
"backlinks_title": "Обратные ссылки на {{.hypha_name}}",
"backlinks_heading": "Обратные ссылки на {{.hypha_link}}",
"backlinks_desc": "Ниже перечислены гифы, на которых есть ссылка на эту гифу, трансклюзия этой гифы или эта гифа вставлена как изображение.",
"list_title": "Список страниц",
"list_heading": "Список гиф",
"list_desc": "В этой вики {{.n}} %s.",
"list_desc+one": "гифа",
"list_desc+few": "гифы",
"list_desc+many": "гиф",
"edit_link": "Редактировать",
"logout_link": "Выйти",

View File

@ -7,9 +7,6 @@ import (
"github.com/bouncepaw/mycorrhiza/user"
)
func rejectDeleteLog(h hyphae.Hypha, u *user.User, errmsg string) {
log.Printf("Reject delete %s by @%s: %s\n", h.CanonicalName(), u.Name, errmsg)
}
func rejectRenameLog(h hyphae.Hypha, u *user.User, errmsg string) {
log.Printf("Reject rename %s by @%s: %s\n", h.CanonicalName(), u.Name, errmsg)
}

View File

@ -97,7 +97,7 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e
}
// TODO: that []byte(...) part should be removed
if bytes.Compare(data, []byte(oldText)) == 0 {
if bytes.Equal(data, []byte(oldText)) {
// No changes! Just like cancel button
hop.Abort()
return nil
@ -118,7 +118,7 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e
}
// TODO: that []byte(...) part should be removed
if bytes.Compare(data, []byte(oldText)) == 0 {
if bytes.Equal(data, []byte(oldText)) {
// No changes! Just like cancel button
hop.Abort()
return nil

View File

@ -71,4 +71,7 @@ func AdminPanel(meta viewutil.Meta) {
templateAsString(localizedAdminTemplates(meta), "panel title"),
buf.String(),
))
if err != nil {
log.Println(err)
}
}