repochecker/epita: Fix nil pointer exception

This commit is contained in:
nemunaire 2022-10-29 00:35:11 +02:00
parent d791e74a2a
commit 2b26b2b819
2 changed files with 4 additions and 4 deletions

View file

@ -72,8 +72,8 @@ func AnalyzeNumberFlag(t string) (min, max, step *float64, err error) {
}
}
step = new(float64)
if len(fields[3]) > 0 {
step = new(float64)
*step, err = strconv.ParseFloat(fields[3], 64)
if err != nil {
return

View file

@ -8,7 +8,7 @@ import (
"srs.epita.fr/fic-server/libfic"
)
func EPITACheckKeyFlag(flag *fic.FlagKey, raw string) (errs []error) {
func EPITACheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.CheckExceptions) (errs []error) {
if (flag.Label[0] == 'Q' || flag.Label[0] == 'q') && (flag.Label[1] == 'U' || flag.Label[1] == 'u') ||
(flag.Label[0] == 'W' || flag.Label[0] == 'w') && (flag.Label[1] == 'H' || flag.Label[1] == 'h') {
errs = append(errs, fmt.Errorf("Label should not begin with %s. This seem to be a question. Reword your label as a description of the expected flag, `:` are automatically appended.", flag.Label[0:2]))
@ -32,7 +32,7 @@ func EPITACheckKeyFlag(flag *fic.FlagKey, raw string) (errs []error) {
if err != nil {
errs = append(errs, err)
} else if min == nil || max == nil || step == nil {
errs = append(errs, fmt.Errorf("please define min, max and step for your number flag"))
errs = append(errs, fmt.Errorf("please define min and max for your number flag"))
} else if (*max-*min)**step <= 10 {
errs = append(errs, fmt.Errorf("to avoid bruteforce, define more than 10 possibilities"))
}
@ -41,7 +41,7 @@ func EPITACheckKeyFlag(flag *fic.FlagKey, raw string) (errs []error) {
return
}
func EPITACheckKeyFlagWithChoices(flag *fic.FlagKey, raw string, choices []*fic.FlagChoice) (errs []error) {
func EPITACheckKeyFlagWithChoices(flag *fic.FlagKey, raw string, choices []*fic.FlagChoice, exceptions *sync.CheckExceptions) (errs []error) {
if len(choices) < 10 && flag.ChoicesCost == 0 {
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
} else if len(choices) < 6 && flag.ChoicesCost > 0 {