MCPcopy Create free account
hub / github.com/byterocket/c4udit / analyzeFile

Function analyzeFile

analyzer/analyzer.go:74–103  ·  view source on GitHub ↗
(issues []Issue, file string)

Source from the content-addressed store, hash-verified

72}
73
74func analyzeFile(issues []Issue, file string) (map[string][]Finding, error) {
75 findings := make(map[string][]Finding)
76
77 readFile, err := os.Open(file)
78 if err != nil {
79 return nil, err
80 }
81 defer readFile.Close()
82
83 scanner := bufio.NewScanner(readFile)
84 lineNumber := 0
85 for scanner.Scan() {
86 lineNumber++
87 line := scanner.Text()
88
89 for _, issue := range issues {
90 matched, _ := regexp.MatchString(issue.Pattern, line)
91 if matched {
92 findings[issue.Identifier] = append(findings[issue.Identifier], Finding{
93 IssueIdentifier: issue.Identifier,
94 File: file,
95 LineNumber: lineNumber,
96 LineContent: strings.TrimSpace(line),
97 })
98 }
99 }
100 }
101
102 return findings, nil
103}

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected