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
|
@ -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,
|
||||
|
|
Reference in a new issue