repochecker/epita: Fix nil pointer exception
This commit is contained in:
parent
d791e74a2a
commit
2b26b2b819
2 changed files with 4 additions and 4 deletions
|
@ -72,8 +72,8 @@ func AnalyzeNumberFlag(t string) (min, max, step *float64, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
step = new(float64)
|
||||||
if len(fields[3]) > 0 {
|
if len(fields[3]) > 0 {
|
||||||
step = new(float64)
|
|
||||||
*step, err = strconv.ParseFloat(fields[3], 64)
|
*step, err = strconv.ParseFloat(fields[3], 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"srs.epita.fr/fic-server/libfic"
|
"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') ||
|
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') {
|
(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]))
|
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 {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
} else if min == nil || max == nil || step == nil {
|
} 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 {
|
} else if (*max-*min)**step <= 10 {
|
||||||
errs = append(errs, fmt.Errorf("to avoid bruteforce, define more than 10 possibilities"))
|
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
|
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 {
|
if len(choices) < 10 && flag.ChoicesCost == 0 {
|
||||||
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
||||||
} else if len(choices) < 6 && flag.ChoicesCost > 0 {
|
} else if len(choices) < 6 && flag.ChoicesCost > 0 {
|
||||||
|
|
Reference in a new issue