Skip to content

Commit 22b75ac

Browse files
authored
CI: run codeql in lint.yml (#70)
* CI: run codeql in lint.yml * disable depguard linter * silence linter
1 parent f1de67e commit 22b75ac

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

.github/workflows/lint.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
10+
jobs:
11+
build:
12+
name: "golangci-lint + codeql"
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
security-events: write
17+
18+
steps:
19+
20+
- name: Check out code into the Go module directory
21+
uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v4
27+
with:
28+
go-version: 1.20.5
29+
30+
- name: Initialize CodeQL
31+
uses: github/codeql-action/init@v2
32+
with:
33+
languages: go, python
34+
35+
- name: Build
36+
run: |
37+
make build
38+
39+
- name: golangci-lint
40+
uses: golangci/golangci-lint-action@v3
41+
with:
42+
version: v1.53
43+
args: --issues-exit-code=1 --timeout 10m
44+
only-new-issues: false
45+
# the cache is already managed above, enabling it here
46+
# gives errors when extracting
47+
skip-pkg-cache: true
48+
skip-build-cache: true
49+
50+
- name: Perform CodeQL Analysis
51+
uses: github/codeql-action/analyze@v2

.github/workflows/tests.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,3 @@ jobs:
7676
EOT
7777
sleep 5
7878
sudo -E pipenv run pytest ./test/install/with_crowdsec
79-
80-
- name: golangci-lint
81-
uses: golangci/golangci-lint-action@v3
82-
with:
83-
version: v1.51
84-
args: --issues-exit-code=1 --timeout 10m
85-
only-new-issues: false
86-
# the cache is already managed above, enabling it here
87-
# gives errors when extracting
88-
skip-pkg-cache: true
89-
skip-build-cache: true

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ linters:
3333
# DEPRECATED by golangi-lint
3434
#
3535
- deadcode # The owner seems to have abandoned the linter. Replaced by unused.
36+
- depguard # Go linter that checks if package imports are in a list of acceptable packages
3637
- exhaustivestruct # The owner seems to have abandoned the linter. Replaced by exhaustruct.
3738
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
3839
- ifshort # Checks that your code uses short syntax for if-statements whenever possible
@@ -54,7 +55,6 @@ linters:
5455
# - containedctx # containedctx is a linter that detects struct contained context.Context field
5556
# - contextcheck # check the function whether use a non-inherited context
5657
# - decorder # check declaration order and count of types, constants, variables and functions
57-
# - depguard # Go linter that checks if package imports are in a list of acceptable packages
5858
# - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
5959
# - durationcheck # check for two durations multiplied together
6060
# - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.

pkg/server/logging.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ const lowerhex = "0123456789abcdef"
114114

115115
func appendQuoted(buf []byte, s string) []byte {
116116
var runeTmp [utf8.UTFMax]byte
117+
//nolint:wastedassign
117118
for width := 0; len(s) > 0; s = s[width:] {
118119
r := rune(s[0])
119120
width = 1

0 commit comments

Comments
 (0)