repochecker/grammalecte: Extract struct in a dedicated lib
This commit is contained in:
parent
23ac512ce6
commit
acdf0a6261
3 changed files with 7 additions and 5 deletions
|
|
@ -6,12 +6,13 @@ import (
|
||||||
|
|
||||||
"srs.epita.fr/fic-server/admin/sync"
|
"srs.epita.fr/fic-server/admin/sync"
|
||||||
"srs.epita.fr/fic-server/libfic"
|
"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) {
|
func GrammalecteCheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.CheckExceptions) (errs []error) {
|
||||||
label, _, _, _ := flag.AnalyzeFlagLabel()
|
label, _, _, _ := flag.AnalyzeFlagLabel()
|
||||||
for _, err := range grammalecte("label ", label, exceptions, &CommonOpts) {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +57,7 @@ func GrammalecteCheckMDText(str string, exceptions *sync.CheckExceptions) (errs
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GrammalecteCheckGrammar(data interface{}, exceptions *sync.CheckExceptions) (errs []error) {
|
func GrammalecteCheckGrammar(data interface{}, exceptions *sync.CheckExceptions) []error {
|
||||||
if s, ok := data.(string); ok {
|
if s, ok := data.(string); ok {
|
||||||
return grammalecte("", s, exceptions, &CommonOpts)
|
return grammalecte("", s, exceptions, &CommonOpts)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"srs.epita.fr/fic-server/admin/sync"
|
"srs.epita.fr/fic-server/admin/sync"
|
||||||
|
lib "srs.epita.fr/fic-server/repochecker/grammalecte/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GrammalecteOptions struct {
|
type GrammalecteOptions struct {
|
||||||
|
|
@ -169,7 +170,7 @@ func grammalecte(name string, text string, exceptions *sync.CheckExceptions, opt
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestions, _ := suggest(serror.Value)
|
suggestions, _ := suggest(serror.Value)
|
||||||
errs = append(errs, SpellingError{
|
errs = append(errs, lib.SpellingError{
|
||||||
Prefix: name,
|
Prefix: name,
|
||||||
Source: data.Text,
|
Source: data.Text,
|
||||||
NSource: data.Paragraph,
|
NSource: data.Paragraph,
|
||||||
|
|
@ -190,7 +191,7 @@ func grammalecte(name string, text string, exceptions *sync.CheckExceptions, opt
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
errs = append(errs, GrammarError{
|
errs = append(errs, lib.GrammarError{
|
||||||
Prefix: name,
|
Prefix: name,
|
||||||
Source: data.Text,
|
Source: data.Text,
|
||||||
NSource: data.Paragraph,
|
NSource: data.Paragraph,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package main
|
package grammalecte
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
Reference in a new issue