1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-27 06:58:17 +01:00
phorge-phorge/src/applications/harbormaster/view/HarbormasterLintPropertyView.php
epriestley e618b672d2 Render lint results as Harbormaster lint messages
Summary:
Ref T8095. Render lint results in a future-ready way.

This makes the renderer accept `HarbormasterBuildLintMessage` objects. If we have legacy data instead, it converts it into `HarbormasterBuildLintMessage` objects.

Design is a bit rough but will be cleaned up later after T7739.

This moves away from "postponed linters", which are obsolete after Harbormaster (and were only ever used by Facebook).

Test Plan: {F523429}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8095

Differential Revision: https://secure.phabricator.com/D13377
2015-06-23 10:23:28 -07:00

78 lines
1.6 KiB
PHP

<?php
final class HarbormasterLintPropertyView extends AphrontView {
private $pathURIMap;
private $lintMessages = array();
public function setPathURIMap(array $map) {
$this->pathURIMap = $map;
return $this;
}
public function setLintMessages(array $messages) {
assert_instances_of($messages, 'HarbormasterBuildLintMessage');
$this->lintMessages = $messages;
return $this;
}
public function render() {
$rows = array();
foreach ($this->lintMessages as $message) {
$path = $message->getPath();
$line = $message->getLine();
$href = null;
if (strlen(idx($this->pathURIMap, $path))) {
$href = $this->pathURIMap[$path].max($line, 1);
}
$severity = $this->renderSeverity($message->getSeverity());
$location = $path.':'.$line;
if (strlen($href)) {
$location = phutil_tag(
'a',
array(
'href' => $href,
),
$location);
}
$rows[] = array(
$location,
$severity,
$message->getCode(),
$message->getName(),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Location'),
pht('Severity'),
pht('Code'),
pht('Message'),
))
->setColumnClasses(
array(
'pri',
null,
null,
'wide',
));
return $table;
}
private function renderSeverity($severity) {
$names = ArcanistLintSeverity::getLintSeverities();
$name = idx($names, $severity, $severity);
// TODO: Add some color here?
return $name;
}
}