Skip to content

Commit b1716de

Browse files
committed
golangci: try to set up golangci
The ebpf libraries are not helping at all. Fix #28
1 parent bb99b44 commit b1716de

File tree

2 files changed

+169
-1
lines changed

2 files changed

+169
-1
lines changed

.github/workflows/tests.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ jobs:
4747
name: unit-test
4848
path: /tmp/unit/
4949

50+
- name: Golangci-lint
51+
uses: golangci/[email protected]
52+
continue-on-error: true
53+
with:
54+
# TODO: find a way to pass this the same way we pass it to go test
55+
args: --issues-exit-code 0 internal/analyzer internal/archiver internal/elfreader internal/embeddable internal/executor internal/metadata internal/privileged internal/seccomputils internal/writer
56+
5057
integration-test:
5158

5259
runs-on: ubuntu-latest
@@ -76,7 +83,7 @@ jobs:
7683
mkdir -p /tmp/integration
7784
# we have to run integration tests one-by-one
7885
# otherwhise they will run in parallel.
79-
# since harpoon apply network forwards, these could
86+
# since harpoon apply network forwards, these could
8087
# interact with each other and make the test fail.
8188
go test \
8289
-exec sudo \

.golangci.yml

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
# golangci-lint configuration file made by @ccoVeille
3+
# Source: https://github.com/ccoVeille/golangci-lint-config-examples/
4+
# Author: @ccoVeille
5+
# License: MIT
6+
#
7+
issues:
8+
# Maximum issues count per one linter.
9+
# Set to 0 to disable the limit (Default: 50)
10+
max-issues-per-linter: 0
11+
# Maximum count of issues with the same text.
12+
# Set to 0 to disable the limit (Default: 3)
13+
max-same-issues: 0
14+
15+
output:
16+
show-stats: true
17+
18+
linters:
19+
# some linters are enabled by default
20+
# https://golangci-lint.run/usage/linters/
21+
#
22+
# enable some extra linters
23+
enable:
24+
# Errcheck is a program for checking for unchecked errors in Go code.
25+
- errcheck
26+
27+
# Linter for Go source code that specializes in simplifying code.
28+
- gosimple
29+
30+
# Vet examines Go source code and reports suspicious constructs.
31+
- govet
32+
33+
# Detects when assignments to existing variables are not used.
34+
- ineffassign
35+
36+
# It's a set of rules from staticcheck. See https://staticcheck.io/
37+
- staticcheck
38+
39+
# Fast, configurable, extensible, flexible, and beautiful linter for Go.
40+
# Drop-in replacement of golint.
41+
- revive
42+
43+
# check imports order and makes it always deterministic.
44+
- gci
45+
46+
# make sure to use t.Helper() when needed
47+
- thelper
48+
49+
# mirror suggests rewrites to avoid unnecessary []byte/string conversion
50+
- mirror
51+
52+
# detect the possibility to use variables/constants from the Go standard library.
53+
- usestdlibvars
54+
55+
# find what will cause problems with the error wrapping
56+
- errorlint
57+
58+
# Finds commonly misspelled English words.
59+
- misspell
60+
61+
# Checks for duplicate words in the source code.
62+
- dupword
63+
64+
linters-settings:
65+
gci: # define the section orders for imports
66+
sections:
67+
# Standard section: captures all standard packages.
68+
- standard
69+
# Default section: catchall that is not standard or custom
70+
- default
71+
# linters that related to local tool, so they should be separated
72+
- localmodule
73+
74+
revive:
75+
rules:
76+
# these are the default revive rules
77+
# you can remove the whole "rules" node if you want
78+
# BUT
79+
# ! /!\ they all need to be present when you want to add more rules than the default ones
80+
# otherwise, you won't have the default rules, but only the ones you define in the "rules" node
81+
82+
# Blank import should be only in a main or test package, or have a comment justifying it.
83+
- name: blank-imports
84+
85+
# context.Context() should be the first parameter of a function when provided as argument.
86+
- name: context-as-argument
87+
arguments:
88+
- allowTypesBefore: "*testing.T"
89+
90+
# Basic types should not be used as a key in `context.WithValue`
91+
- name: context-keys-type
92+
93+
# Importing with `.` makes the programs much harder to understand
94+
- name: dot-imports
95+
96+
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
97+
- name: empty-block
98+
99+
# for better readability, variables of type `error` must be named with the prefix `err`.
100+
- name: error-naming
101+
102+
# for better readability, the errors should be last in the list of returned values by a function.
103+
- name: error-return
104+
105+
# for better readability, error messages should not be capitalized or end with punctuation or a newline.
106+
- name: error-strings
107+
108+
# report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible
109+
- name: errorf
110+
111+
# incrementing an integer variable by 1 is recommended to be done using the `++` operator
112+
- name: increment-decrement
113+
114+
# highlights redundant else-blocks that can be eliminated from the code
115+
- name: indent-error-flow
116+
117+
# This rule suggests a shorter way of writing ranges that do not use the second value.
118+
- name: range
119+
120+
# receiver names in a method should reflect the struct name (p for Person, for example)
121+
- name: receiver-naming
122+
123+
# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect.
124+
- name: redefines-builtin-id
125+
126+
# redundant else-blocks that can be eliminated from the code.
127+
- name: superfluous-else
128+
129+
# prevent confusing name for variables when using `time` package
130+
- name: time-naming
131+
132+
# warns when an exported function or method returns a value of an un-exported type.
133+
- name: unexported-return
134+
135+
# spots and proposes to remove unreachable code. also helps to spot errors
136+
- name: unreachable-code
137+
138+
# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
139+
- name: unused-parameter
140+
141+
# report when a variable declaration can be simplified
142+
- name: var-declaration
143+
144+
# warns when initialism, variable or package naming conventions are not followed.
145+
- name: var-naming
146+
147+
# report when a comment should be starting with a space
148+
- name: comment-spacings
149+
150+
# This rule warns when errors returned by a function are not explicitly handled on the caller side.
151+
- name: unhandled-error
152+
153+
dupword:
154+
# Keywords used to ignore detection.
155+
# Default: []
156+
ignore:
157+
# - "blah" # this will accept "blah blah …" as a valid duplicate word
158+
159+
misspell:
160+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
161+
locale: US

0 commit comments

Comments
 (0)