diff --git a/src/lint/linter/ArcanistCpplintLinter.php b/src/lint/linter/ArcanistCpplintLinter.php index f9c6ddf5..4559ec47 100644 --- a/src/lint/linter/ArcanistCpplintLinter.php +++ b/src/lint/linter/ArcanistCpplintLinter.php @@ -1,77 +1,87 @@ $match) { $matches[$key] = trim($match); } $severity = $this->getLintMessageSeverity($matches[3]); $message = new ArcanistLintMessage(); $message->setPath($path); - $message->setLine($matches[1]); $message->setCode($matches[3]); $message->setName($matches[3]); $message->setDescription($matches[2]); $message->setSeverity($severity); + // NOTE: "cpplint" raises some messages which apply to the whole file, + // like "no #ifndef guard found". It raises these messages on line 0. + + // Arcanist messages should have a "null" line, not a "0" line, if they + // aren't bound to a particular line number. + + $line = (int)$matches[1]; + if ($line > 0) { + $message->setLine($line); + } + $messages[] = $message; } return $messages; } protected function getLintCodeFromLinterConfigurationKey($code) { if (!preg_match('@^[a-z_]+/[a-z0-9_+]+$@', $code)) { throw new Exception( pht( 'Unrecognized lint message code "%s". Expected a valid cpplint '. 'lint code like "%s" or "%s".', $code, 'build/include_order', 'whitespace/braces')); } return $code; } }