Skip to content

Commit

Permalink
autogenerated_exclude: increase scanner buffer (#955)
Browse files Browse the repository at this point in the history
* autogenerated_exclude: increase scanner buffer

Some lines can be very long, so increase scanner
buffer to mitigate this.

Fix #954
  • Loading branch information
ernado authored Feb 3, 2020
1 parent 4d165fc commit 18ab7a0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/result/processors/autogenerated_exclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ func getDoc(filePath string) (string, error) {
defer file.Close()

scanner := bufio.NewScanner(file)

// Issue 954: Some lines can be very long, e.g. auto-generated
// embedded resources. Reported on file of 86.2KB.
const (
maxSize = 512 * 1024 // 512KB should be enough
initialSize = 4096 // same as startBufSize in bufio
)
scanner.Buffer(make([]byte, initialSize), maxSize)

var docLines []string
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
Expand Down

0 comments on commit 18ab7a0

Please sign in to comment.