Add some comments

Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
Cosmin Cojocar 2020-06-25 17:03:25 +02:00 committed by Cosmin Cojocar
parent d1467ac998
commit 4d4e5949c6
2 changed files with 2 additions and 0 deletions

View file

@ -131,6 +131,7 @@ func (c Score) String() string {
return "UNDEFINED"
}
// codeSnippet extracts a code snippet based on the ast reference
func codeSnippet(file *os.File, start int64, end int64, n ast.Node) (string, error) {
if n == nil {
return "", fmt.Errorf("invalid AST node provided")

View file

@ -322,6 +322,7 @@ func highlight(t string, s gosec.Score) string {
}
}
// printCodeSnippet prints the code snippet from the issue by adding a marker to the affected line
func printCodeSnippet(issue *gosec.Issue) string {
scanner := bufio.NewScanner(strings.NewReader(issue.Code))
var buf bytes.Buffer