Skip to content

Commit 3f8776a

Browse files
committed
Re-add dead code detection
1 parent 6c61408 commit 3f8776a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ci/lint/04_install.sh

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ${CI_RETRY_EXE} pip3 install codespell==2.0.0
1515
${CI_RETRY_EXE} pip3 install flake8==3.8.3
1616
${CI_RETRY_EXE} pip3 install yq
1717
${CI_RETRY_EXE} pip3 install mypy==0.781
18+
${CI_RETRY_EXE} pip3 install vulture==2.3
1819

1920
SHELLCHECK_VERSION=v0.7.1
2021
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/

test/lint/lint-python-dead-code.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2021 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
#
7+
# Find dead Python code.
8+
9+
export LC_ALL=C
10+
11+
if ! command -v vulture > /dev/null; then
12+
echo "Skipping Python dead code linting since vulture is not installed. Install by running \"pip3 install vulture\""
13+
exit 0
14+
fi
15+
16+
# --min-confidence 100 will only report code that is guaranteed to be unused within the analyzed files.
17+
# Any value below 100 introduces the risk of false positives, which would create an unacceptable maintenance burden.
18+
if ! vulture \
19+
--min-confidence 100 \
20+
$(git ls-files -- "*.py"); then
21+
echo "Python dead code detection found some issues"
22+
exit 1
23+
fi

0 commit comments

Comments
 (0)