repochecker/grammalecte: Check for forbidden strings (raw flags) in resolution.md
This commit is contained in:
parent
80422daffb
commit
3421286c9b
4 changed files with 38 additions and 3 deletions
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue