Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/view/HarbormasterLintPropertyView.php
12256 views
1
<?php
2
3
final class HarbormasterLintPropertyView extends AphrontView {
4
5
private $pathURIMap = array();
6
private $lintMessages = array();
7
private $limit;
8
9
public function setPathURIMap(array $map) {
10
$this->pathURIMap = $map;
11
return $this;
12
}
13
14
public function setLintMessages(array $messages) {
15
assert_instances_of($messages, 'HarbormasterBuildLintMessage');
16
$this->lintMessages = $messages;
17
return $this;
18
}
19
20
public function setLimit($limit) {
21
$this->limit = $limit;
22
return $this;
23
}
24
25
public function render() {
26
$messages = $this->lintMessages;
27
$messages = msort($messages, 'getSortKey');
28
29
if ($this->limit) {
30
$messages = array_slice($messages, 0, $this->limit);
31
}
32
33
$rows = array();
34
foreach ($messages as $message) {
35
$path = $message->getPath();
36
$line = $message->getLine();
37
38
$href = null;
39
if (strlen(idx($this->pathURIMap, $path))) {
40
$href = $this->pathURIMap[$path].max($line, 1);
41
}
42
43
$severity = $this->renderSeverity($message->getSeverity());
44
45
$location = $path.':'.$line;
46
if (strlen($href)) {
47
$location = phutil_tag(
48
'a',
49
array(
50
'href' => $href,
51
),
52
$location);
53
}
54
55
$rows[] = array(
56
$severity,
57
$location,
58
$message->getCode(),
59
$message->getName(),
60
);
61
}
62
63
$table = id(new AphrontTableView($rows))
64
->setHeaders(
65
array(
66
pht('Severity'),
67
pht('Location'),
68
pht('Code'),
69
pht('Message'),
70
))
71
->setColumnClasses(
72
array(
73
null,
74
'pri',
75
null,
76
'wide',
77
));
78
79
return $table;
80
}
81
82
private function renderSeverity($severity) {
83
$names = ArcanistLintSeverity::getLintSeverities();
84
$name = idx($names, $severity, $severity);
85
86
// TODO: Add some color here?
87
88
return $name;
89
}
90
91
}
92
93