if (!ArcanistLintSeverity::isAtLeastAsSevere($message, $minimum)) {
continue;
}
- // When a user runs "arc lint", we default to raising only warnings on
- // lines they have changed (errors are still raised anywhere in the
- // file). The list of $changed lines may be null, to indicate that the
- // path is a directory or a binary file so we should not exclude
- // warnings.
- $changed = $this->getPathChangedLines($message->getPath());
- if ($changed !== null && !$message->isError() && $message->getLine()) {
- if (empty($changed[$message->getLine()])) {
- continue;
- }
+ if (!$this->isRelevantMessage($message)) {
+ continue;
}
$result = $this->getResultForPath($message->getPath());
$result->addMessage($message);
abstract protected function buildLinters();
+ private function isRelevantMessage($message) {
+ // When a user runs "arc lint", we default to raising only warnings on
+ // lines they have changed (errors are still raised anywhere in the
+ // file). The list of $changed lines may be null, to indicate that the
+ // path is a directory or a binary file so we should not exclude
+ // warnings.
+
+ $changed = $this->getPathChangedLines($message->getPath());
+
+ if ($changed === null || $message->isError() || !$message->getLine()) {
+ return true;
+ }
+
+ $last_line = $message->getLine();
+ if ($message->getOriginalText()) {
+ $last_line += substr_count($message->getOriginalText(), "\n");
+ }
+
+ for ($l = $message->getLine(); $l <= $last_line; $l++) {
+ if (!empty($changed[$l])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
private function getResultForPath($path) {
if (empty($this->results[$path])) {
$result = new ArcanistLintResult();