Skip to content

Commit 4f98d3c

Browse files
authored
update lint configuration (#120)
1 parent 47d477d commit 4f98d3c

File tree

4 files changed

+19
-29
lines changed

4 files changed

+19
-29
lines changed

.golangci.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@ version: "2"
33
linters:
44
default: all
55
disable:
6-
- testableexamples
76
- errcheck
8-
- exptostd
9-
- forbidigo
107
- forcetypeassert
11-
- gocritic
128
- promlinter
139
- embeddedstructfieldcheck
1410
- funcorder
1511
- noinlineerr
1612
- wsl_v5
1713

18-
1914
#
2015
# Redundant
2116
#
@@ -76,16 +71,16 @@ linters:
7671
desc: yaml.v2 is deprecated for new code in favor of yaml.v3
7772

7873
errcheck:
79-
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
80-
# Such cases aren't reported by default.
8174
check-type-assertions: false
82-
# List of functions to exclude from checking, where each entry is a single function to exclude.
83-
# See https://github.com/kisielk/errcheck#excluding-functions for details.
8475

8576
gocritic:
8677
enable-all: true
8778
disabled-checks:
79+
- appendCombine
80+
- hugeParam
81+
- importShadow
8882
- paramTypeCombine
83+
- whyNoLint
8984

9085
govet:
9186
disable:
@@ -115,8 +110,6 @@ linters:
115110
- 33
116111
- name: comment-spacings
117112
disabled: true
118-
# - name: confusing-results
119-
# disabled: true
120113
- name: cyclomatic
121114
arguments:
122115
# lower this after refactoring
@@ -142,8 +135,6 @@ linters:
142135
disabled: true
143136
- name: package-comments
144137
disabled: true
145-
- name: var-naming
146-
disabled: true
147138
- name: unchecked-type-assertion
148139
disabled: true
149140
- name: useless-break
@@ -153,10 +144,6 @@ linters:
153144
checks:
154145
- all
155146

156-
wsl:
157-
# Allow blocks to end with comments
158-
allow-trailing-comment: true
159-
160147
exclusions:
161148
presets:
162149
- comments

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func Execute() error {
5656
flag.Parse()
5757

5858
if *bouncerVersion {
59-
fmt.Printf("%s", version.FullString())
59+
fmt.Fprintf(os.Stdout, "%s", version.FullString())
6060
return nil
6161
}
6262

@@ -70,7 +70,7 @@ func Execute() error {
7070
}
7171

7272
if *showConfig {
73-
fmt.Println(string(configBytes))
73+
fmt.Fprintln(os.Stdout, string(configBytes))
7474
return nil
7575
}
7676

pkg/server/logging.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const lowerhex = "0123456789abcdef"
119119
func appendQuoted(buf []byte, s string) []byte {
120120
var runeTmp [utf8.UTFMax]byte
121121
//nolint:wastedassign
122-
for width := 0; len(s) > 0; s = s[width:] {
122+
for width := 0; s != ""; s = s[width:] {
123123
r := rune(s[0])
124124
width = 1
125125

scripts/_bouncer.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,23 @@ msg() {
4949
}
5050

5151
require() {
52-
set | grep -q "^$1=" || { msg err "missing required variable \$$1"; exit 1; }
52+
set | grep -q "^$1=" || {
53+
msg err "missing required variable \$$1"
54+
exit 1
55+
}
5356
shift
5457
[ "$#" -eq 0 ] || require "$@"
5558
}
5659

5760
# shellcheck disable=SC2034
5861
{
59-
SERVICE="$BOUNCER.service"
60-
BIN_PATH_INSTALLED="/usr/local/bin/$BOUNCER"
61-
BIN_PATH="./$BOUNCER"
62-
CONFIG_DIR="/etc/crowdsec/bouncers"
63-
CONFIG_FILE="$BOUNCER.yaml"
64-
CONFIG="$CONFIG_DIR/$CONFIG_FILE"
65-
SYSTEMD_PATH_FILE="/etc/systemd/system/$SERVICE"
62+
SERVICE="$BOUNCER.service"
63+
BIN_PATH_INSTALLED="/usr/local/bin/$BOUNCER"
64+
BIN_PATH="./$BOUNCER"
65+
CONFIG_DIR="/etc/crowdsec/bouncers"
66+
CONFIG_FILE="$BOUNCER.yaml"
67+
CONFIG="$CONFIG_DIR/$CONFIG_FILE"
68+
SYSTEMD_PATH_FILE="/etc/systemd/system/$SERVICE"
6669
}
6770

6871
assert_root() {
@@ -141,7 +144,7 @@ set_api_key() {
141144
ret=1
142145
else
143146
echo "API Key successfully created" >&2
144-
echo "$bouncer_id" > "$CONFIG.id"
147+
echo "$bouncer_id" >"$CONFIG.id"
145148
fi
146149
else
147150
echo "cscli/crowdsec is not present, please set the API key manually" >&2

0 commit comments

Comments
 (0)