Skip to content

Commit 9d09967

Browse files
committed
autogenerated_exclude: increase scanner buffer
Some lines can be very long, so increase scanner buffer to mitigate this. Fix golangci#954
1 parent fd621bd commit 9d09967

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/result/processors/autogenerated_exclude.go

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ func getDoc(filePath string) (string, error) {
120120
defer file.Close()
121121

122122
scanner := bufio.NewScanner(file)
123+
124+
// Issue 954: Some lines can be very long, e.g. auto-generated
125+
// embedded resources. Reported on file of 86.2KB.
126+
const maxTokenSize = 512 * 1024 // 512KB should be enough
127+
scanner.Buffer(make([]byte, maxTokenSize), maxTokenSize)
128+
123129
var docLines []string
124130
for scanner.Scan() {
125131
line := strings.TrimSpace(scanner.Text())

0 commit comments

Comments
 (0)