Skip to content

Commit

Permalink
Add even more linters and bump golangci-lint to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrik committed Aug 31, 2023
1 parent 47b4984 commit 8303ee1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.2
version: v1.54.2
env:
CGO_LDFLAGS: "-l bpf"

Expand Down
28 changes: 28 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
linters:
enable:
- dupl
- durationcheck
- exhaustive
- exportloopref
- forcetypeassert
- goimports
- gomoddirectives
- interfacebloat
- makezero
- mirror
- misspell
- musttag
- nestif
- nilnil
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- revive
- tagalign
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
# nilerr: https://github.com/gostaticanalysis/nilerr/issues/8
# wastedassign: https://github.com/sanposhiho/wastedassign/issues/39
issues:
exclude-use-default: false
exclude:
Expand Down
1 change: 0 additions & 1 deletion cmd/ebpf_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func listen(addr string) error {
}

return http.ListenAndServe(addr, nil)

}

func ensureCapabilities(keep string) error {
Expand Down
4 changes: 2 additions & 2 deletions decoder/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestDecodeLabels(t *testing.T) {
err bool
}{
{
in: append([]byte{0x8, 0x0, 0x0, 0x0}, zeroPaddedString("bananas", 32)...),
in: append([]byte{0x8, 0x0, 0x0, 0x0}, zeroPaddedString("potatoes", 16)...),
labels: []config.Label{
{
Name: "number",
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestDecodeLabels(t *testing.T) {
},
},
out: []string{"8", "bananas"},
err: true, // this label should be skipped, only tomatos allowed
err: true, // this label should be skipped, only tomatoes allowed
},
}

Expand Down
4 changes: 2 additions & 2 deletions exporter/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cloudflare/ebpf_exporter/v2/config"
)

func attachModule(module *libbpfgo.Module, cfg config.Config) (map[*libbpfgo.BPFProg]bool, error) {
func attachModule(module *libbpfgo.Module, cfg config.Config) map[*libbpfgo.BPFProg]bool {
attached := map[*libbpfgo.BPFProg]bool{}

iter := module.Iterator()
Expand All @@ -26,5 +26,5 @@ func attachModule(module *libbpfgo.Module, cfg config.Config) (map[*libbpfgo.BPF
}
}

return attached, nil
return attached
}
8 changes: 2 additions & 6 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ func (e *Exporter) Attach() error {
return fmt.Errorf("error loading bpf object from %q for config %q: %v", cfg.BPFPath, cfg.Name, err)
}

attachments, err := attachModule(module, cfg)
if err != nil {
return fmt.Errorf("failed to attach to config %q: %s", cfg.Name, err)
}
attachments := attachModule(module, cfg)

e.attachedProgs[cfg.Name] = attachments
e.modules[cfg.Name] = module
Expand All @@ -160,10 +157,9 @@ func (e *Exporter) passKaddrs(module *libbpfgo.Module, cfg config.Config) error
}

name := fmt.Sprintf("kaddr_%s", kaddr)
if err := module.InitGlobalVariable(name, uint64(addr)); err != nil {
if err := module.InitGlobalVariable(name, addr); err != nil {
return fmt.Errorf("error setting kaddr value for %q (const volatile %q) to 0x%x: %v", kaddr, name, addr, err)
}

}

return nil
Expand Down
1 change: 0 additions & 1 deletion exporter/perf_event_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func newPerfEventArraySink(decoders *decoder.Set, module *libbpfgo.Module, count
}

sink.counterVec.WithLabelValues(labelValues...).Inc()

}
}(sink, receiveCh)

Expand Down

0 comments on commit 8303ee1

Please sign in to comment.