Fix golint issues

This commit is contained in:
Cameron Moore 2019-11-29 13:31:28 -06:00
parent 2932dadfb3
commit 3dc5ebdb17
7 changed files with 19 additions and 12 deletions

View file

@ -2,11 +2,13 @@ package fuzz
import ( import (
"bytes" "bytes"
"github.com/yuin/goldmark" "github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension" "github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/renderer/html" "github.com/yuin/goldmark/renderer/html"
) )
// Fuzz runs automated fuzzing against goldmark.
func Fuzz(data []byte) int { func Fuzz(data []byte) int {
markdown := goldmark.New( markdown := goldmark.New(
goldmark.WithRendererOptions( goldmark.WithRendererOptions(

View file

@ -2,11 +2,12 @@ package parser
import ( import (
"bytes" "bytes"
"regexp"
"strings"
"github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/text" "github.com/yuin/goldmark/text"
"github.com/yuin/goldmark/util" "github.com/yuin/goldmark/util"
"regexp"
"strings"
) )
var allowedBlockTags = map[string]bool{ var allowedBlockTags = map[string]bool{
@ -97,12 +98,12 @@ var htmlBlockType7Regexp = regexp.MustCompile(`^[ ]{0,3}<(/)?([a-zA-Z0-9]+)(` +
type htmlBlockParser struct { type htmlBlockParser struct {
} }
var defaultHtmlBlockParser = &htmlBlockParser{} var defaultHTMLBlockParser = &htmlBlockParser{}
// NewHTMLBlockParser return a new BlockParser that can parse html // NewHTMLBlockParser return a new BlockParser that can parse html
// blocks. // blocks.
func NewHTMLBlockParser() BlockParser { func NewHTMLBlockParser() BlockParser {
return defaultHtmlBlockParser return defaultHTMLBlockParser
} }
func (b *htmlBlockParser) Trigger() []byte { func (b *htmlBlockParser) Trigger() []byte {

View file

@ -11,7 +11,7 @@ type thematicBreakPraser struct {
var defaultThematicBreakPraser = &thematicBreakPraser{} var defaultThematicBreakPraser = &thematicBreakPraser{}
// NewThematicBreakPraser returns a new BlockParser that // NewThematicBreakParser returns a new BlockParser that
// parses thematic breaks. // parses thematic breaks.
func NewThematicBreakParser() BlockParser { func NewThematicBreakParser() BlockParser {
return defaultThematicBreakPraser return defaultThematicBreakPraser

View file

@ -4,11 +4,10 @@ package renderer
import ( import (
"bufio" "bufio"
"io" "io"
"sync"
"github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/util" "github.com/yuin/goldmark/util"
"sync"
) )
// A Config struct is a data structure that holds configuration of the Renderer. // A Config struct is a data structure that holds configuration of the Renderer.

View file

@ -21,6 +21,7 @@ type TestingT interface {
FailNow() FailNow()
} }
// MarkdownTestCase represents a test case.
type MarkdownTestCase struct { type MarkdownTestCase struct {
No int No int
Markdown string Markdown string
@ -30,6 +31,7 @@ type MarkdownTestCase struct {
const attributeSeparator = "//- - - - - - - - -//" const attributeSeparator = "//- - - - - - - - -//"
const caseSeparator = "//= = = = = = = = = = = = = = = = = = = = = = = =//" const caseSeparator = "//= = = = = = = = = = = = = = = = = = = = = = = =//"
// DoTestCaseFile runs test cases in a given file.
func DoTestCaseFile(m goldmark.Markdown, filename string, t TestingT) { func DoTestCaseFile(m goldmark.Markdown, filename string, t TestingT) {
fp, err := os.Open(filename) fp, err := os.Open(filename)
if err != nil { if err != nil {
@ -86,12 +88,14 @@ func DoTestCaseFile(m goldmark.Markdown, filename string, t TestingT) {
DoTestCases(m, cases, t) DoTestCases(m, cases, t)
} }
// DoTestCases runs a set of test cases.
func DoTestCases(m goldmark.Markdown, cases []MarkdownTestCase, t TestingT) { func DoTestCases(m goldmark.Markdown, cases []MarkdownTestCase, t TestingT) {
for _, testCase := range cases { for _, testCase := range cases {
DoTestCase(m, testCase, t) DoTestCase(m, testCase, t)
} }
} }
// DoTestCase runs a test case.
func DoTestCase(m goldmark.Markdown, testCase MarkdownTestCase, t TestingT) { func DoTestCase(m goldmark.Markdown, testCase MarkdownTestCase, t TestingT) {
var ok bool var ok bool
var out bytes.Buffer var out bytes.Buffer

View file

@ -1,10 +1,11 @@
package text package text
import ( import (
"github.com/yuin/goldmark/util"
"io" "io"
"regexp" "regexp"
"unicode/utf8" "unicode/utf8"
"github.com/yuin/goldmark/util"
) )
const invalidValue = -1 const invalidValue = -1
@ -138,7 +139,7 @@ func (r *reader) LineOffset() int {
if r.source[i] == '\t' { if r.source[i] == '\t' {
v += util.TabWidth(v) v += util.TabWidth(v)
} else { } else {
v += 1 v++
} }
} }
r.lineOffset = v - r.pos.Padding r.lineOffset = v - r.pos.Padding
@ -355,7 +356,7 @@ func (r *blockReader) LineOffset() int {
if r.source[i] == '\t' { if r.source[i] == '\t' {
v += util.TabWidth(v) v += util.TabWidth(v)
} else { } else {
v += 1 v++
} }
} }
r.lineOffset = v - r.pos.Padding r.lineOffset = v - r.pos.Padding

View file

@ -631,7 +631,7 @@ func URLEscape(v []byte, resolveReference bool) []byte {
cob.Write(v[n:i]) cob.Write(v[n:i])
stop := i + int(u8len) stop := i + int(u8len)
if stop > len(v) { if stop > len(v) {
i += 1 i++
n = i n = i
continue continue
} }