From 4d4e5949c6d7f265e9779162964420caa1abb70f Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Thu, 25 Jun 2020 17:03:25 +0200 Subject: [PATCH] Add some comments Signed-off-by: Cosmin Cojocar --- issue.go | 1 + output/formatter.go | 1 + 2 files changed, 2 insertions(+) diff --git a/issue.go b/issue.go index 1668baa5fb..aa58c3434b 100644 --- a/issue.go +++ b/issue.go @@ -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") diff --git a/output/formatter.go b/output/formatter.go index 7d7f18f65c..2159a0e98d 100644 --- a/output/formatter.go +++ b/output/formatter.go @@ -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