Skip to content

Commit 67caf2d

Browse files
author
MarcoFalke
committed
Merge #15920: lint: Check that all wallet args are hidden
fac174e lint: Check that all wallet args are hidden (MarcoFalke) Pull request description: Can be tested by calling `git revert 765d589` and then running the script ACKs for commit fac174: fanquake: utACK fac174e practicalswift: tACK fac174e Tree-SHA512: f7d40dc3d9f471c0cf77bc2746c1ef09b9df093b24508e72bfc50114c338e5dcb4a17741cf97566aeddc6d608f13e4eb1c986ae9935cebad1d589495ac16e0b2
2 parents 1085221 + fac174e commit 67caf2d

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

test/lint/check-doc.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,23 @@
1212

1313
from subprocess import check_output
1414
import re
15-
import sys
1615

1716
FOLDER_GREP = 'src'
1817
FOLDER_TEST = 'src/test/'
1918
REGEX_ARG = '(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\("(-[^"]+)"'
2019
REGEX_DOC = 'AddArg\("(-[^"=]+?)(?:=|")'
21-
CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/{}'.format(FOLDER_GREP)
20+
CMD_ROOT_DIR = '$(git rev-parse --show-toplevel)/{}'.format(FOLDER_GREP)
2221
CMD_GREP_ARGS = r"git grep --perl-regexp '{}' -- {} ':(exclude){}'".format(REGEX_ARG, CMD_ROOT_DIR, FOLDER_TEST)
22+
CMD_GREP_WALLET_ARGS = r"git grep --function-context 'void WalletInit::AddWalletOptions' -- {} | grep AddArg".format(CMD_ROOT_DIR)
23+
CMD_GREP_WALLET_HIDDEN_ARGS = r"git grep --function-context 'void DummyWalletInit::AddWalletOptions' -- {}".format(CMD_ROOT_DIR)
2324
CMD_GREP_DOCS = r"git grep --perl-regexp '{}' {}".format(REGEX_DOC, CMD_ROOT_DIR)
2425
# list unsupported, deprecated and duplicate args as they need no documentation
2526
SET_DOC_OPTIONAL = set(['-h', '-help', '-dbcrashratio', '-forcecompactdb'])
2627

2728

28-
def main():
29-
if sys.version_info >= (3, 6):
30-
used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True, encoding='utf8')
31-
docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True, encoding='utf8')
32-
else:
33-
used = check_output(CMD_GREP_ARGS, shell=True).decode('utf8').strip()
34-
docd = check_output(CMD_GREP_DOCS, shell=True).decode('utf8').strip()
29+
def lint_missing_argument_documentation():
30+
used = check_output(CMD_GREP_ARGS, shell=True).decode('utf8').strip()
31+
docd = check_output(CMD_GREP_DOCS, shell=True).decode('utf8').strip()
3532

3633
args_used = set(re.findall(re.compile(REGEX_ARG), used))
3734
args_docd = set(re.findall(re.compile(REGEX_DOC), docd)).union(SET_DOC_OPTIONAL)
@@ -45,7 +42,24 @@ def main():
4542
print("Args unknown : {}".format(len(args_unknown)))
4643
print(args_unknown)
4744

48-
sys.exit(len(args_need_doc))
45+
assert 0 == len(args_need_doc), "Please document the following arguments: {}".format(args_need_doc)
46+
47+
48+
def lint_missing_hidden_wallet_args():
49+
wallet_args = check_output(CMD_GREP_WALLET_ARGS, shell=True).decode('utf8').strip()
50+
wallet_hidden_args = check_output(CMD_GREP_WALLET_HIDDEN_ARGS, shell=True).decode('utf8').strip()
51+
52+
wallet_args = set(re.findall(re.compile(REGEX_DOC), wallet_args))
53+
wallet_hidden_args = set(re.findall(re.compile(r' "([^"=]+)'), wallet_hidden_args))
54+
55+
hidden_missing = wallet_args.difference(wallet_hidden_args)
56+
if hidden_missing:
57+
assert 0, "Please add {} to the hidden args in DummyWalletInit::AddWalletOptions".format(hidden_missing)
58+
59+
60+
def main():
61+
lint_missing_argument_documentation()
62+
lint_missing_hidden_wallet_args()
4963

5064

5165
if __name__ == "__main__":

0 commit comments

Comments
 (0)