Path: blob/master/src/applications/harbormaster/view/HarbormasterLintPropertyView.php
12256 views
<?php12final class HarbormasterLintPropertyView extends AphrontView {34private $pathURIMap = array();5private $lintMessages = array();6private $limit;78public function setPathURIMap(array $map) {9$this->pathURIMap = $map;10return $this;11}1213public function setLintMessages(array $messages) {14assert_instances_of($messages, 'HarbormasterBuildLintMessage');15$this->lintMessages = $messages;16return $this;17}1819public function setLimit($limit) {20$this->limit = $limit;21return $this;22}2324public function render() {25$messages = $this->lintMessages;26$messages = msort($messages, 'getSortKey');2728if ($this->limit) {29$messages = array_slice($messages, 0, $this->limit);30}3132$rows = array();33foreach ($messages as $message) {34$path = $message->getPath();35$line = $message->getLine();3637$href = null;38if (strlen(idx($this->pathURIMap, $path))) {39$href = $this->pathURIMap[$path].max($line, 1);40}4142$severity = $this->renderSeverity($message->getSeverity());4344$location = $path.':'.$line;45if (strlen($href)) {46$location = phutil_tag(47'a',48array(49'href' => $href,50),51$location);52}5354$rows[] = array(55$severity,56$location,57$message->getCode(),58$message->getName(),59);60}6162$table = id(new AphrontTableView($rows))63->setHeaders(64array(65pht('Severity'),66pht('Location'),67pht('Code'),68pht('Message'),69))70->setColumnClasses(71array(72null,73'pri',74null,75'wide',76));7778return $table;79}8081private function renderSeverity($severity) {82$names = ArcanistLintSeverity::getLintSeverities();83$name = idx($names, $severity, $severity);8485// TODO: Add some color here?8687return $name;88}8990}919293