Skip to content

Commit 44e907b

Browse files
committed
chore: Add amount access check to pre-commit.
Reimplements `make check-amount-access` for Python regex.
1 parent 7be3772 commit 44e907b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ repos:
1717
hooks:
1818
- id: shellcheck
1919
args: [ -fgcc ]
20+
21+
- repo: local
22+
hooks:
23+
# Reimplementation of `make check-amount-access` for pygrep.
24+
- id: check-amount-access
25+
name: Check amount_msat and amount_sat members are not accessed directly
26+
description: "Don't access amount_msat and amount_sat members directly without a good reason since it risks overflow."
27+
language: pygrep
28+
entry: (->|\.)(milli)?satoshis(?!.*\/\*\ Raw:)|(?<!sizeof)\(struct\ amount_(m)?sat\)
29+
types: [ c ]
30+
exclude: common/amount|.*/test/.*

0 commit comments

Comments
 (0)