repochecker/grammalecte: Check for forbidden strings (raw flags) in resolution.md

This commit is contained in:
nemunaire 2022-11-24 13:11:21 +01:00
commit 3421286c9b
4 changed files with 38 additions and 3 deletions

View file

@ -2,6 +2,7 @@ package main
import (
"bytes"
"fmt"
"strings"
"srs.epita.fr/fic-server/admin/sync"
@ -15,7 +16,7 @@ import (
"github.com/yuin/goldmark/util"
)
func GrammalecteCheckMDText(str string, exceptions *sync.CheckExceptions) (errs []error) {
func GrammalecteCheckMDText(str string, exceptions *sync.CheckExceptions, forbiddenStrings ...string) (errs []error) {
if exceptions != nil {
for k := range *exceptions {
tmp := strings.SplitN(k, ":", 3)
@ -25,6 +26,14 @@ func GrammalecteCheckMDText(str string, exceptions *sync.CheckExceptions) (errs
}
}
for _, s := range forbiddenStrings {
if strings.Contains(str, s) {
if !exceptions.HasException(":not-forbidden-string:" + s) {
errs = append(errs, fmt.Errorf("Forbidden raw string %q included in file content, don't write it (:not-forbidden-string:%s)", s, s))
}
}
}
checker := &grammarChecker{
exceptions: exceptions,
}