Skip to content

Commit 506f9db

Browse files
committed
update linter
1 parent 7a72b28 commit 506f9db

File tree

5 files changed

+45
-19
lines changed

5 files changed

+45
-19
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
tmp/
1+
tmp/
2+
failed/

.golangci.yml

+30-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
1-
21
run:
32
skip-dirs-use-default: false
43

54
linters:
6-
enable:
7-
- gofmt
5+
enable-all: true
6+
disable:
7+
- gochecknoinits
8+
- paralleltest
9+
- wrapcheck
10+
- gosec
11+
- gochecknoglobals
12+
- musttag
13+
- wsl
14+
- gocritic
15+
- varnamelen
16+
- forbidigo
17+
- lll
818
- revive
9-
- gocyclo
10-
- misspell
11-
- bodyclose
19+
- gomnd
20+
- nlreturn
21+
- exhaustruct
22+
- nilnil
23+
- nonamedreturns
24+
25+
# Deprecated ones:
26+
- structcheck
27+
- interfacer
28+
- deadcode
29+
- varcheck
30+
- ifshort
31+
- exhaustivestruct
32+
- golint
33+
- maligned
34+
- nosnakecase
35+
- scopelint
1236

1337
gocyclo:
1438
min-complexity: 15
1539

1640
issues:
1741
exclude-use-default: false
18-
19-
exclude-rules:
20-
- linters:
21-
- revive
22-
text: "package-comments: should have a package comment"

check_test.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ func TestCheckCode(t *testing.T) {
2727

2828
b, err := os.ReadFile(path)
2929
g.E(err)
30-
return checkGoCode(g, path, string(b))
30+
checkGoCode(g, path, string(b))
31+
32+
return nil
3133
}))
3234

3335
defer func() {
@@ -42,12 +44,13 @@ func TestCheckCode(t *testing.T) {
4244

4345
var count = 0
4446

45-
func checkGoCode(g got.G, path, body string) error {
47+
func checkGoCode(g got.G, path, body string) {
4648
reg := regexp.MustCompile("(?s)```go\r?\n(.+?)```")
4749

4850
for _, m := range reg.FindAllStringSubmatch(body, -1) {
4951
code := strings.TrimSpace(m[1])
5052
if strings.HasPrefix(code, "package ") {
53+
noop()
5154
} else if strings.Contains(code, "func ") {
5255
code = "package main\n" + vars(code) + code
5356
} else {
@@ -58,10 +61,9 @@ func checkGoCode(g got.G, path, body string) error {
5861

5962
code = "// Source markdown file: " + path + "\n\n" + code
6063

61-
g.WriteFile(p, []byte(code))
64+
g.E(os.MkdirAll(filepath.Dir(p), 0o755))
65+
g.E(os.WriteFile(p, []byte(code), 0o755))
6266
}
63-
64-
return nil
6567
}
6668

6769
func vars(code string) string {
@@ -72,5 +74,9 @@ func vars(code string) string {
7274
if strings.Contains(code, "browser.") && !strings.Contains(code, "browser :=") {
7375
vars += "var browser *rod.Browser\n"
7476
}
77+
7578
return vars
7679
}
80+
81+
func noop() {
82+
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ go 1.17
55
require (
66
github.com/go-rod/rod v0.112.9
77
github.com/ysmood/got v0.34.1
8+
github.com/ysmood/gson v0.7.3
89
)
910

1011
require (
1112
github.com/ysmood/fetchup v0.2.2 // indirect
1213
github.com/ysmood/goob v0.4.0 // indirect
1314
github.com/ysmood/gop v0.0.2 // indirect
14-
github.com/ysmood/gson v0.7.3 // indirect
1515
github.com/ysmood/leakless v0.8.0 // indirect
1616
)

input.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To simulate the mouse click an element:
1111
page.MustElement("button").MustClick()
1212

1313
// right click
14-
_ = page.MustElement("button").Click(proto.InputMouseButtonRight)
14+
_ = page.MustElement("button").Click(proto.InputMouseButtonRight, 1)
1515
```
1616

1717
## Text input

0 commit comments

Comments
 (0)