mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01:00
7be2b2456a
fa3c910bfeab00703c947c5200a64c21225b50ef test: Move linters to test/lint, add readme (MarcoFalke) Pull request description: This moves the checks and linters from `devtools` to a subfolder in `test`. (Motivated by my opinion that the dev tools are mostly for generating code and updating the repo whereas the linters are read-only checks.) Also, adds a readme to clarify that checks and linters are only meant to prevent bugs and user facing issues, not merely stylistic preference or inconsistencies. (This is motivated by the diversity in developers and work flows as well as existing code styles. It would be too disruptive to change all existing code to a single style or too burdensome to force all developers to adhere to a single style. Also note that our style guide is changing, so locking in at the wrong style "too early" would only waste resources.) Tree-SHA512: 9b10e89f2aeaf0c8a9ae248aa891d74e0abf0569f8e5dfd266446efa8bfaf19f0ea0980abf0b0b22f0d8416ee90d7435d21a9f9285b66df43f370b7979173406
49 lines
1.8 KiB
Python
Executable File
49 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2015 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
'''
|
|
This checks if all command line args are documented.
|
|
Return value is 0 to indicate no error.
|
|
|
|
Author: @MarcoFalke
|
|
'''
|
|
|
|
from subprocess import check_output
|
|
import re
|
|
import sys
|
|
|
|
FOLDER_GREP = 'src'
|
|
FOLDER_TEST = 'src/test/'
|
|
REGEX_ARG = '(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\("(-[^"]+)"'
|
|
REGEX_DOC = 'HelpMessageOpt\("(-[^"=]+?)(?:=|")'
|
|
CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/{}'.format(FOLDER_GREP)
|
|
CMD_GREP_ARGS = r"git grep --perl-regexp '{}' -- {} ':(exclude){}'".format(REGEX_ARG, CMD_ROOT_DIR, FOLDER_TEST)
|
|
CMD_GREP_DOCS = r"git grep --perl-regexp '{}' {}".format(REGEX_DOC, CMD_ROOT_DIR)
|
|
# list unsupported, deprecated and duplicate args as they need no documentation
|
|
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-blockminsize', '-dbcrashratio', '-forcecompactdb'])
|
|
|
|
|
|
def main():
|
|
used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True)
|
|
docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True)
|
|
|
|
args_used = set(re.findall(re.compile(REGEX_ARG), used))
|
|
args_docd = set(re.findall(re.compile(REGEX_DOC), docd)).union(SET_DOC_OPTIONAL)
|
|
args_need_doc = args_used.difference(args_docd)
|
|
args_unknown = args_docd.difference(args_used)
|
|
|
|
print("Args used : {}".format(len(args_used)))
|
|
print("Args documented : {}".format(len(args_docd)))
|
|
print("Args undocumented: {}".format(len(args_need_doc)))
|
|
print(args_need_doc)
|
|
print("Args unknown : {}".format(len(args_unknown)))
|
|
print(args_unknown)
|
|
|
|
sys.exit(len(args_need_doc))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|