Skip to content

Commit 83cacc5

Browse files
committed
Add deadcode linter step in makefile
1 parent 8174b29 commit 83cacc5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,16 @@ test-coverage:
9696
.PHONY: test-build
9797
test-build:
9898
bats -r ./test
99+
100+
.PHONY: deadcode
101+
deadcode:
102+
ifeq (, $(shell command -v deadcode 2> /dev/null))
103+
$(error "'deadcode' command not found. You can install it locally with 'go install golang.org/x/tools/cmd/deadcode@latest'.")
104+
endif
105+
@out=$$(deadcode -test ./... 2>/dev/null); \
106+
if [ -n "$$out" ] && [ "$$out" != "null" ]; then \
107+
echo "Dead code detected:" >&2; \
108+
echo "$$out" >&2; \
109+
exit 1; \
110+
fi
111+
@echo "No dead code found."

0 commit comments

Comments
 (0)