From 25ee39b657b89f907e47be04b7c43542cfa8ee4e Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 27 May 2020 10:49:31 -0700 Subject: [PATCH] In the "cpplint" binding, raise messages on "line 0" without a line Summary: Ref T13543. The "cpplint.py" script may emit messages on line 0, but Arcanist doesn't accept these messages. This is a small piece of a whole set of broader issues, but stop the bleeding for now. Test Plan: - Ran `arc lint example.h` on a file with no `#ifndef` guard, and `cpplint` configured. - Cpplint raised a message at line "0". - Before change: arc choked when trying to render this. - After change: arc survives rendering. Maniphest Tasks: T13543 Differential Revision: https://secure.phabricator.com/D21289 --- src/lint/linter/ArcanistCpplintLinter.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 @@ -48,12 +48,22 @@ final class ArcanistCpplintLinter extends ArcanistExternalLinter { $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; }