Add golangci-lint

This commit is contained in:
Peter 2021-12-22 20:27:43 +01:00
parent 3f847e0b8b
commit 33dadaff87
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
9 changed files with 176 additions and 43 deletions

View file

@ -47,6 +47,7 @@ type RevealRenderer struct {
hasNotes bool
}
//nolint:gocyclo // under construction
func (r *RevealRenderer) RenderHook(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool) {
switch b := node.(type) {
case *ast.Document:
@ -82,7 +83,7 @@ func (r *RevealRenderer) RenderHook(w io.Writer, node ast.Node, entering bool) (
return ast.GoToNext, false
case *ast.HorizontalRule:
next := peekNextRuler(b)
var input = string(b.Literal)
input := string(b.Literal)
if next != nil {
input += string(next.Literal)
}
@ -185,6 +186,7 @@ func getAttributesFromChildSpan(node ast.Node) []template.HTMLAttr {
}
func extractElementAttributes(htmlSpan *ast.HTMLSpan) (attrs []template.HTMLAttr) {
const expectedNumberOfMatches = 4
htmlComment := string(htmlSpan.Literal)
if htmlComment == "" {
return nil
@ -192,7 +194,7 @@ func extractElementAttributes(htmlSpan *ast.HTMLSpan) (attrs []template.HTMLAttr
matches := htmlElementAttributesRegexp.FindAllStringSubmatch(htmlComment, -1)
attrs = make([]template.HTMLAttr, 0, len(matches))
for idx := range matches {
if len(matches[idx]) != 4 {
if len(matches[idx]) != expectedNumberOfMatches {
continue
}

View file

@ -18,34 +18,32 @@ const (
StateTypeNested
)
var (
EventMapping = map[EventType][]byte{
EventTypeHorizontalSplit: []byte(`
var EventMapping = map[EventType][]byte{
EventTypeHorizontalSplit: []byte(`
</section>
<section>`),
EventTypeVerticalSplit: []byte(`
EventTypeVerticalSplit: []byte(`
</section>
<section>
<section>
`),
EventTypeHorizontalEnd: []byte(`
EventTypeHorizontalEnd: []byte(`
</section>
`),
EventTypeVerticalSplitEnd: []byte(`
EventTypeVerticalSplitEnd: []byte(`
</section>
</section>
<section>`),
EventTypeVerticalDocumentEnd: []byte(`
EventTypeVerticalDocumentEnd: []byte(`
</section>
</section>
`),
EventTypeVerticalVerticalSplit: []byte(`
EventTypeVerticalVerticalSplit: []byte(`
</section>
</section>
<section>
<section>`),
}
)
}
func NewStateMachine(verticalSplit, horizontalSplit string) *StateMachine {
return &StateMachine{