From 250d84a5af2ff6860a5e65931a8fccbf2b0e5fca Mon Sep 17 00:00:00 2001 From: kwanhur Date: Sun, 6 Mar 2022 23:09:27 +0800 Subject: [PATCH] Add staticcheck hook Signed-off-by: kwanhur --- .pre-commit-hooks.yaml | 6 ++++++ run-static-check.sh | 5 +++++ 2 files changed, 11 insertions(+) create mode 100755 run-static-check.sh diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 05c6f89..75807fb 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -57,6 +57,12 @@ language: 'script' pass_filenames: false description: "Runs `golangci-lint`, requires https://github.com/golangci/golangci-lint" +- id: staticcheck + name: 'staticcheck' + entry: run-static-check.sh + files: '\.go$' + language: 'script' + description: "Runs `staticcheck`, requires https://honnef.co/go/tools/cmd/staticcheck" - id: go-critic name: 'go-critic' entry: run-go-critic.sh diff --git a/run-static-check.sh b/run-static-check.sh new file mode 100755 index 0000000..d0ccbe8 --- /dev/null +++ b/run-static-check.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +for dir in $(echo $@|xargs -n1 dirname|sort -u); do + staticcheck $dir +done