From 6251205cf1349c9e7929eb3584c1b1f8b881748d Mon Sep 17 00:00:00 2001 From: Christoph Herb <52382992+chrishrb@users.noreply.github.com> Date: Fri, 11 Oct 2024 00:06:20 +0200 Subject: [PATCH] fix linting issues --- pkg/parser.go | 80 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/pkg/parser.go b/pkg/parser.go index f05fa38..435a03b 100644 --- a/pkg/parser.go +++ b/pkg/parser.go @@ -91,11 +91,15 @@ func renderHookBlockquote(w io.Writer, node ast.Node, entering bool) (ast.WalkSt } // Set the message type based on the content of the blockquote + var err error if entering { s, _ := createBlockquoteStart(alert) - io.WriteString(w, s) + _, err = io.WriteString(w, s) } else { - io.WriteString(w, "") + _, err = io.WriteString(w, "") + } + if err != nil { + log.Println("Error:", err) } return ast.GoToNext, true @@ -111,32 +115,40 @@ func renderHookText(w io.Writer, node ast.Node) (ast.WalkStatus, bool) { _, ok = paragraph.GetParent().(*ast.BlockQuote) if ok { - // Remove prefixes - for _, b := range blockquotes { - content, found := strings.CutPrefix(string(block.Literal), fmt.Sprintf("[!%s]", strings.ToUpper(b))) - if found { - io.WriteString(w, content) - return ast.GoToNext, true - } - } - } + // Remove prefixes + for _, b := range blockquotes { + content, found := strings.CutPrefix(string(block.Literal), fmt.Sprintf("[!%s]", strings.ToUpper(b))) + if found { + _, err := io.WriteString(w, content) + if err != nil { + log.Println("Error:", err) + } + return ast.GoToNext, true + } + } + } _, ok = paragraph.GetParent().(*ast.ListItem) if ok { - content, found := strings.CutPrefix(string(block.Literal), "[ ]") - content = ` ` + content - if found { - io.WriteString(w, content) - return ast.GoToNext, true - } + content, found := strings.CutPrefix(string(block.Literal), "[ ]") + content = ` ` + content + if found { + _, err := io.WriteString(w, content) + if err != nil { + log.Println("Error:", err) + } + return ast.GoToNext, true + } - content, found = strings.CutPrefix(string(block.Literal), "[x]") - content = ` ` + content - if found { - io.WriteString(w, content) - return ast.GoToNext, true - } - } + content, found = strings.CutPrefix(string(block.Literal), "[x]") + content = ` ` + content + if found { + _, err := io.WriteString(w, content) + if err != nil { + log.Println("Error:", err) + } + } + } return ast.GoToNext, false } @@ -154,15 +166,21 @@ func renderHookListItem(w io.Writer, node ast.Node, entering bool) (ast.WalkStat return ast.GoToNext, false } - if !(strings.HasPrefix(string(t.Literal), "[ ]") || strings.HasPrefix(string(t.Literal), "[x]")) { + if !(strings.HasPrefix(string(t.Literal), "[ ]") || strings.HasPrefix(string(t.Literal), "[x]")) { return ast.GoToNext, false - } + } - if entering { - io.WriteString(w, "