From 98939e9d618be2be4798527b76db72c08712e103 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 31 Oct 2022 23:33:42 +0100 Subject: [PATCH] repochecker/grammalecte: Check labels and titles have upper case --- repochecker/grammalecte/flags.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/repochecker/grammalecte/flags.go b/repochecker/grammalecte/flags.go index c2b12c40..1f24a490 100644 --- a/repochecker/grammalecte/flags.go +++ b/repochecker/grammalecte/flags.go @@ -1,8 +1,11 @@ package main import ( + "bytes" + "fmt" "log" "strings" + "unicode" "srs.epita.fr/fic-server/admin/sync" "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) { 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 } func GrammalecteCheckHint(hint *fic.EHint, exceptions *sync.CheckExceptions) (errs []error) { if len(hint.Title) > 0 { 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