Skip to content

Commit 6080228

Browse files
committed
Lint setup
Signed-off-by: Chris Koch <[email protected]>
1 parent aeb09c4 commit 6080228

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

.github/workflows/golangci-lint.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: read
14+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
15+
pull-requests: read
16+
17+
jobs:
18+
golangci:
19+
name: lint
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/setup-go@v3
23+
with:
24+
go-version: '1.20'
25+
- uses: actions/checkout@v3
26+
- name: golangci-lint
27+
uses: golangci/golangci-lint-action@v3
28+
with:
29+
version: latest

.golangci.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
linters:
2+
enable:
3+
- containedctx
4+
- gocritic
5+
- godot
6+
- nilerr
7+
- revive
8+
- unconvert
9+
10+
issues:
11+
include:
12+
- EXC0012
13+
- EXC0013
14+
- EXC0014
15+
- EXC0015
16+
17+
linters-settings:
18+
gocritic:
19+
disabledChecks:
20+
- ifElseChain
21+
revive:
22+
# Maximum number of open files at the same time.
23+
# See https://github.com/mgechev/revive#command-line-flags
24+
# Defaults to unlimited.
25+
max-open-files: 2048
26+
# When set to false, ignores files with "GENERATED" header, similar to golint.
27+
# See https://github.com/mgechev/revive#available-rules for details.
28+
# Default: false
29+
ignore-generated-header: true
30+
# Sets the default severity.
31+
# See https://github.com/mgechev/revive#configuration
32+
# Default: warning
33+
severity: error
34+
# Default: false
35+
# Sets the default failure confidence.
36+
# This means that linting errors with less than 0.8 confidence will be ignored.
37+
# Default: 0.8
38+
confidence: 0.8
39+
rules:
40+
- name: blank-imports
41+
- name: context-as-argument
42+
arguments:
43+
- allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness"
44+
- name: context-keys-type
45+
- name: error-return
46+
- name: error-strings
47+
- name: error-naming
48+
- name: exported
49+
arguments:
50+
- "checkPrivateReceivers"
51+
- "sayRepetitiveInsteadOfStutters"
52+
- name: if-return
53+
- name: increment-decrement
54+
- name: var-naming
55+
- name: var-declaration
56+
- name: package-comments
57+
- name: range
58+
- name: receiver-naming
59+
- name: time-naming
60+
- name: unexported-return
61+
- name: indent-error-flow
62+
- name: errorf
63+
- name: early-return
64+
- name: file-header
65+
arguments:
66+
- "Copyright 20[1-2][0-9](-20[1-2][0-9])? the u-root Authors. All rights reserved Use of this source code is governed by a BSD-style license that can be found in the LICENSE file."

.revive.toml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ignoreGeneratedHeader = false
2+
severity = "warning"
3+
confidence = 0.8
4+
errorCode = 0
5+
warningCode = 0
6+
7+
[rule.blank-imports]
8+
[rule.context-as-argument]
9+
[rule.context-keys-type]
10+
[rule.dot-imports]
11+
[rule.error-return]
12+
[rule.error-strings]
13+
[rule.error-naming]
14+
[rule.exported]
15+
[rule.if-return]
16+
[rule.increment-decrement]
17+
[rule.var-naming]
18+
[rule.var-declaration]
19+
[rule.package-comments]
20+
[rule.range]
21+
[rule.receiver-naming]
22+
[rule.time-naming]
23+
[rule.unexported-return]
24+
[rule.indent-error-flow]
25+
[rule.errorf]
26+
[rule.early-return]
27+
[rule.file-header]
28+
arguments=["Copyright 20[1-2][0-9](-20[1-2][0-9])? the u-root Authors. All rights reserved Use of this source code is governed by a BSD-style license that can be found in the LICENSE file."]

0 commit comments

Comments
 (0)