repochecker/grammalecte: Check labels and titles have upper case

This commit is contained in:
nemunaire 2022-10-31 23:33:42 +01:00
parent 960122dfb6
commit 98939e9d61

View File

@ -1,8 +1,11 @@
package main package main
import ( import (
"bytes"
"fmt"
"log" "log"
"strings" "strings"
"unicode"
"srs.epita.fr/fic-server/admin/sync" "srs.epita.fr/fic-server/admin/sync"
"srs.epita.fr/fic-server/libfic" "srs.epita.fr/fic-server/libfic"
@ -29,12 +32,19 @@ func GrammalecteCheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.Che
func GrammalecteCheckFlagChoice(choice *fic.FlagChoice, exceptions *sync.CheckExceptions) (errs []error) { func GrammalecteCheckFlagChoice(choice *fic.FlagChoice, exceptions *sync.CheckExceptions) (errs []error) {
errs = append(errs, grammalecte("label ", choice.Label, exceptions, &CommonOpts)...) errs = append(errs, grammalecte("label ", choice.Label, exceptions, &CommonOpts)...)
if len(errs) == 0 && !unicode.IsUpper(bytes.Runes([]byte(choice.Label))[0]) && !exceptions.HasException(":1:label_majuscule") {
errs = append(errs, fmt.Errorf("%q nécessite une majuscule (:1:label_majuscule)", choice.Label))
}
return return
} }
func GrammalecteCheckHint(hint *fic.EHint, exceptions *sync.CheckExceptions) (errs []error) { func GrammalecteCheckHint(hint *fic.EHint, exceptions *sync.CheckExceptions) (errs []error) {
if len(hint.Title) > 0 { if len(hint.Title) > 0 {
errs = append(errs, grammalecte("title ", hint.Title, exceptions, &CommonOpts)...) errs = append(errs, grammalecte("title ", hint.Title, exceptions, &CommonOpts)...)
if len(errs) == 0 && !unicode.IsUpper(bytes.Runes([]byte(hint.Title))[0]) && !exceptions.HasException(":1:title_majuscule") {
errs = append(errs, fmt.Errorf("%q nécessite une majuscule (:1:label_majuscule)", hint.Title))
}
} }
// Hint content are checked through GrammalecteCheckMDText, no need to check them // Hint content are checked through GrammalecteCheckMDText, no need to check them