Skip to content

Commit

Permalink
use a bytes.NewReader instead
Browse files Browse the repository at this point in the history
  • Loading branch information
simar7 committed May 2, 2024
1 parent 349eeb7 commit 3483943
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/iac/scan/code.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package scan

import (
"bufio"
"bytes"
"fmt"
"io/fs"
"path/filepath"
Expand Down Expand Up @@ -149,7 +151,14 @@ func (r *Result) GetCode(opts ...CodeOption) (*Code, error) {
Lines: nil,
}

rawLines := strings.Split(string(content), "\n")
var rawLines []string
bs := bufio.NewScanner(bytes.NewReader(content))
for bs.Scan() {
rawLines = append(rawLines, bs.Text())
}
if bs.Err() != nil {
return nil, fmt.Errorf("failed to scan file : %w", err)
}

var highlightedLines []string
if settings.includeHighlighted {
Expand Down

0 comments on commit 3483943

Please sign in to comment.