add parseErrorDetails for parsing of errors and code lines

Signed-off-by: Danilo Patrucco <danilo.patrucco@gmail.com>
pull/13205/head
Danilo Patrucco 1 year ago
parent d489d78531
commit 5cc306154d

@ -0,0 +1,26 @@
package rules
import (
"bufio"
"os"
"strings"
)
func ParseIgnoreFile(filePath string) ([]string, error) {
var patterns []string
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line != "" && !strings.HasPrefix(line, "#") {
patterns = append(patterns, line)
}
}
return patterns, scanner.Err()
}

@ -0,0 +1,18 @@
package rules
import (
"regexp"
"strconv"
)
func parseErrorDetails(err string) (string, int, int) {
re := regexp.MustCompile(`([^:]+):(\d+):(\d+): executing`)
matches := re.FindStringSubmatch(err)
if len(matches) < 4 {
return "", 0, 0 // Return default values if the format does not match
}
line, _ := strconv.Atoi(matches[2])
col, _ := strconv.Atoi(matches[3])
return matches[1], line, col
}
Loading…
Cancel
Save