Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/unit-test-on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ jobs:
- name: Get linter version
id: linter-version
run: (echo -n "version="; make linter-version) >> "$GITHUB_OUTPUT"
- name: golangci-lint
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
- name: linter
env:
GOARCH: ${{ matrix.target-arch }}
CGO_ENABLED: 1
with:
version: ${{ steps.linter-version.outputs.version }}
- name: Lint eBPF code
run: |
sudo apt update
sudo apt install -y clang-format-17
make lint -C support/ebpf
make lint

test:
name: Test (${{ matrix.target_arch }})
Expand Down
156 changes: 82 additions & 74 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
version: "2"

formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes:
- github.com/open-telemetry/opentelemetry-ebpf-profiler

run:
timeout: 10m
build-tags:
- integration
- linux

issues:
exclude-dirs:
- artifacts
- build-targets
- design
- docker-images
- docs
- etc
- experiments
- infrastructure
- legal
- libpf-rs
- mocks
- pf-code-indexing-service/cibackend/gomock_*
- pf-debug-metadata-service/dmsbackend/gomock_*
- pf-host-agent/support/ci-kernels
- pf-storage-backend/storagebackend/gomock_*
- scratch
- systemtests/benchmarks/_outdata
- target
- virt-tests
- vm-images

# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Don't complain about integer overflows
- text: "G115:"
linters:
- gosec

linters:
enable-all: true
default: all
disable:
# Disabled because of
# - too many non-sensical warnings
Expand All @@ -50,22 +36,23 @@ linters:
- dupword
- durationcheck # might be worth fixing
- err113
- errcheck
- errorlint # might be worth fixing
- exhaustive
- exhaustruct
- forbidigo
- forcetypeassert # might be worth fixing
- funlen
- gci # might be worth fixing
- funcorder
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocyclo
- godot
- godox # complains about TODO etc
- gofumpt
- gomoddirectives
- gosmopolitan
- inamedparam
- interfacebloat
- ireturn
Expand All @@ -81,6 +68,7 @@ linters:
- paralleltest
- protogetter
- sqlclosecheck # might be worth fixing
- staticcheck
- tagalign
- tagliatelle
- testableexamples # might be worth fixing
Expand All @@ -94,45 +82,65 @@ linters:
# we don't want to change code to Go 1.22+ yet
- intrange
- copyloopvar
- tenv

linters-settings:
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- whyNoLint
- sloppyReassign
- uncheckedInlineErr # Experimental rule with high false positive rate.
gocyclo:
min-complexity: 15
govet:
enable-all: true
disable:
- fieldalignment
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
- debug,debugf,debugln
- error,errorf,errorln
- fatal,fatalf,fataln
- info,infof,infoln
- log,logf,logln
- warn,warnf,warnln
- print,printf,println,sprint,sprintf,sprintln,fprint,fprintf,fprintln
lll:
line-length: 100
tab-width: 4
misspell:
locale: US
ignore-words:
- rela
exclusions:
paths:
- design-docs
- doc
- legal
- target

settings:
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- whyNoLint
- sloppyReassign
- uncheckedInlineErr # experimental rule with high false positive rate.
- importShadow # shadow of imported package
gocyclo:
min-complexity: 15
gosec:
excludes:
- G103 # unsafe calls should be audited
- G115 # integer overflow
- G204 # subprocess launched with variable
- G301 # directory permissions
- G302 # file permissions
- G304 # potential file inclusion via variable
govet:
enable-all: true
disable:
- fieldalignment
- unsafeptr
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
- debug,debugf,debugln
- error,errorf,errorln
- fatal,fatalf,fataln
- info,infof,infoln
- log,logf,logln
- warn,warnf,warnln
- print,printf,println,sprint,sprintf,sprintln,fprint,fprintf,fprintln
lll:
line-length: 100
tab-width: 4
misspell:
locale: US
ignore-rules:
- rela
revive:
rules:
- name: unexported-naming
disabled: true
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ rust-components: rust-targets
rust-tests: rust-targets
cargo test

GOLANGCI_LINT_VERSION = "v1.64.5"
GOLANGCI_LINT_VERSION = "v2.1.6"
lint: generate vanity-import-check
$(MAKE) lint -C support/ebpf
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) version
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run
docker run --rm -t -v $$(pwd):/app -w /app golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) sh -c "golangci-lint version && golangci-lint config verify && golangci-lint run --max-issues-per-linter -1 --max-same-issues -1"

format-ebpf:
$(MAKE) format -C support/ebpf
Expand Down
2 changes: 0 additions & 2 deletions interpreter/hotspot/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
)

// Constants for the JVM internals that have never changed
//
//nolint:golint,stylecheck,revive
const ConstMethod_has_linenumber_table = 0x0001

// hotspotMethod contains symbolization information for one Java method. It caches
Expand Down
1 change: 0 additions & 1 deletion interpreter/perl/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type perlData struct {
// vmStructs reflects the Perl internal class names and the offsets of named field
// The struct names are based on the Perl C "struct name", the alternate typedef seen
// mostly in code is in parenthesis.
//nolint:golint,stylecheck,revive
vmStructs struct {
// interpreter struct (PerlInterpreter) is defined in intrpvar.h via macro trickery
// https://github.com/Perl/perl5/blob/v5.32.0/intrpvar.h
Expand Down
1 change: 0 additions & 1 deletion interpreter/perl/perl.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import (
"go.opentelemetry.io/ebpf-profiler/interpreter"
)

//nolint:golint,stylecheck,revive
const (
// Scalar Value types (SVt)
// https://github.com/Perl/perl5/blob/v5.32.0/sv.h#L132-L166
Expand Down
1 change: 0 additions & 1 deletion interpreter/php/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"go.opentelemetry.io/ebpf-profiler/util"
)

//nolint:golint,stylecheck,revive
const (
// zend_function.type definitions from PHP sources
ZEND_USER_FUNCTION = (1 << 1)
Expand Down
2 changes: 0 additions & 2 deletions interpreter/php/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"go.opentelemetry.io/ebpf-profiler/support"
)

//nolint:golint,stylecheck,revive
const (
// This is used to check if the VM mode is the default one
// From https://github.com/php/php-src/blob/PHP-8.0/Zend/zend_vm_opcodes.h#L29
Expand Down Expand Up @@ -71,7 +70,6 @@ type phpData struct {
rtAddr libpf.Address

// vmStructs reflects the PHP internal class names and the offsets of named field
//nolint:golint,stylecheck,revive
vmStructs struct {
// https://github.com/php/php-src/blob/PHP-7.4/Zend/zend_globals.h#L135
zend_executor_globals struct {
Expand Down
1 change: 0 additions & 1 deletion interpreter/ruby/ruby.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ type rubyData struct {
version uint32

// vmStructs reflects the Ruby internal names and offsets of named fields.
//nolint:golint,stylecheck,revive
vmStructs struct {
// rb_execution_context_struct
// https://github.com/ruby/ruby/blob/5445e0435260b449decf2ac16f9d09bae3cafe72/vm_core.h#L843
Expand Down
6 changes: 3 additions & 3 deletions libpf/pfelf/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func Open(name string) (*File, error) {

ff, err := newFile(f, f, 0, false)
if err != nil {
f.Close()
_ = f.Close()
return nil, err
}
return ff, nil
Expand Down Expand Up @@ -518,7 +518,7 @@ func (f *File) DebuglinkFileName(elfFilePath string, elfOpener ELFOpener) string
}
file, path := f.OpenDebugLink(elfFilePath, elfOpener)
if file != nil {
file.Close()
_ = file.Close()
}
return path
}
Expand Down Expand Up @@ -648,7 +648,7 @@ func (f *File) OpenDebugLink(elfFilePath string, elfOpener ELFOpener) (
}
fileCRC32, err := debugELF.CRC32()
if err != nil || fileCRC32 != linkCRC32 {
debugELF.Close()
_ = debugELF.Close()
continue
}
f.debuglinkPath = debugFile
Expand Down
4 changes: 2 additions & 2 deletions libpf/pfelf/pfelf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestGetBuildIDError(t *testing.T) {

buildID, err := pfelf.GetBuildID(elfFile)
if assert.ErrorIs(t, pfelf.ErrNoBuildID, err) {
assert.Equal(t, "", buildID)
assert.Empty(t, buildID)
}
}

Expand All @@ -83,7 +83,7 @@ func TestGetDebugLinkError(t *testing.T) {

debugLink, _, err := pfelf.GetDebugLink(elfFile)
if assert.ErrorIs(t, pfelf.ErrNoDebugLink, err) {
assert.Equal(t, "", debugLink)
assert.Empty(t, debugLink)
}
}

Expand Down
2 changes: 1 addition & 1 deletion libpf/pfelf/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (ref *Reference) GetELF() (*File, error) {
// Close closes the File if it has been opened earlier.
func (ref *Reference) Close() {
if ref.elfFile != nil {
ref.elfFile.Close()
_ = ref.elfFile.Close()
ref.elfFile = nil
}
}
2 changes: 0 additions & 2 deletions nativeunwind/elfunwindinfo/elfehframe.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const (
// The subset needed for normal .eh_frame handling
type expressionOpcode uint8

//nolint:deadcode,varcheck
const (
opDeref expressionOpcode = 0x06
opConstU expressionOpcode = 0x10
Expand All @@ -123,7 +122,6 @@ type dwarfExpression struct {
// https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/dwarfext.html
type encoding uint8

//nolint:deadcode,varcheck
const (
encFormatNative encoding = 0x00
encFormatLeb128 encoding = 0x01
Expand Down
1 change: 0 additions & 1 deletion nativeunwind/elfunwindinfo/elfehframe_aarch64.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"go.opentelemetry.io/ebpf-profiler/support"
)

//nolint:deadcode,varcheck
const (
// Aarch64 ABI
armRegX0 uleb128 = 0
Expand Down
1 change: 0 additions & 1 deletion nativeunwind/elfunwindinfo/elfehframe_x86.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"go.opentelemetry.io/ebpf-profiler/support"
)

//nolint:deadcode,varcheck
const (
// x86_64 abi (https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf, page 57)
x86RegRAX uleb128 = 0
Expand Down
Loading