diff --git a/arcanist/linter/AutoPEP8Linter.php b/arcanist/linter/AutoPEP8Linter.php --- a/arcanist/linter/AutoPEP8Linter.php +++ b/arcanist/linter/AutoPEP8Linter.php @@ -26,38 +26,35 @@ } public function getLinterConfigurationOptions() { - $options = array( - ); - + $options = array(); return $options + parent::getLinterConfigurationOptions(); } public function getDefaultBinary() { return 'autopep8'; } - + public function getVersion() { list($stdout, $stderr) = execx('%C --version', $this->getExecutableCommand()); $matches = array(); - + /* Support a.b or a.b.c version numbering scheme */ $regex = '/^autopep8 (?P\d+\.\d+(?:\.\d+)?)/'; - - /* + + /* * Old autopep8 output the version to stdout, newer output to stderr. * Try both to determine the version. */ if (preg_match($regex, $stdout, $matches)) { return $matches['version']; - } + } if (preg_match($regex, $stderr, $matches)) { return $matches['version']; } return false; } - public function getInstallInstructions() { return pht('Make sure autopep8 is in directory specified by $PATH'); @@ -68,8 +65,7 @@ } protected function getMandatoryFlags() { - return array( - ); + return array(); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { @@ -97,6 +93,7 @@ ->setDescription("'$path' has code style errors.") ->setOriginalText($orig) ->setReplacementText($stdout); + return array($message); } } diff --git a/arcanist/linter/CheckDocLinter.php b/arcanist/linter/CheckDocLinter.php --- a/arcanist/linter/CheckDocLinter.php +++ b/arcanist/linter/CheckDocLinter.php @@ -26,28 +26,26 @@ } public function getLinterConfigurationOptions() { - $options = array( - ); - + $options = array(); return $options + parent::getLinterConfigurationOptions(); } public function getDefaultBinary() { - return Filesystem::resolvePath( - 'test/lint/check-doc.py', + return Filesystem::resolvePath('test/lint/check-doc.py', $this->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'); + return pht('The test/lint/check-doc.py script is part of the bitcoin-abc '. + 'project'); } public function shouldExpectCommandErrors() { @@ -55,8 +53,7 @@ } protected function getMandatoryFlags() { - return array( - ); + return array(); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { @@ -68,15 +65,15 @@ * 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) { + foreach ($args[0] as $arg) { $messages[] = id(new ArcanistLintMessage()) ->setGranularity(ArcanistLinter::GRANULARITY_GLOBAL) ->setCode('ARGDOC') @@ -84,11 +81,11 @@ ->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()) + foreach ($args[0] as $arg) { + $messages[] = id(new ArcanistLintMessage()) ->setGranularity(ArcanistLinter::GRANULARITY_GLOBAL) ->setCode('ARGDOC') ->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR) @@ -99,5 +96,3 @@ return $messages; } } - -?> diff --git a/arcanist/linter/ClangFormatLinter.php b/arcanist/linter/ClangFormatLinter.php --- a/arcanist/linter/ClangFormatLinter.php +++ b/arcanist/linter/ClangFormatLinter.php @@ -26,9 +26,7 @@ } public function getLinterConfigurationOptions() { - $options = array( - ); - + $options = array(); return $options + parent::getLinterConfigurationOptions(); } @@ -57,8 +55,7 @@ } protected function getMandatoryFlags() { - return array( - ); + return array(); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { @@ -86,6 +83,7 @@ ->setDescription("'$path' has code style errors.") ->setOriginalText($orig) ->setReplacementText($stdout); + return array($message); } } diff --git a/arcanist/linter/LocalDependenceLinter.php b/arcanist/linter/LocalDependenceLinter.php --- a/arcanist/linter/LocalDependenceLinter.php +++ b/arcanist/linter/LocalDependenceLinter.php @@ -5,7 +5,7 @@ * functions relying on the system locale are used. */ final class LocaleDependenceLinter extends ArcanistExternalLinter { - + const ADVICE_MESSAGE = <<getProjectRoot()); } - + public function shouldUseInterpreter() { return true; } - + public function getDefaultInterpreter() { return "bash"; } - + public function getInstallInstructions() { - return pht('The test/lint/lint-locale-dependence.sh script is part of the - bitcoin-abc project. Requires git >= 2.6.5.'); + return pht('The test/lint/lint-locale-dependence.sh script is part of the '. + 'bitcoin-abc project. Requires git >= 2.6.5.'); } public function shouldExpectCommandErrors() { @@ -63,8 +61,7 @@ } protected function getMandatoryFlags() { - return array( - ); + return array(); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { @@ -76,13 +73,13 @@ * : * 2/ Section with a general warning, will not be used by Arcanist. Instead * we define our own advice message. - * + * * First a list of the locale dependent functions will be determined, then * the code lines containing these functions. - * An linting error message is generated for each line of code. + * A linting error message is generated for each line of code. */ - /* + /* * Extract infos from the path */ $pathinfo = pathinfo($path); @@ -92,25 +89,35 @@ /* Find the functions */ $pattern = '/The locale dependent function (\w+)\(...\)/'; - if (!preg_match_all($pattern, $stdout, $matches, $flags = PREG_SET_ORDER)) { + if (!preg_match_all( + $pattern, + $stdout, + $matches, + $flags = PREG_SET_ORDER + )) { return $messages; } $functions = []; - foreach($matches as $match) { + foreach ($matches as $match) { $functions[] = $match[1]; } /* Find the code lines */ $pattern = '/'.$fileName.':(\d+): (.+)/'; - if (preg_match_all($pattern, $stdout, $matches, $flags = PREG_SET_ORDER)) { + if (preg_match_all( + $pattern, + $stdout, + $matches, + $flags = PREG_SET_ORDER + )) { foreach ($matches as $match) { list(, $lineNumber, $codeSnippet) = $match; - + /* Determine which function is used */ $functionUsed = ''; - foreach($functions as $function) { - if (strpos($codeSnippet, $function) !== FALSE) { + foreach ($functions as $function) { + if (strpos($codeSnippet, $function) !== false) { $functionUsed = $function; break; } diff --git a/arcanist/linter/PythonFormatLinter.php b/arcanist/linter/PythonFormatLinter.php --- a/arcanist/linter/PythonFormatLinter.php +++ b/arcanist/linter/PythonFormatLinter.php @@ -1,7 +1,7 @@ getProjectRoot()); } - + public function shouldUseInterpreter() { return true; } - + public function getDefaultInterpreter() { return "python3"; } public function getInstallInstructions() { - return pht('The test/lint/lint-python-format.py script is part of the bitcoin-abc project'); + return pht('The test/lint/lint-python-format.py script is part of the '. + 'bitcoin-abc project'); } public function shouldExpectCommandErrors() { @@ -62,8 +61,8 @@ $pattern = '/\((\d+)\) ([\s\S]+?)=> (.+)/'; $found = preg_match_all($pattern, $stdout, $snippets, $flags = PREG_SET_ORDER); - - /* + + /* * Matched snippets $snippets are organized like this: * [0] The complete mask * [1] The line number @@ -89,7 +88,7 @@ ->setOriginalText(rtrim($snippet[2])) ->setReplacementText($snippet[3]); } - + return $messages; } -} \ No newline at end of file +} diff --git a/arcanist/linter/TestsLinter.php b/arcanist/linter/TestsLinter.php --- a/arcanist/linter/TestsLinter.php +++ b/arcanist/linter/TestsLinter.php @@ -15,7 +15,7 @@ public function getInfoDescription() { return pht('Check the unit tests for duplicates and ensure the file name '. - 'matches the boost test suite name.'); + 'matches the boost test suite name.'); } public function getLinterName() { @@ -27,29 +27,26 @@ } public function getLinterConfigurationOptions() { - $options = array( - ); - + $options = array(); return $options + parent::getLinterConfigurationOptions(); } public function getDefaultBinary() { - return Filesystem::resolvePath( - 'test/lint/lint-tests.sh', + return Filesystem::resolvePath('test/lint/lint-tests.sh', $this->getProjectRoot()); } - + public function shouldUseInterpreter() { return true; } - + public function getDefaultInterpreter() { return "bash"; } - + public function getInstallInstructions() { return pht('The test/lint/lint-tests.sh script is part of the bitcoin-abc '. - 'project'); + 'project'); } public function shouldExpectCommandErrors() { @@ -57,8 +54,7 @@ } protected function getMandatoryFlags() { - return array( - ); + return array(); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { @@ -70,9 +66,9 @@ * */ - /* + /* * Extract infos from the path - * + * * Note: the files are already filtered by path thanks to the .arclint * configuration. If the file is not a test, the grep will find nothing and * there will be no error to parse. @@ -88,7 +84,7 @@ $mismatch = preg_match($pattern, $stdout, $matches); if ($mismatch) { - /* + /* * Expect a single result as we are testing against a single file. * - $matches[0] contains the full mask * - $matches[1] contains the captured match @@ -96,7 +92,7 @@ if (count($matches) != 2) { throw new Exception( pht('Found multiple matches for a single file, lint-tests.sh output '. - 'is not formatted as expected, aborting.')); + 'is not formatted as expected, aborting.')); } $mismatchName = $matches[1]; @@ -111,7 +107,7 @@ $mismatchName.'", should be "'.$testName.'").'); } - /* + /* * Search for unicity, searching for test name alone on its line. * The test name can be whether the one extracted from the file name or the * one extracted from the BOOST_FIXTURE_TEST_SUITE content. @@ -130,7 +126,7 @@ * possibly return an output matching our expected test name AND our actual * test name. This would be weird, but not impossible. * Just returning an error for the first one is enough, as the linter will - * be rerun after the name is fix and the other match will then eventually + * be rerun after the name is fix and the other match will then eventually * get catched. */ @@ -147,5 +143,3 @@ return $messages; } } - -?>