diff --git a/.arcconfig b/.arcconfig --- a/.arcconfig +++ b/.arcconfig @@ -7,5 +7,6 @@ "arc.feature.start.default" : "master", "history.immutable" : false, "load" : ["arcanist"], + "arcanist_configuration" : "BitcoinABCConfiguration", "lint.engine" : "BitcoinABCConfigurationDrivenLintEngine" } diff --git a/.arclint b/.arclint --- a/.arclint +++ b/.arclint @@ -3,20 +3,6 @@ "generated": { "type": "generated" }, - "clang-format": { - "type": "clang-format", - "version": "7.0", - "bin": ["clang-format-7", "clang-format"], - "include": "(^src/.*\\.(h|c|cpp)$)", - "exclude": [ - "(^src/(secp256k1|univalue|leveldb)/)" - ] - }, - "autopep8": { - "type": "autopep8", - "version": ">=1.3.4", - "include": "(\\.py$)" - }, "flake8": { "type": "flake8", "include": "(\\.py$)", diff --git a/.runlast.arclint b/.runlast.arclint new file mode 100644 --- /dev/null +++ b/.runlast.arclint @@ -0,0 +1,18 @@ +{ + "linters": { + "clang-format": { + "type": "clang-format", + "version": "7.0", + "bin": ["clang-format-7", "clang-format"], + "include": "(^src/.*\\.(h|c|cpp)$)", + "exclude": [ + "(^src/(secp256k1|univalue|leveldb)/)" + ] + }, + "autopep8": { + "type": "autopep8", + "version": ">=1.3.4", + "include": "(\\.py$)" + } + } +} diff --git a/arcanist/.phutil_module_cache b/arcanist/.phutil_module_cache --- a/arcanist/.phutil_module_cache +++ b/arcanist/.phutil_module_cache @@ -1 +1 @@ -{"__symbol_cache_version__":11,"2809b09d2021203b43c57da33d1fe8bf":{"have":{"class":{"AssertWithSideEffectsLinter":210}},"need":{"function":{"pht":439},"class":{"ArcanistLinter":246,"ArcanistLintSeverity":926,"Filesystem":1170}},"xmap":{"AssertWithSideEffectsLinter":["ArcanistLinter"]}},"90a8b110dc475955f15bb81d37268cb5":{"have":{"class":{"AutoPEP8FormatLinter":75}},"need":{"function":{"pht":297,"execx":769,"id":1903},"class":{"ArcanistExternalLinter":104,"ArcanistLintMessage":1910,"Filesystem":1754,"ArcanistLinter":2017,"ArcanistLintSeverity":2095}},"xmap":{"AutoPEP8FormatLinter":["ArcanistExternalLinter"]}},"38f0c676bff5192a344464142caaa253":{"have":{"class":{"CHeaderLinter":99}},"need":{"function":{"pht":611},"class":{"ArcanistLinter":121,"ArcanistLintSeverity":1060,"Filesystem":1307}},"xmap":{"CHeaderLinter":["ArcanistLinter"]}},"a30e4e25376ca05d4ae719915441be9e":{"have":{"class":{"CheckDocLinter":106}},"need":{"function":{"pht":323,"id":1848},"class":{"ArcanistExternalLinter":129,"ArcanistLintMessage":1855,"Filesystem":731,"ArcanistLinter":1903,"ArcanistLintSeverity":1989}},"xmap":{"CheckDocLinter":["ArcanistExternalLinter"]}},"6af7410cfea496ff1d4dcc2624b6b8ea":{"have":{"class":{"ClangFormatLinter":79}},"need":{"function":{"pht":302,"execx":781,"id":1653},"class":{"ArcanistExternalLinter":105,"ArcanistLintMessage":1660,"Filesystem":1504,"ArcanistLinter":1767,"ArcanistLintSeverity":1845}},"xmap":{"ClangFormatLinter":["ArcanistExternalLinter"]}},"9285ad9415f8ebe564f7119e5a72c559":{"have":{"class":{"FormatStringLinter":146}},"need":{"function":{"pht":377,"csprintf":1492,"id":1872},"class":{"ArcanistExternalLinter":173,"ArcanistLintMessage":1879,"Filesystem":827,"ArcanistLinter":1956,"ArcanistLintSeverity":2044}},"xmap":{"FormatStringLinter":["ArcanistExternalLinter"]}},"224d394856b17878058b4c14acb7178b":{"have":{"class":{"LocaleDependenceLinter":160}},"need":{"function":{"pht":5400},"class":{"ArcanistLinter":191,"ArcanistLintSeverity":5903,"Filesystem":6149}},"xmap":{"LocaleDependenceLinter":["ArcanistLinter"]}},"6f2f22dd0f259fb2eaa284b4fab3bc29":{"have":{"class":{"PythonFormatLinter":123}},"need":{"function":{"pht":353,"id":1838},"class":{"ArcanistExternalLinter":150,"ArcanistLintMessage":1845,"Filesystem":776,"ArcanistLinter":1970,"ArcanistLintSeverity":2053}},"xmap":{"PythonFormatLinter":["ArcanistExternalLinter"]}},"25781df78f6eebfb223296b8265e9d19":{"have":{"class":{"TestsLinter":103}},"need":{"function":{"pht":318,"id":2629},"class":{"ArcanistExternalLinter":123,"ArcanistLintMessage":2636,"Filesystem":776,"ArcanistLinter":2684,"ArcanistLintSeverity":2792}},"xmap":{"TestsLinter":["ArcanistExternalLinter"]}},"0ab29329c5371d373da9d1ad4ff7db97":{"have":{"class":{"BitcoinABCConfigurationDrivenLintEngine":13}},"need":{"function":{"pht":383,"phutil_json_decode":700,"idx":1440,"id":4148},"class":{"ArcanistLintEngine":61,"ArcanistUsageException":351,"PhutilProxyException":789,"PhutilClassMapQuery":4155,"Filesystem":295,"PhutilTypeSpec":1067,"PhutilConsole":3620},"class\/interface":{"PhutilJSONParserException":740,"PhutilTypeCheckException":1262}},"xmap":{"BitcoinABCConfigurationDrivenLintEngine":["ArcanistLintEngine"]}}} \ No newline at end of file +{"__symbol_cache_version__":11,"b3016722acf4fd40b88be13e339d74c1":{"have":{"class":{"BitcoinABCConfiguration":13}},"need":{"class":{"ArcanistConfiguration":45,"ArcanistLintWorkflow":360},"class\/interface":{"ArcanistWorkflow":468,"ArcanistNoEffectException":261}},"xmap":{"BitcoinABCConfiguration":["ArcanistConfiguration"]}},"2809b09d2021203b43c57da33d1fe8bf":{"have":{"class":{"AssertWithSideEffectsLinter":210}},"need":{"function":{"pht":439},"class":{"ArcanistLinter":246,"ArcanistLintSeverity":926,"Filesystem":1170}},"xmap":{"AssertWithSideEffectsLinter":["ArcanistLinter"]}},"90a8b110dc475955f15bb81d37268cb5":{"have":{"class":{"AutoPEP8FormatLinter":75}},"need":{"function":{"pht":297,"execx":769,"id":1903},"class":{"ArcanistExternalLinter":104,"ArcanistLintMessage":1910,"Filesystem":1754,"ArcanistLinter":2017,"ArcanistLintSeverity":2095}},"xmap":{"AutoPEP8FormatLinter":["ArcanistExternalLinter"]}},"38f0c676bff5192a344464142caaa253":{"have":{"class":{"CHeaderLinter":99}},"need":{"function":{"pht":611},"class":{"ArcanistLinter":121,"ArcanistLintSeverity":1060,"Filesystem":1307}},"xmap":{"CHeaderLinter":["ArcanistLinter"]}},"a30e4e25376ca05d4ae719915441be9e":{"have":{"class":{"CheckDocLinter":106}},"need":{"function":{"pht":323,"id":1848},"class":{"ArcanistExternalLinter":129,"ArcanistLintMessage":1855,"Filesystem":731,"ArcanistLinter":1903,"ArcanistLintSeverity":1989}},"xmap":{"CheckDocLinter":["ArcanistExternalLinter"]}},"6af7410cfea496ff1d4dcc2624b6b8ea":{"have":{"class":{"ClangFormatLinter":79}},"need":{"function":{"pht":302,"execx":781,"id":1653},"class":{"ArcanistExternalLinter":105,"ArcanistLintMessage":1660,"Filesystem":1504,"ArcanistLinter":1767,"ArcanistLintSeverity":1845}},"xmap":{"ClangFormatLinter":["ArcanistExternalLinter"]}},"9285ad9415f8ebe564f7119e5a72c559":{"have":{"class":{"FormatStringLinter":146}},"need":{"function":{"pht":377,"csprintf":1492,"id":1872},"class":{"ArcanistExternalLinter":173,"ArcanistLintMessage":1879,"Filesystem":827,"ArcanistLinter":1956,"ArcanistLintSeverity":2044}},"xmap":{"FormatStringLinter":["ArcanistExternalLinter"]}},"224d394856b17878058b4c14acb7178b":{"have":{"class":{"LocaleDependenceLinter":160}},"need":{"function":{"pht":5400},"class":{"ArcanistLinter":191,"ArcanistLintSeverity":5903,"Filesystem":6149}},"xmap":{"LocaleDependenceLinter":["ArcanistLinter"]}},"6f2f22dd0f259fb2eaa284b4fab3bc29":{"have":{"class":{"PythonFormatLinter":123}},"need":{"function":{"pht":353,"id":1838},"class":{"ArcanistExternalLinter":150,"ArcanistLintMessage":1845,"Filesystem":776,"ArcanistLinter":1970,"ArcanistLintSeverity":2053}},"xmap":{"PythonFormatLinter":["ArcanistExternalLinter"]}},"25781df78f6eebfb223296b8265e9d19":{"have":{"class":{"TestsLinter":103}},"need":{"function":{"pht":318,"id":2629},"class":{"ArcanistExternalLinter":123,"ArcanistLintMessage":2636,"Filesystem":776,"ArcanistLinter":2684,"ArcanistLintSeverity":2792}},"xmap":{"TestsLinter":["ArcanistExternalLinter"]}},"0ab29329c5371d373da9d1ad4ff7db97":{"have":{"class":{"BitcoinABCConfigurationDrivenLintEngine":13}},"need":{"function":{"pht":383,"phutil_json_decode":700,"idx":1440,"id":4148},"class":{"ArcanistLintEngine":61,"ArcanistUsageException":351,"PhutilProxyException":789,"PhutilClassMapQuery":4155,"Filesystem":295,"PhutilTypeSpec":1067,"PhutilConsole":3620},"class\/interface":{"PhutilJSONParserException":740,"PhutilTypeCheckException":1262}},"xmap":{"BitcoinABCConfigurationDrivenLintEngine":["ArcanistLintEngine"]}},"45021061144f2a52622e3325a70c80cf":{"have":{"class":{"RunLastLintEngine":19}},"need":{"class":{"BitcoinABCConfigurationDrivenLintEngine":45}},"xmap":{"RunLastLintEngine":["BitcoinABCConfigurationDrivenLintEngine"]}}} \ No newline at end of file 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 @@ -11,6 +11,7 @@ 'class' => array( 'AssertWithSideEffectsLinter' => 'linter/AssertWithSideEffectsLinter.php', 'AutoPEP8FormatLinter' => 'linter/AutoPEP8Linter.php', + 'BitcoinABCConfiguration' => 'configuration/BitcoinABCConfiguration.php', 'BitcoinABCConfigurationDrivenLintEngine' => 'linter/engine/BitcoinABCConfigurationDrivenLintEngine.php', 'CHeaderLinter' => 'linter/CHeaderLinter.php', 'CheckDocLinter' => 'linter/CheckDocLinter.php', @@ -18,12 +19,14 @@ 'FormatStringLinter' => 'linter/FormatStringLinter.php', 'LocaleDependenceLinter' => 'linter/LocaleDependenceLinter.php', 'PythonFormatLinter' => 'linter/PythonFormatLinter.php', + 'RunLastLintEngine' => 'linter/engine/RunLastLintEngine.php', 'TestsLinter' => 'linter/TestsLinter.php', ), 'function' => array(), 'xmap' => array( 'AssertWithSideEffectsLinter' => 'ArcanistLinter', 'AutoPEP8FormatLinter' => 'ArcanistExternalLinter', + 'BitcoinABCConfiguration' => 'ArcanistConfiguration', 'BitcoinABCConfigurationDrivenLintEngine' => 'ArcanistLintEngine', 'CHeaderLinter' => 'ArcanistLinter', 'CheckDocLinter' => 'ArcanistExternalLinter', @@ -31,6 +34,7 @@ 'FormatStringLinter' => 'ArcanistExternalLinter', 'LocaleDependenceLinter' => 'ArcanistLinter', 'PythonFormatLinter' => 'ArcanistExternalLinter', + 'RunLastLintEngine' => 'BitcoinABCConfigurationDrivenLintEngine', 'TestsLinter' => 'ArcanistExternalLinter', ), )); diff --git a/arcanist/configuration/BitcoinABCConfiguration.php b/arcanist/configuration/BitcoinABCConfiguration.php new file mode 100644 --- /dev/null +++ b/arcanist/configuration/BitcoinABCConfiguration.php @@ -0,0 +1,42 @@ +buildChildWorkflow('lint', $options); + + try { + $err = $buildWorkflow ->run(); + } catch (ArcanistNoEffectException $e) { + // If there is nothing to lint, return no error + return ArcanistLintWorkflow::RESULT_OKAY; + } + + return $err; + } + + public function willRunWorkflow($command, ArcanistWorkflow $workflow) { + if ($command === 'diff' && !$workflow->getArgument('nolint')) { + $err = $this->runLint($workflow); + if ($err != ArcanistLintWorkflow::RESULT_OKAY) { + $workflow->finalize(); + exit($err); + } + + /* + * Set the configuration but don't run the linter, the diff workflow will + * do it for us. + */ + $config = $workflow->getConfigurationManager(); + $config->setRuntimeConfig('lint.engine', 'RunLastLintEngine'); + } + } + + public function didRunWorkflow($command, ArcanistWorkflow $workflow, $err) { + if ($command === 'lint') { + $config = $workflow->getConfigurationManager(); + $config->setRuntimeConfig('lint.engine', 'RunLastLintEngine'); + $this->runLint($workflow); + } + } +} diff --git a/arcanist/linter/engine/RunLastLintEngine.php b/arcanist/linter/engine/RunLastLintEngine.php new file mode 100644 --- /dev/null +++ b/arcanist/linter/engine/RunLastLintEngine.php @@ -0,0 +1,9 @@ +configurationFile = '.runlast.arclint'; + return parent::buildLinters(); + } +}