sync: Introduce repochecker-ack.txt to support check exceptions
This commit is contained in:
parent
edde9f885d
commit
fb368d79d1
17 changed files with 283 additions and 106 deletions
|
|
@ -4,10 +4,11 @@ import (
|
|||
"fmt"
|
||||
"path"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
func EPITACheckFile(file *fic.EFile) (errs []error) {
|
||||
func EPITACheckFile(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
// Enforce file format
|
||||
if path.Ext(file.Name) == "rar" || path.Ext(file.Name) == "7z" {
|
||||
errs = append(errs, fmt.Errorf("this file use a forbidden archive type."))
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"strings"
|
||||
"unicode"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ func (e SpellingError) Error() string {
|
|||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"%sspelling error %s %s\n%q\n%s%s",
|
||||
"%sspelling error %s %q (:spelling:%s)\n%q\n%s%s",
|
||||
e.Prefix,
|
||||
e.Type,
|
||||
e.Value,
|
||||
e.Value,
|
||||
e.Source,
|
||||
underline(1, e.Start, e.End),
|
||||
suggestions,
|
||||
|
|
@ -61,10 +62,10 @@ func (e GrammarError) Error() string {
|
|||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"%s%s (%s)\n%q\n%s%s",
|
||||
"%s%s (%d:%s)\n%q\n%s%s",
|
||||
e.Prefix,
|
||||
e.Message,
|
||||
e.RuleId,
|
||||
e.NSource, e.RuleId,
|
||||
e.Source,
|
||||
underline(1, e.Start, e.End),
|
||||
suggestions,
|
||||
|
|
|
|||
|
|
@ -1,36 +1,37 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
func GrammalecteCheckKeyFlag(flag *fic.FlagKey, raw string) (errs []error) {
|
||||
func GrammalecteCheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
label, _, _, _ := flag.AnalyzeFlagLabel()
|
||||
errs = append(errs, grammalecte("label ", label, &CommonOpts)...)
|
||||
errs = append(errs, grammalecte("label ", label, exceptions, &CommonOpts)...)
|
||||
|
||||
if len(flag.Help) > 0 {
|
||||
errs = append(errs, grammalecte("help ", flag.Help, &CommonOpts)...)
|
||||
errs = append(errs, grammalecte("help ", flag.Help, exceptions, &CommonOpts)...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GrammalecteCheckFlagChoice(choice *fic.FlagChoice) (errs []error) {
|
||||
errs = append(errs, grammalecte("label ", choice.Label, &CommonOpts)...)
|
||||
func GrammalecteCheckFlagChoice(choice *fic.FlagChoice, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
errs = append(errs, grammalecte("label ", choice.Label, exceptions, &CommonOpts)...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GrammalecteCheckHint(hint *fic.EHint) (errs []error) {
|
||||
func GrammalecteCheckHint(hint *fic.EHint, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
if len(hint.Title) > 0 {
|
||||
errs = append(errs, grammalecte("title ", hint.Title, &CommonOpts)...)
|
||||
errs = append(errs, grammalecte("title ", hint.Title, exceptions, &CommonOpts)...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GrammalecteCheckMDText(str string) (errs []error) {
|
||||
errs = append(errs, grammalecte("", str, &CommonOpts)...)
|
||||
func GrammalecteCheckMDText(str string, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
errs = append(errs, grammalecte("", str, exceptions, &CommonOpts)...)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
)
|
||||
|
||||
type GrammalecteOptions struct {
|
||||
|
|
@ -115,7 +118,7 @@ var (
|
|||
mdimg = regexp.MustCompile(`!\[([^\]]+)\]\([^)]+\)`)
|
||||
)
|
||||
|
||||
func grammalecte(name string, text string, options *GrammalecteOptions) (errs []error) {
|
||||
func grammalecte(name string, text string, exceptions *sync.CheckExceptions, options *GrammalecteOptions) (errs []error) {
|
||||
// Remove Markdown elements
|
||||
text = mdimg.ReplaceAllString(text, "Image : ${1}")
|
||||
|
||||
|
|
@ -161,7 +164,7 @@ func grammalecte(name string, text string, options *GrammalecteOptions) (errs []
|
|||
break
|
||||
}
|
||||
}
|
||||
if allowed {
|
||||
if allowed || exceptions.HasException(":spelling:"+serror.Value) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -183,6 +186,10 @@ func grammalecte(name string, text string, options *GrammalecteOptions) (errs []
|
|||
continue
|
||||
}
|
||||
|
||||
if exceptions.HasException(fmt.Sprintf(":%d:%s", data.Paragraph, gerror.RuleId)) {
|
||||
continue
|
||||
}
|
||||
|
||||
errs = append(errs, GrammarError{
|
||||
Prefix: name,
|
||||
Source: data.Text,
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ func searchBinaryInGit(edir string) (ret []string) {
|
|||
return
|
||||
}
|
||||
|
||||
func checkExercice(theme *fic.Theme, edir string, dmap *map[int64]*fic.Exercice) (errs []error) {
|
||||
e, _, eid, _, berrs := sync.BuildExercice(sync.GlobalImporter, theme, path.Join(theme.Path, edir), dmap)
|
||||
func checkExercice(theme *fic.Theme, edir string, dmap *map[int64]*fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
e, _, eid, _, berrs := sync.BuildExercice(sync.GlobalImporter, theme, path.Join(theme.Path, edir), dmap, exceptions)
|
||||
errs = append(errs, berrs...)
|
||||
|
||||
if e != nil {
|
||||
|
|
@ -117,7 +117,7 @@ func checkExercice(theme *fic.Theme, edir string, dmap *map[int64]*fic.Exercice)
|
|||
var files []string
|
||||
var cerrs []error
|
||||
if !skipFileChecks {
|
||||
files, cerrs = sync.CheckExerciceFiles(sync.GlobalImporter, e)
|
||||
files, cerrs = sync.CheckExerciceFiles(sync.GlobalImporter, e, exceptions)
|
||||
log.Printf("%d files checked.\n", len(files))
|
||||
} else {
|
||||
files, cerrs = sync.CheckExerciceFilesPresence(sync.GlobalImporter, e)
|
||||
|
|
@ -126,12 +126,12 @@ func checkExercice(theme *fic.Theme, edir string, dmap *map[int64]*fic.Exercice)
|
|||
errs = append(errs, cerrs...)
|
||||
|
||||
// Flags
|
||||
flags, cerrs := sync.CheckExerciceFlags(sync.GlobalImporter, e, files)
|
||||
flags, cerrs := sync.CheckExerciceFlags(sync.GlobalImporter, e, files, exceptions)
|
||||
errs = append(errs, cerrs...)
|
||||
log.Printf("%d flags checked.\n", len(flags))
|
||||
|
||||
// Hints
|
||||
hints, cerrs := sync.CheckExerciceHints(sync.GlobalImporter, e)
|
||||
hints, cerrs := sync.CheckExerciceHints(sync.GlobalImporter, e, exceptions)
|
||||
errs = append(errs, cerrs...)
|
||||
log.Printf("%d hints checked.\n", len(hints))
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ func main() {
|
|||
}
|
||||
|
||||
nberr := 0
|
||||
theme, errs := sync.BuildTheme(sync.GlobalImporter, p)
|
||||
theme, exceptions, errs := sync.BuildTheme(sync.GlobalImporter, p)
|
||||
|
||||
if theme != nil {
|
||||
nberr += len(errs)
|
||||
|
|
@ -260,7 +260,7 @@ func main() {
|
|||
dmap := map[int64]*fic.Exercice{}
|
||||
|
||||
for _, edir := range exercices {
|
||||
for _, err := range checkExercice(theme, edir, &dmap) {
|
||||
for _, err := range checkExercice(theme, edir, &dmap, exceptions) {
|
||||
log.Println(err.Error())
|
||||
|
||||
if logMissingResolution {
|
||||
|
|
@ -290,7 +290,7 @@ func main() {
|
|||
} else {
|
||||
log.Printf("This is not a theme directory, run checks for exercice.\n\n")
|
||||
|
||||
for _, err := range checkExercice(&fic.Theme{}, p, &map[int64]*fic.Exercice{}) {
|
||||
for _, err := range checkExercice(&fic.Theme{}, p, &map[int64]*fic.Exercice{}, exceptions) {
|
||||
nberr += 1
|
||||
log.Println(err)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue