diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..84a3fb8 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,13 @@ +version: "2" + +linters: + enable: + - gocyclo + - gocognit + + settings: + gocyclo: + min-complexity: 20 + + gocognit: + min-complexity: 30 diff --git a/cmd/bingo-client/main.go b/cmd/bingo-client/main.go index 0673ee1..a9e4c6a 100644 --- a/cmd/bingo-client/main.go +++ b/cmd/bingo-client/main.go @@ -17,7 +17,7 @@ import ( "golang.org/x/term" ) -func main() { +func main() { //nolint:gocognit,gocyclo // this is a temporary default client that we will refactor completely later on cfg, err := config.Load("config/config.yml") if err != nil { log.Printf("Failed to load config: %v", err) diff --git a/internal/debuginfo/debug_info.go b/internal/debuginfo/debug_info.go index 6799c5f..2f966b6 100644 --- a/internal/debuginfo/debug_info.go +++ b/internal/debuginfo/debug_info.go @@ -4,6 +4,7 @@ import ( "debug/gosym" ) +// Target represents information about the debugging target process type Target struct { Path string PID int @@ -11,8 +12,15 @@ type Target struct { } type DebugInfo interface { + // GetTarget returns the Target struct of the debugger instance GetTarget() Target + + // PCToLine returns the filename, line number and function from the stack memory address PCToLine(pc uint64) (file string, line int, fn *gosym.Func) + + // LineToPC returns the memory address, function or an error from the filename and line number LineToPC(file string, line int) (pc uint64, fn *gosym.Func, err error) + + // LookupFunc returns the Func struct whose name corresponds to the value of fn LookupFunc(fn string) *gosym.Func } diff --git a/lefthook.yml b/lefthook.yml index 66199e6..aae54e7 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -2,43 +2,29 @@ # Documentation: https://lefthook.dev/configuration/ pre-commit: - parallel: true + parallel: false commands: - format: + imports: glob: "*.go" - run: gofmt -w {staged_files} && git add {staged_files} + run: goimports -w {staged_files} && git add {staged_files} vet: glob: "*.go" run: go vet ./... - imports: - glob: "*.go" - run: | - if command -v goimports &> /dev/null; then - goimports -w {staged_files} && git add {staged_files} - fi - lint: glob: "*.go" - run: | - if command -v golangci-lint &> /dev/null; then - golangci-lint run --new-from-rev=HEAD ./... - fi + run: golangci-lint run --new-from-rev=HEAD ./... pre-push: commands: vet: - run: go vet ./cmd/bingo + run: go vet ./... build: - run: just build + run: go build -o ./build/bingo/bingo ./cmd/bingo commit-msg: commands: check-message: - run: | - if [ ! -f ./build/githook/commitlint ]; then - go build -o ./build/githook/commitlint ./cmd/githook - fi - ./build/githook/commitlint {1} + run: go run ./cmd/githook {1}