Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistCpplintLinter.php
| Show All 13 Lines | final class ArcanistCpplintLinter extends ArcanistExternalLinter { | ||||
| } | } | ||||
| public function getDefaultBinary() { | public function getDefaultBinary() { | ||||
| return 'cpplint'; | return 'cpplint'; | ||||
| } | } | ||||
| public function getInstallInstructions() { | public function getInstallInstructions() { | ||||
| return pht( | return pht( | ||||
| 'Install cpplint.py using `%s`.', | 'Install cpplint.py using `%s`, and place it in your path with the'. | ||||
| 'wget http://google-styleguide.googlecode.com'. | 'appropriate permissions set.', | ||||
| '/svn/trunk/cpplint/cpplint.py'); | 'wget https://raw.github.com'. | ||||
| '/google/styleguide/gh-pages/cpplint/cpplint.py'); | |||||
| } | } | ||||
| protected function getDefaultMessageSeverity($code) { | protected function getDefaultMessageSeverity($code) { | ||||
| return ArcanistLintSeverity::SEVERITY_WARNING; | return ArcanistLintSeverity::SEVERITY_WARNING; | ||||
| } | } | ||||
| protected function parseLinterOutput($path, $err, $stdout, $stderr) { | protected function parseLinterOutput($path, $err, $stdout, $stderr) { | ||||
| $lines = explode("\n", $stderr); | $lines = explode("\n", $stderr); | ||||
| $messages = array(); | $messages = array(); | ||||
| foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
| $line = trim($line); | $line = trim($line); | ||||
| $matches = null; | $matches = null; | ||||
| $regex = '/(\d+):\s*(.*)\s*\[(.*)\] \[(\d+)\]$/'; | $regex = '/(\d+):\s*(.*)\s*\[(.*)\] \[(\d+)\]$/'; | ||||
epriestley: Oh! I thought this was the regexp that was wrong. | |||||
| if (!preg_match($regex, $line, $matches)) { | if (!preg_match($regex, $line, $matches)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| foreach ($matches as $key => $match) { | foreach ($matches as $key => $match) { | ||||
| $matches[$key] = trim($match); | $matches[$key] = trim($match); | ||||
| } | } | ||||
| $severity = $this->getLintMessageSeverity($matches[3]); | $severity = $this->getLintMessageSeverity($matches[3]); | ||||
| $message = new ArcanistLintMessage(); | $message = new ArcanistLintMessage(); | ||||
| $message->setPath($path); | $message->setPath($path); | ||||
| $message->setLine($matches[1]); | $message->setLine($matches[1]); | ||||
| $message->setCode($matches[3]); | $message->setCode($matches[3]); | ||||
| $message->setName($matches[3]); | $message->setName($matches[3]); | ||||
| $message->setDescription($matches[2]); | $message->setDescription($matches[2]); | ||||
| $message->setSeverity($severity); | $message->setSeverity($severity); | ||||
| $messages[] = $message; | $messages[] = $message; | ||||
| } | } | ||||
| return $messages; | return $messages; | ||||
| } | } | ||||
| protected function getLintCodeFromLinterConfigurationKey($code) { | protected function getLintCodeFromLinterConfigurationKey($code) { | ||||
| if (!preg_match('@^[a-z_]+/[a-z_]+$@', $code)) { | if (!preg_match('@^[a-z_]+/[a-z0-9_+]+$@', $code)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'Unrecognized lint message code "%s". Expected a valid cpplint '. | 'Unrecognized lint message code "%s". Expected a valid cpplint '. | ||||
| 'lint code like "%s" or "%s".', | 'lint code like "%s" or "%s".', | ||||
| $code, | $code, | ||||
| 'build/include_order', | 'build/include_order', | ||||
| 'whitespace/braces')); | 'whitespace/braces')); | ||||
| } | } | ||||
| return $code; | return $code; | ||||
| } | } | ||||
| } | } | ||||
Oh! I thought this was the regexp that was wrong.