Skip to content

Commit 47fdfd5

Browse files
moorereasonbep
authored andcommitted
Clean up lint in various packages
Changes fall into one of the following: - gofmt -s - receiver name is inconsistent - omit unused 2nd value from range - godoc comment formed incorrectly - err assigned and not used - if block ends with a return statement followed by else
1 parent d45e358 commit 47fdfd5

File tree

12 files changed

+44
-42
lines changed

12 files changed

+44
-42
lines changed

‎helpers/pygments_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,13 @@ func TestHlLinesToRanges(t *testing.T) {
224224
expected interface{}
225225
}{
226226
{"", 1, zero},
227-
{"1 4", 1, [][2]int{[2]int{1, 1}, [2]int{4, 4}}},
228-
{"1 4", 2, [][2]int{[2]int{2, 2}, [2]int{5, 5}}},
229-
{"1-4 5-8", 1, [][2]int{[2]int{1, 4}, [2]int{5, 8}}},
230-
{" 1 4 ", 1, [][2]int{[2]int{1, 1}, [2]int{4, 4}}},
231-
{"1-4 5-8 ", 1, [][2]int{[2]int{1, 4}, [2]int{5, 8}}},
232-
{"1-4 5", 1, [][2]int{[2]int{1, 4}, [2]int{5, 5}}},
233-
{"4 5-9", 1, [][2]int{[2]int{4, 4}, [2]int{5, 9}}},
227+
{"1 4", 1, [][2]int{{1, 1}, {4, 4}}},
228+
{"1 4", 2, [][2]int{{2, 2}, {5, 5}}},
229+
{"1-4 5-8", 1, [][2]int{{1, 4}, {5, 8}}},
230+
{" 1 4 ", 1, [][2]int{{1, 1}, {4, 4}}},
231+
{"1-4 5-8 ", 1, [][2]int{{1, 4}, {5, 8}}},
232+
{"1-4 5", 1, [][2]int{{1, 4}, {5, 5}}},
233+
{"4 5-9", 1, [][2]int{{4, 4}, {5, 9}}},
234234
{" 1 -4 5 - 8 ", 1, true},
235235
{"a b", 1, true},
236236
} {

‎hugolib/handler_meta.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type MetaHandler interface {
3434
Handle() Handler
3535
}
3636

37-
// HandledResults is a channel for HandledResult.
37+
// HandleResults is a channel for HandledResult.
3838
type HandleResults chan<- HandledResult
3939

4040
// NewMetaHandler creates a MetaHandle for a given extensions.

‎hugolib/page.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const (
6565
KindPage = "page"
6666

6767
// The rest are node types; home page, sections etc.
68+
6869
KindHome = "home"
6970
KindSection = "section"
7071
KindTaxonomy = "taxonomy"
@@ -484,10 +485,10 @@ func traverse(keys []string, m map[string]interface{}) interface{} {
484485
if len(rest) == 0 {
485486
// That was the last key.
486487
return result
487-
} else {
488-
// That was not the last key.
489-
return traverse(rest, cast.ToStringMap(result))
490488
}
489+
490+
// That was not the last key.
491+
return traverse(rest, cast.ToStringMap(result))
491492
}
492493

493494
func (p *Page) Author() Author {

‎hugolib/pages_related_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Content
6868
assert.Equal("Page 3", result[1].Title)
6969

7070
result, err = s.RegularPages.RelatedTo(types.NewKeyValuesStrings("keywords", "bep", "rocks"))
71+
assert.NoError(err)
7172
assert.Len(result, 2)
7273
assert.Equal("Page 2", result[0].Title)
7374
assert.Equal("Page 3", result[1].Title)
74-
7575
}

‎media/mediaType.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,15 @@ func DecodeTypes(maps ...map[string]interface{}) (Types, error) {
189189
return m, nil
190190
}
191191

192-
func (t Type) MarshalJSON() ([]byte, error) {
192+
func (m Type) MarshalJSON() ([]byte, error) {
193193
type Alias Type
194194
return json.Marshal(&struct {
195195
Type string `json:"type"`
196196
String string `json:"string"`
197197
Alias
198198
}{
199-
Type: t.Type(),
200-
String: t.String(),
201-
Alias: (Alias)(t),
199+
Type: m.Type(),
200+
String: m.String(),
201+
Alias: (Alias)(m),
202202
})
203203
}

‎output/outputFormat.go‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ func init() {
150150

151151
type Formats []Format
152152

153-
func (f Formats) Len() int { return len(f) }
154-
func (f Formats) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
155-
func (f Formats) Less(i, j int) bool { return f[i].Name < f[j].Name }
153+
func (formats Formats) Len() int { return len(formats) }
154+
func (formats Formats) Swap(i, j int) { formats[i], formats[j] = formats[j], formats[i] }
155+
func (formats Formats) Less(i, j int) bool { return formats[i].Name < formats[j].Name }
156156

157157
// GetBySuffix gets a output format given as suffix, e.g. "html".
158158
// It will return false if no format could be found, or if the suffix given
@@ -312,17 +312,17 @@ func decode(mediaTypes media.Types, input, output interface{}) error {
312312
return decoder.Decode(input)
313313
}
314314

315-
func (f Format) BaseFilename() string {
316-
return f.BaseName + "." + f.MediaType.Suffix
315+
func (formats Format) BaseFilename() string {
316+
return formats.BaseName + "." + formats.MediaType.Suffix
317317
}
318318

319-
func (f Format) MarshalJSON() ([]byte, error) {
319+
func (formats Format) MarshalJSON() ([]byte, error) {
320320
type Alias Format
321321
return json.Marshal(&struct {
322322
MediaType string
323323
Alias
324324
}{
325-
MediaType: f.MediaType.String(),
326-
Alias: (Alias)(f),
325+
MediaType: formats.MediaType.String(),
326+
Alias: (Alias)(formats),
327327
})
328328
}

‎related/inverted_index.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func DecodeConfig(in interface{}) (Config, error) {
418418
}
419419

420420
if c.ToLower {
421-
for i, _ := range c.Indices {
421+
for i := range c.Indices {
422422
c.Indices[i].ToLower = true
423423
}
424424
}

‎related/inverted_index_test.go‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ type testDoc struct {
2727
date time.Time
2828
}
2929

30-
func (k *testDoc) String() string {
30+
func (d *testDoc) String() string {
3131
s := "\n"
32-
for k, v := range k.keywords {
32+
for k, v := range d.keywords {
3333
s += k + ":\t\t"
3434
for _, vv := range v {
3535
s += " " + vv.String()
@@ -49,17 +49,17 @@ func newTestDoc(name string, keywords ...string) *testDoc {
4949
return kw
5050
}
5151

52-
func (t *testDoc) addKeywords(name string, keywords ...string) *testDoc {
52+
func (d *testDoc) addKeywords(name string, keywords ...string) *testDoc {
5353
keywordm := createTestKeywords(name, keywords...)
5454

5555
for k, v := range keywordm {
5656
keywords := make([]Keyword, len(v))
5757
for i := 0; i < len(v); i++ {
5858
keywords[i] = StringKeyword(v[i])
5959
}
60-
t.keywords[k] = keywords
60+
d.keywords[k] = keywords
6161
}
62-
return t
62+
return d
6363
}
6464

6565
func createTestKeywords(name string, keywords ...string) map[string][]string {
@@ -68,12 +68,12 @@ func createTestKeywords(name string, keywords ...string) map[string][]string {
6868
}
6969
}
7070

71-
func (k *testDoc) SearchKeywords(cfg IndexConfig) ([]Keyword, error) {
72-
return k.keywords[cfg.Name], nil
71+
func (d *testDoc) SearchKeywords(cfg IndexConfig) ([]Keyword, error) {
72+
return d.keywords[cfg.Name], nil
7373
}
7474

75-
func (k *testDoc) PubDate() time.Time {
76-
return k.date
75+
func (d *testDoc) PubDate() time.Time {
76+
return d.date
7777
}
7878

7979
func TestSearch(t *testing.T) {

‎source/filesystem.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ func (f *Filesystem) avoid(filePath string) bool {
158158
return false
159159
}
160160

161-
func (s SourceSpec) isNonProcessablePath(filePath string) bool {
161+
func (sp SourceSpec) isNonProcessablePath(filePath string) bool {
162162
base := filepath.Base(filePath)
163163
if strings.HasPrefix(base, ".") ||
164164
strings.HasPrefix(base, "#") ||
165165
strings.HasSuffix(base, "~") {
166166
return true
167167
}
168-
ignoreFiles := cast.ToStringSlice(s.Cfg.Get("ignoreFiles"))
168+
ignoreFiles := cast.ToStringSlice(sp.Cfg.Get("ignoreFiles"))
169169
if len(ignoreFiles) > 0 {
170170
for _, ignorePattern := range ignoreFiles {
171171
match, err := regexp.MatchString(ignorePattern, filePath)

‎tpl/collections/collections.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,25 +503,25 @@ func (i *intersector) appendIfNotSeen(v reflect.Value) {
503503
}
504504
}
505505

506-
func (ins *intersector) handleValuePair(l1vv, l2vv reflect.Value) {
506+
func (i *intersector) handleValuePair(l1vv, l2vv reflect.Value) {
507507
switch kind := l1vv.Kind(); {
508508
case kind == reflect.String:
509509
l2t, err := toString(l2vv)
510510
if err == nil && l1vv.String() == l2t {
511-
ins.appendIfNotSeen(l1vv)
511+
i.appendIfNotSeen(l1vv)
512512
}
513513
case isNumber(kind):
514514
f1, err1 := numberToFloat(l1vv)
515515
f2, err2 := numberToFloat(l2vv)
516516
if err1 == nil && err2 == nil && f1 == f2 {
517-
ins.appendIfNotSeen(l1vv)
517+
i.appendIfNotSeen(l1vv)
518518
}
519519
case kind == reflect.Ptr, kind == reflect.Struct:
520520
if l1vv.Interface() == l2vv.Interface() {
521-
ins.appendIfNotSeen(l1vv)
521+
i.appendIfNotSeen(l1vv)
522522
}
523523
case kind == reflect.Interface:
524-
ins.handleValuePair(reflect.ValueOf(l1vv.Interface()), l2vv)
524+
i.handleValuePair(reflect.ValueOf(l1vv.Interface()), l2vv)
525525
}
526526
}
527527

0 commit comments

Comments
 (0)