Skip to content

Commit 3af8341

Browse files
Upgrade golangci-lint (#711)
* Upgrade golangci-lint * Freeze version of golangci-lint * Update changelog
1 parent f961af8 commit 3af8341

File tree

28 files changed

+186
-173
lines changed

28 files changed

+186
-173
lines changed

.github/workflows/linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
uses: wabarc/.github/.github/workflows/reusable-golangci.yml@main
3838
with:
3939
egress-policy: audit
40+
version: 'v2.5.0'
4041

4142
shellcheck:
4243
name: ShellCheck

.golangci.yml

Lines changed: 88 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,110 @@
22
# Use of this source code is governed by the GNU GPL v3
33
# license that can be found in the LICENSE file.
44
#
5-
---
6-
#########################
7-
#########################
8-
## Golang Linter rules ##
9-
#########################
10-
#########################
11-
12-
# configure golangci-lint
13-
# see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
5+
version: "2"
146
run:
15-
# default concurrency is a available CPU number.
16-
# concurrency: 4 # explicitly omit this value to fully utilize available resources.
17-
deadline: 5m
187
issues-exit-code: 1
198
tests: false
20-
21-
issues:
22-
exclude-rules:
23-
- path: _test\.go
24-
linters:
25-
- dupl
26-
- gosec
27-
- goconst
289
linters:
29-
disable-all: true
10+
default: none
3011
enable:
3112
- bodyclose
3213
- errcheck
3314
- goconst
34-
- gocyclo
3515
- gocritic
36-
- gofmt
37-
- goimports
16+
- gocyclo
3817
- gosec
39-
- gosimple
4018
- govet
4119
- ineffassign
4220
- misspell
4321
- prealloc
4422
- staticcheck
45-
- stylecheck
46-
- typecheck
4723
- unconvert
4824
- unparam
4925
- unused
5026
- whitespace
51-
linters-settings:
52-
errcheck:
53-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
54-
# default is false: such cases aren't reported by default.
55-
check-blank: true
56-
govet:
57-
# report about shadowed variables
58-
check-shadowing: true
59-
gocyclo:
60-
# minimal code complexity to report, 30 by default
61-
min-complexity: 15
62-
gosec:
63-
# To specify a set of rules to explicitly exclude.
64-
# Available rules: https://github.com/securego/gosec#available-rules
65-
excludes:
66-
- G108
67-
# To specify the configuration of rules.
68-
# The configuration of rules is not fully documented by gosec:
69-
# https://github.com/securego/gosec#configuration
70-
# https://github.com/securego/gosec/blob/569328eade2ccbad4ce2d0f21ee158ab5356a5cf/rules/rulelist.go#L60-L102
71-
config:
72-
misspell:
73-
# Correct spellings using locale preferences for US or UK.
74-
# Default is to use a neutral variety of English.
75-
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
76-
locale: US
77-
ignore-words:
78-
- someword
79-
stylecheck:
80-
go: "1.16"
81-
# https://staticcheck.io/docs/options#checks
82-
checks: [ "all", "-ST1003", "-ST1008", "-ST1016" ]
83-
# https://staticcheck.io/docs/options#initialisms
84-
initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ]
27+
settings:
28+
errcheck:
29+
check-blank: true
30+
gocyclo:
31+
min-complexity: 15
32+
gosec:
33+
excludes:
34+
- G108
35+
govet:
36+
enable-all: true
37+
misspell:
38+
locale: US
39+
ignore-rules:
40+
- someword
41+
staticcheck:
42+
checks:
43+
- all
44+
- -ST1003
45+
- -ST1008
46+
- -ST1016
47+
initialisms:
48+
- ACL
49+
- API
50+
- ASCII
51+
- CPU
52+
- CSS
53+
- DNS
54+
- EOF
55+
- GUID
56+
- HTML
57+
- HTTP
58+
- HTTPS
59+
- ID
60+
- IP
61+
- JSON
62+
- QPS
63+
- RAM
64+
- RPC
65+
- SLA
66+
- SMTP
67+
- SQL
68+
- SSH
69+
- TCP
70+
- TLS
71+
- TTL
72+
- UDP
73+
- UI
74+
- GID
75+
- UID
76+
- UUID
77+
- URI
78+
- URL
79+
- UTF8
80+
- VM
81+
- XML
82+
- XMPP
83+
- XSRF
84+
- XSS
85+
exclusions:
86+
generated: lax
87+
presets:
88+
- comments
89+
- common-false-positives
90+
- legacy
91+
- std-error-handling
92+
rules:
93+
- linters:
94+
- dupl
95+
- goconst
96+
- gosec
97+
path: _test\.go
98+
paths:
99+
- third_party$
100+
- builtin$
101+
- examples$
102+
formatters:
103+
enable:
104+
- gofmt
105+
- goimports
106+
exclusions:
107+
generated: lax
108+
paths:
109+
- third_party$
110+
- builtin$
111+
- examples$

config/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package config // import "github.com/wabarc/wayback/config"
77
// Opts holds parsed configuration options.
88
// var Opts *Options
99

10-
// nolint:stylecheck
1110
const (
1211
SLOT_IA = "ia" // Internet Archive
1312
SLOT_IS = "is" // archive.today

config/options.go

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -121,54 +121,49 @@ var (
121121

122122
// Options represents a configuration options in the application.
123123
type Options struct {
124-
debug bool
125-
logTime bool
126-
logLevel string
127-
overTor bool
128-
metrics bool
129-
130-
// Enabled services
131-
services sync.Map
132-
133-
ipfs *ipfs
134-
slots map[string]bool
135-
telegram *telegram
136-
mastodon *mastodon
137-
discord *discord
138-
twitter *twitter
139-
github *github
140-
notion *notion
141-
matrix *matrix
142-
slack *slack
143-
nostr *nostr
144-
irc *irc
145-
onion *onion
146-
xmpp *xmpp
147-
omnivore *omnivore
148-
meili *meili
149-
124+
nostr *nostr
125+
irc *irc
126+
meili *meili
127+
omnivore *omnivore
128+
xmpp *xmpp
129+
discord *discord
130+
ipfs *ipfs
131+
slots map[string]bool
132+
telegram *telegram
133+
mastodon *mastodon
134+
onion *onion
135+
twitter *twitter
136+
github *github
137+
notion *notion
138+
matrix *matrix
139+
slack *slack
140+
services sync.Map
141+
maxMediaSize string
142+
storageDir string
143+
waybackUserAgent string
144+
proxy string
145+
logLevel string
150146
listenAddr string
151147
chromeRemoteAddr string
152-
enabledChromeRemote bool
153148
boltPathname string
154149
poolingSize int
155-
storageDir string
156-
maxMediaSize string
157-
proxy string
158150
waybackTimeout int
159151
waybackMaxRetries int
160-
waybackUserAgent string
152+
enabledChromeRemote bool
153+
debug bool
154+
logTime bool
155+
overTor bool
156+
metrics bool
161157
waybackFallback bool
162158
}
163159

164160
type ipfs struct {
165-
host string
166-
port int
167-
mode string
168-
161+
host string
162+
mode string
169163
target string
170164
apikey string
171165
secret string
166+
port int
172167
}
173168

174169
type telegram struct {
@@ -182,8 +177,8 @@ type mastodon struct {
182177
clientKey string
183178
clientSecret string
184179
accessToken string
185-
cw bool
186180
cwText string
181+
cw bool
187182
}
188183

189184
type discord struct {
@@ -239,19 +234,17 @@ type irc struct {
239234
}
240235

241236
type onion struct {
242-
pvk string
243-
244-
localPort int
237+
pvk string
245238
remotePorts []int
246-
247-
disabled bool
239+
localPort int
240+
disabled bool
248241
}
249242

250243
type xmpp struct {
251244
username string
252245
password string
253-
noTLS bool
254246
helptext string
247+
noTLS bool
255248
}
256249

257250
type meili struct {

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Fix playback from discord no response
1919
- Improve IRC publish
2020
- Improve type conversion ([#628](https://github.com/wabarc/wayback/pull/628))
21+
- Upgrade golangci-lint ([#711](https://github.com/wabarc/wayback/pull/711))
2122

2223
## [0.20.1] - 2024-07-02
2324

entity/playback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ const EntityPlayback = "playback"
99

1010
// Playback represents a Playback in the application.
1111
type Playback struct {
12-
ID uint64
1312
Source string
13+
ID uint64
1414
}

pooling/pooling.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ type resource struct {
2929

3030
// Pool represents a pool of services.
3131
type Pool struct {
32-
mutex sync.Mutex
32+
context context.Context
3333
resource chan *resource
34-
timeout time.Duration
34+
closed chan bool
3535
staging queue.Queue
36+
timeout time.Duration
3637

37-
closed chan bool
38-
context context.Context
38+
maxRetries uint64
39+
multiplier float64
40+
mutex sync.Mutex
3941

4042
waiting int32
4143
processing int32
42-
maxRetries uint64
43-
multiplier float64
4444
}
4545

4646
// A Bucket represents a wayback request is sent by a service.
@@ -51,11 +51,11 @@ type Bucket struct {
5151
// Fallback defines an optional func to return a failure response for the Request func.
5252
Fallback func(context.Context) error
5353

54-
// Count of retried attempts
55-
elapsed uint64
56-
5754
// An object that will perform exactly one action.
5855
once *sync.Once
56+
57+
// Count of retried attempts
58+
elapsed uint64
5959
}
6060

6161
func newResource(id int) *resource {

publish/meili/meili.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ var (
3838

3939
// Meili represents a Meilisearch client.
4040
type Meili struct {
41-
ctx context.Context
41+
ctx context.Context
42+
client *http.Client
4243

4344
// Meilisearch server API endpoint.
4445
endpoint string
@@ -51,8 +52,6 @@ type Meili struct {
5152

5253
// Version of the Meilisearch server.
5354
version string
54-
55-
client *http.Client
5655
}
5756

5857
// New returns a Meilisearch client.
@@ -165,11 +164,11 @@ func (m *Meili) existIndex() error {
165164
}
166165

167166
type creates struct {
168-
UID int `json:"uid"`
167+
EnqueuedAt time.Time `json:"enqueuedAt"`
169168
IndexUID string `json:"indexUid"`
170169
Status string `json:"status"`
171170
Type string `json:"type"`
172-
EnqueuedAt time.Time `json:"enqueuedAt"`
171+
UID int `json:"uid"`
173172
}
174173

175174
// createIndex creates an index.

0 commit comments

Comments
 (0)