repochecker/grammalecte: Reduce the avoided checks due to other lang

This commit is contained in:
nemunaire 2023-01-18 15:48:59 +01:00
parent 81ea38e2c1
commit 6b74674123

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"log" "log"
"strings"
"unicode" "unicode"
"srs.epita.fr/fic-server/admin/sync" "srs.epita.fr/fic-server/admin/sync"
@ -34,11 +33,9 @@ func GrammalecteCheckKeyFlag(flag *fic.FlagKey, raw string, exercice *fic.Exerci
} }
func GrammalecteCheckFlagChoice(choice *fic.FlagChoice, exercice *fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) { func GrammalecteCheckFlagChoice(choice *fic.FlagChoice, exercice *fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) {
if !isRecognizedLanguage(exercice.Language) { if isRecognizedLanguage(exercice.Language) {
return
}
errs = append(errs, grammalecte("label ", choice.Label, -1, exceptions, &CommonOpts)...) errs = append(errs, grammalecte("label ", choice.Label, -1, exceptions, &CommonOpts)...)
}
if len(errs) == 0 && !unicode.IsUpper(bytes.Runes([]byte(choice.Label))[0]) && !exceptions.HasException(":label_majuscule") { if len(errs) == 0 && !unicode.IsUpper(bytes.Runes([]byte(choice.Label))[0]) && !exceptions.HasException(":label_majuscule") {
errs = append(errs, fmt.Errorf("%q nécessite une majuscule (:label_majuscule)", choice.Label)) errs = append(errs, fmt.Errorf("%q nécessite une majuscule (:label_majuscule)", choice.Label))
@ -48,12 +45,10 @@ func GrammalecteCheckFlagChoice(choice *fic.FlagChoice, exercice *fic.Exercice,
} }
func GrammalecteCheckHint(hint *fic.EHint, exercice *fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) { func GrammalecteCheckHint(hint *fic.EHint, exercice *fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) {
if !isRecognizedLanguage(exercice.Language) {
return
}
if len(hint.Title) > 0 { if len(hint.Title) > 0 {
if isRecognizedLanguage(exercice.Language) {
errs = append(errs, grammalecte("title ", hint.Title, -1, exceptions, &CommonOpts)...) errs = append(errs, grammalecte("title ", hint.Title, -1, exceptions, &CommonOpts)...)
}
if len(errs) == 0 && !unicode.IsUpper(bytes.Runes([]byte(hint.Title))[0]) && !exceptions.HasException(":title_majuscule") { if len(errs) == 0 && !unicode.IsUpper(bytes.Runes([]byte(hint.Title))[0]) && !exceptions.HasException(":title_majuscule") {
errs = append(errs, fmt.Errorf("%q nécessite une majuscule (:title_majuscule)", hint.Title)) errs = append(errs, fmt.Errorf("%q nécessite une majuscule (:title_majuscule)", hint.Title))
} }
@ -69,7 +64,7 @@ func GrammalecteCheckGrammar(data interface{}, exceptions *sync.CheckExceptions)
Str string Str string
Language string Language string
}); ok { }); ok {
if s.Language != "" && strings.HasPrefix(s.Language, "fr") { if !isRecognizedLanguage(s.Language) {
return nil return nil
} }