Skip to content

Commit 3055269

Browse files
Enable linting of Go source files repo-wide (#3389)
Fix import ordering, stray newline, variable naming and idiomatic Go issues in Go source files under `docs/`. This allows us to run golangci-lint on the entire repo.
1 parent c85b1d5 commit 3055269

6 files changed

Lines changed: 14 additions & 22 deletions

File tree

.github/workflows/golangci-lint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ jobs:
1919
uses: golangci/golangci-lint-action@v8
2020
with:
2121
version: v2.2
22-
args: src/... tools/...

docs/test/docs_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/thought-machine/please/src/core"
11-
1210
"github.com/stretchr/testify/assert"
1311
"github.com/stretchr/testify/require"
1412
"golang.org/x/net/html"
13+
14+
"github.com/thought-machine/please/src/core"
1515
)
1616

1717
func TestAllLinksAreLive(t *testing.T) {
@@ -54,7 +54,6 @@ func TestAllLinksAreLive(t *testing.T) {
5454
allnames[filename+"#"+attr.Val] = true
5555
}
5656
}
57-
5857
}
5958
}
6059
for c := n.FirstChild; c != nil; c = c.NextSibling {
@@ -89,7 +88,7 @@ var ignoreConfigFields = map[string]struct{}{
8988
}
9089

9190
// IDs in the html that are for other purposes other than documenting config.
92-
var nonConfigIds = map[string]struct{}{
91+
var nonConfigIDs = map[string]struct{}{
9392
"menu-list": {},
9493
"nav-graphic": {},
9594
"side-images": {},
@@ -124,7 +123,7 @@ func TestConfigDocumented(t *testing.T) {
124123
}
125124

126125
for id := range ids {
127-
if _, ok := nonConfigIds[id]; ok {
126+
if _, ok := nonConfigIDs[id]; ok {
128127
continue
129128
}
130129
if _, ok := configFields[id]; !ok {
@@ -156,7 +155,6 @@ func findConfigFields(path string, configType reflect.Type) []string {
156155
if t.Kind() == reflect.Struct {
157156
fields = append(fields, findConfigFields(name, t)...)
158157
}
159-
160158
}
161159
return fields
162160
}

docs/tools/lexicon_templater/template_lexicon.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import (
88
"strings"
99
"text/template"
1010

11-
"github.com/thought-machine/please/docs/tools/lexicon_templater/rules"
12-
1311
"github.com/peterebden/go-cli-init/v5/flags"
14-
)
15-
1612

13+
"github.com/thought-machine/please/docs/tools/lexicon_templater/rules"
14+
)
1715

1816
func must(err error) {
1917
if err != nil {

docs/tools/plugin_config_tool/plugin/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ type Plugin struct {
1010
}
1111

1212
type ConfigField struct {
13-
Name, Type, Help, DefaultValue string
13+
Name, Type, Help, DefaultValue string
1414
Inherit, Repeatable, Defaults, Optional bool
1515
}

docs/tools/plugin_config_tool/plugin_config_tool.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
"path/filepath"
1111
"strings"
1212

13+
"github.com/peterebden/go-cli-init/v5/flags"
14+
"github.com/please-build/gcfg"
15+
1316
"github.com/thought-machine/please/docs/tools/lexicon_templater/rules"
1417
"github.com/thought-machine/please/docs/tools/plugin_config_tool/plugin"
1518
"github.com/thought-machine/please/src/core"
16-
17-
"github.com/peterebden/go-cli-init/v5/flags"
18-
"github.com/please-build/gcfg"
1919
)
2020

2121
// formatConfigKey converts the config key from snake_case to CamelCase
@@ -61,7 +61,6 @@ func getConfigFields(config *core.Configuration) []*plugin.ConfigField {
6161
f.Type = "string"
6262
}
6363
fields = append(fields, f)
64-
6564
}
6665
return fields
6766
}

docs/tools/plugin_templater/main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package main
22

33
import (
44
"encoding/json"
5-
"github.com/thought-machine/please/docs/tools/lexicon_templater/rules"
65
htmltemplate "html/template"
76
"os"
87
"path/filepath"
98
"sort"
109
"strings"
1110
"text/template"
1211

13-
"github.com/thought-machine/please/docs/tools/plugin_config_tool/plugin"
14-
1512
"github.com/peterebden/go-cli-init/v5/flags"
13+
14+
"github.com/thought-machine/please/docs/tools/lexicon_templater/rules"
15+
"github.com/thought-machine/please/docs/tools/plugin_config_tool/plugin"
1616
)
1717

1818
func must(err error) {
@@ -40,9 +40,7 @@ func (p Plugins) Less(i, j int) bool {
4040
}
4141

4242
func (p Plugins) Swap(i, j int) {
43-
iVal := p[i]
44-
p[i] = p[j]
45-
p[j] = iVal
43+
p[i], p[j] = p[j], p[i]
4644
}
4745

4846
func main() {

0 commit comments

Comments
 (0)