Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/customfield/DifferentialLintField.php
12256 views
1
<?php
2
3
final class DifferentialLintField
4
extends DifferentialHarbormasterField {
5
6
public function getFieldKey() {
7
return 'differential:lint';
8
}
9
10
public function getFieldName() {
11
return pht('Lint');
12
}
13
14
public function getFieldDescription() {
15
return pht('Shows lint results.');
16
}
17
18
public function shouldAppearInPropertyView() {
19
return true;
20
}
21
22
public function renderPropertyViewValue(array $handles) {
23
return null;
24
}
25
26
public function shouldAppearInDiffPropertyView() {
27
return true;
28
}
29
30
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {
31
return $this->getFieldName();
32
}
33
34
protected function getLegacyProperty() {
35
return 'arc:lint';
36
}
37
38
protected function getDiffPropertyKeys() {
39
return array(
40
'arc:lint',
41
);
42
}
43
44
protected function loadHarbormasterTargetMessages(array $target_phids) {
45
return id(new HarbormasterBuildLintMessage())->loadAllWhere(
46
'buildTargetPHID IN (%Ls) LIMIT 25',
47
$target_phids);
48
}
49
50
protected function newHarbormasterMessageView(array $messages) {
51
return id(new HarbormasterLintPropertyView())
52
->setLimit(25)
53
->setLintMessages($messages);
54
}
55
56
protected function newModernMessage(array $message) {
57
return HarbormasterBuildLintMessage::newFromDictionary(
58
new HarbormasterBuildTarget(),
59
$this->getModernLintMessageDictionary($message));
60
}
61
62
public function getWarningsForDetailView() {
63
$status = $this->getObject()->getActiveDiff()->getLintStatus();
64
if ($status < DifferentialLintStatus::LINT_WARN) {
65
return array();
66
}
67
if ($status == DifferentialLintStatus::LINT_AUTO_SKIP) {
68
return array();
69
}
70
71
$warnings = array();
72
if ($status == DifferentialLintStatus::LINT_SKIP) {
73
$warnings[] = pht(
74
'Lint was skipped when generating these changes.');
75
} else {
76
$warnings[] = pht('These changes have lint problems.');
77
}
78
79
return $warnings;
80
}
81
82
protected function renderHarbormasterStatus(
83
DifferentialDiff $diff,
84
array $messages) {
85
86
$status_value = $diff->getLintStatus();
87
$status = DifferentialLintStatus::newStatusFromValue($status_value);
88
89
$status_icon = $status->getIconIcon();
90
$status_color = $status->getIconColor();
91
$status_name = $status->getName();
92
93
$status = id(new PHUIStatusListView())
94
->addItem(
95
id(new PHUIStatusItemView())
96
->setIcon($status_icon, $status_color)
97
->setTarget($status_name));
98
99
return $status;
100
}
101
102
private function getModernLintMessageDictionary(array $map) {
103
// Strip out `null` values to satisfy stricter typechecks.
104
foreach ($map as $key => $value) {
105
if ($value === null) {
106
unset($map[$key]);
107
}
108
}
109
110
// TODO: We might need to remap some stuff here?
111
return $map;
112
}
113
114
115
}
116
117