carlos / todomvc-bakeoff Public

Clone
git clone https://amadan.net/carlos/todomvc-bakeoff

Plain git — no account needed to clone.

Download

Download this file

1package bakeoff
2
3import (
4 "regexp"
5 "strings"
6)
7
8var findingStart = regexp.MustCompile(`^\s*\d+\.\s+`)
9
10// ParseFindings splits a reviewer's numbered list into one string per item,
11// joining wrapped lines. "No findings." yields none.
12func ParseFindings(text string) []string {
13 var out []string
14 for _, line := range strings.Split(text, "\n") {
15 line = strings.TrimSpace(line)
16 switch {
17 case findingStart.MatchString(line):
18 out = append(out, findingStart.ReplaceAllString(line, ""))
19 case line != "" && len(out) > 0:
20 out[len(out)-1] += " " + line
21 }
22 }
23 return out
24}
25
26// HasSecurity reports whether any finding is tagged [security].
27func HasSecurity(findings []string) bool {
28 for _, f := range findings {
29 if strings.HasPrefix(f, "[security]") {
30 return true
31 }
32 }
33 return false
34}
35