2014-02-27 20:06:37 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialLintField
|
2015-06-23 22:33:09 +02:00
|
|
|
extends DifferentialHarbormasterField {
|
2014-02-27 20:06:37 +01:00
|
|
|
|
|
|
|
public function getFieldKey() {
|
|
|
|
return 'differential:lint';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldName() {
|
|
|
|
return pht('Lint');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldDescription() {
|
|
|
|
return pht('Shows lint results.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInPropertyView() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-16 17:53:40 +02:00
|
|
|
public function renderPropertyViewValue(array $handles) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInDiffPropertyView() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {
|
2014-02-27 20:06:37 +01:00
|
|
|
return $this->getFieldName();
|
|
|
|
}
|
|
|
|
|
2015-06-23 22:33:09 +02:00
|
|
|
protected function getLegacyProperty() {
|
|
|
|
return 'arc:lint';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getDiffPropertyKeys() {
|
|
|
|
return array(
|
2014-02-27 20:06:37 +01:00
|
|
|
'arc:lint',
|
|
|
|
'arc:lint-excuse',
|
|
|
|
);
|
2015-06-23 22:33:09 +02:00
|
|
|
}
|
2014-02-27 20:06:37 +01:00
|
|
|
|
2015-06-23 22:33:09 +02:00
|
|
|
protected function loadHarbormasterTargetMessages(array $target_phids) {
|
|
|
|
return id(new HarbormasterBuildLintMessage())->loadAllWhere(
|
|
|
|
'buildTargetPHID IN (%Ls) LIMIT 25',
|
|
|
|
$target_phids);
|
|
|
|
}
|
2015-06-21 19:11:53 +02:00
|
|
|
|
2015-06-23 22:33:09 +02:00
|
|
|
protected function newHarbormasterMessageView(array $messages) {
|
|
|
|
return id(new HarbormasterLintPropertyView())
|
2015-06-23 22:34:25 +02:00
|
|
|
->setLimit(25)
|
2015-06-23 22:33:09 +02:00
|
|
|
->setLintMessages($messages);
|
|
|
|
}
|
2014-02-27 20:06:37 +01:00
|
|
|
|
2015-06-23 22:33:09 +02:00
|
|
|
protected function newModernMessage(array $message) {
|
|
|
|
return HarbormasterBuildLintMessage::newFromDictionary(
|
|
|
|
new HarbormasterBuildTarget(),
|
|
|
|
$this->getModernLintMessageDictionary($message));
|
2014-02-27 20:06:37 +01:00
|
|
|
}
|
2014-03-09 21:18:17 +01:00
|
|
|
|
|
|
|
public function getWarningsForDetailView() {
|
|
|
|
$status = $this->getObject()->getActiveDiff()->getLintStatus();
|
|
|
|
if ($status < DifferentialLintStatus::LINT_WARN) {
|
|
|
|
return array();
|
|
|
|
}
|
2014-09-16 21:11:54 +02:00
|
|
|
if ($status == DifferentialLintStatus::LINT_AUTO_SKIP) {
|
|
|
|
return array();
|
|
|
|
}
|
2014-03-09 21:18:17 +01:00
|
|
|
|
|
|
|
$warnings = array();
|
|
|
|
if ($status == DifferentialLintStatus::LINT_SKIP) {
|
|
|
|
$warnings[] = pht(
|
|
|
|
'Lint was skipped when generating these changes.');
|
|
|
|
} else {
|
|
|
|
$warnings[] = pht('These changes have lint problems.');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $warnings;
|
|
|
|
}
|
|
|
|
|
2015-06-23 22:33:09 +02:00
|
|
|
protected function renderHarbormasterStatus(
|
|
|
|
DifferentialDiff $diff,
|
|
|
|
array $messages) {
|
|
|
|
|
2015-06-21 19:11:53 +02:00
|
|
|
$colors = array(
|
|
|
|
DifferentialLintStatus::LINT_NONE => 'grey',
|
|
|
|
DifferentialLintStatus::LINT_OKAY => 'green',
|
|
|
|
DifferentialLintStatus::LINT_WARN => 'yellow',
|
|
|
|
DifferentialLintStatus::LINT_FAIL => 'red',
|
|
|
|
DifferentialLintStatus::LINT_SKIP => 'blue',
|
|
|
|
DifferentialLintStatus::LINT_AUTO_SKIP => 'blue',
|
|
|
|
);
|
|
|
|
$icon_color = idx($colors, $diff->getLintStatus(), 'grey');
|
|
|
|
|
|
|
|
$message = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff);
|
|
|
|
|
|
|
|
$excuse = $diff->getProperty('arc:lint-excuse');
|
|
|
|
if (strlen($excuse)) {
|
|
|
|
$excuse = array(
|
|
|
|
phutil_tag('strong', array(), pht('Excuse:')),
|
|
|
|
' ',
|
|
|
|
phutil_escape_html_newlines($excuse),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$status = id(new PHUIStatusListView())
|
|
|
|
->addItem(
|
|
|
|
id(new PHUIStatusItemView())
|
|
|
|
->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color)
|
|
|
|
->setTarget($message)
|
|
|
|
->setNote($excuse));
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getModernLintMessageDictionary(array $map) {
|
2015-06-21 19:37:55 +02:00
|
|
|
// Strip out `null` values to satisfy stricter typechecks.
|
|
|
|
foreach ($map as $key => $value) {
|
|
|
|
if ($value === null) {
|
|
|
|
unset($map[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-21 19:11:53 +02:00
|
|
|
// TODO: We might need to remap some stuff here?
|
|
|
|
return $map;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-27 20:06:37 +01:00
|
|
|
}
|