repochecker/grammalecte: Extract struct in a dedicated lib

This commit is contained in:
nemunaire 2022-10-31 17:00:09 +01:00
parent 23ac512ce6
commit acdf0a6261
3 changed files with 7 additions and 5 deletions

View File

@ -6,12 +6,13 @@ import (
"srs.epita.fr/fic-server/admin/sync"
"srs.epita.fr/fic-server/libfic"
lib "srs.epita.fr/fic-server/repochecker/grammalecte/lib"
)
func GrammalecteCheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.CheckExceptions) (errs []error) {
label, _, _, _ := flag.AnalyzeFlagLabel()
for _, err := range grammalecte("label ", label, exceptions, &CommonOpts) {
if e, ok := err.(GrammarError); ok && e.RuleId == "poncfin_règle1" {
if e, ok := err.(lib.GrammarError); ok && e.RuleId == "poncfin_règle1" {
continue
}
@ -56,7 +57,7 @@ func GrammalecteCheckMDText(str string, exceptions *sync.CheckExceptions) (errs
return
}
func GrammalecteCheckGrammar(data interface{}, exceptions *sync.CheckExceptions) (errs []error) {
func GrammalecteCheckGrammar(data interface{}, exceptions *sync.CheckExceptions) []error {
if s, ok := data.(string); ok {
return grammalecte("", s, exceptions, &CommonOpts)
} else {

View File

@ -10,6 +10,7 @@ import (
"strings"
"srs.epita.fr/fic-server/admin/sync"
lib "srs.epita.fr/fic-server/repochecker/grammalecte/lib"
)
type GrammalecteOptions struct {
@ -169,7 +170,7 @@ func grammalecte(name string, text string, exceptions *sync.CheckExceptions, opt
}
suggestions, _ := suggest(serror.Value)
errs = append(errs, SpellingError{
errs = append(errs, lib.SpellingError{
Prefix: name,
Source: data.Text,
NSource: data.Paragraph,
@ -190,7 +191,7 @@ func grammalecte(name string, text string, exceptions *sync.CheckExceptions, opt
continue
}
errs = append(errs, GrammarError{
errs = append(errs, lib.GrammarError{
Prefix: name,
Source: data.Text,
NSource: data.Paragraph,

View File

@ -1,4 +1,4 @@
package main
package grammalecte
import (
"bytes"