diff --git a/.arclint b/.arclint --- a/.arclint +++ b/.arclint @@ -24,6 +24,10 @@ ], "script-and-regex.script": "test/lint/lint-format-strings.sh", "script-and-regex.regex": "/^(?P.+): (?P.+:.+)$/m" + }, + "check-doc": { + "type": "check-doc", + "include": "(^src/.*\\.(h|c|cpp)$)" } } } diff --git a/arcanist/__phutil_library_map__.php b/arcanist/__phutil_library_map__.php --- a/arcanist/__phutil_library_map__.php +++ b/arcanist/__phutil_library_map__.php @@ -10,11 +10,13 @@ '__library_version__' => 2, 'class' => array( 'AutoPEP8FormatLinter' => 'linter/AutoPEP8Linter.php', + 'CheckDocLinter' => 'linter/CheckDocLinter.php', 'ClangFormatLinter' => 'linter/ClangFormatLinter.php', ), 'function' => array(), 'xmap' => array( 'AutoPEP8FormatLinter' => 'ArcanistExternalLinter', + 'CheckDocLinter' => 'ArcanistExternalLinter', 'ClangFormatLinter' => 'ArcanistExternalLinter', ), )); diff --git a/arcanist/linter/CheckDocLinter.php b/arcanist/linter/CheckDocLinter.php new file mode 100644 --- /dev/null +++ b/arcanist/linter/CheckDocLinter.php @@ -0,0 +1,103 @@ +getProjectRoot()); + } + + public function shouldUseInterpreter() { + return true; + } + + public function getDefaultInterpreter() { + return "python3"; + } + + public function getInstallInstructions() { + return pht('The test/lint/check-doc.py script is part of the bitcoin-abc project'); + } + + public function shouldExpectCommandErrors() { + return false; + } + + protected function getMandatoryFlags() { + return array( + ); + } + + protected function parseLinterOutput($path, $err, $stdout, $stderr) { + /* Split stdout: + * 0 => Empty (before first 'Args' occurence) + * 1 => Args used: count + * 2 => Args documented: count + * 3 => Args undocumented: count and list + * 4 => Args unknown: count and list + */ + $stdoutExploded = preg_split('/Args/', $stdout); + + $undocumented = $stdoutExploded[3]; + $unknown = $stdoutExploded[4]; + + $messages = array(); + + // Undocumented arguments + $match = preg_match_all('/-[\w|-]+/', $undocumented, $args); + foreach($args[0] as $arg) { + $messages[] = id(new ArcanistLintMessage()) + ->setGranularity(ArcanistLinter::GRANULARITY_GLOBAL) + ->setCode('ARGDOC') + ->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR) + ->setName('Undocumented argument') + ->setDescription("'$arg' is undocumented."); + } + + // Unknown arguments + $match = preg_match_all('/-[\w|-]+/', $unknown, $args); + foreach($args[0] as $arg) { + $messages[] = id(new ArcanistLintMessage()) + ->setGranularity(ArcanistLinter::GRANULARITY_GLOBAL) + ->setCode('ARGDOC') + ->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR) + ->setName('Unknown argument') + ->setDescription("'$arg' is documented but not used."); + } + + return $messages; + } +} + +?> diff --git a/doc/release-process.md b/doc/release-process.md --- a/doc/release-process.md +++ b/doc/release-process.md @@ -12,7 +12,7 @@ 2. Verify tests passed - Any known issues or limitations should be documented in release notes - Known bugs should have tickets - - Run the `contrib/devtools/check-doc.py` script and ensure there is no undocumented argument + - Run `arc lint --everything` and check there is no linter error - Verify IBD without checkpoints and without assumevalid. 3. Update the documents / code which needs to be updated every release diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -75,8 +75,6 @@ print("Args unknown : {}".format(len(args_unknown))) pp.pprint(args_unknown) - sys.exit(len(args_need_doc)) - if __name__ == "__main__": main()