Path: blob/master/src/applications/differential/customfield/DifferentialLintField.php
12256 views
<?php12final class DifferentialLintField3extends DifferentialHarbormasterField {45public function getFieldKey() {6return 'differential:lint';7}89public function getFieldName() {10return pht('Lint');11}1213public function getFieldDescription() {14return pht('Shows lint results.');15}1617public function shouldAppearInPropertyView() {18return true;19}2021public function renderPropertyViewValue(array $handles) {22return null;23}2425public function shouldAppearInDiffPropertyView() {26return true;27}2829public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {30return $this->getFieldName();31}3233protected function getLegacyProperty() {34return 'arc:lint';35}3637protected function getDiffPropertyKeys() {38return array(39'arc:lint',40);41}4243protected function loadHarbormasterTargetMessages(array $target_phids) {44return id(new HarbormasterBuildLintMessage())->loadAllWhere(45'buildTargetPHID IN (%Ls) LIMIT 25',46$target_phids);47}4849protected function newHarbormasterMessageView(array $messages) {50return id(new HarbormasterLintPropertyView())51->setLimit(25)52->setLintMessages($messages);53}5455protected function newModernMessage(array $message) {56return HarbormasterBuildLintMessage::newFromDictionary(57new HarbormasterBuildTarget(),58$this->getModernLintMessageDictionary($message));59}6061public function getWarningsForDetailView() {62$status = $this->getObject()->getActiveDiff()->getLintStatus();63if ($status < DifferentialLintStatus::LINT_WARN) {64return array();65}66if ($status == DifferentialLintStatus::LINT_AUTO_SKIP) {67return array();68}6970$warnings = array();71if ($status == DifferentialLintStatus::LINT_SKIP) {72$warnings[] = pht(73'Lint was skipped when generating these changes.');74} else {75$warnings[] = pht('These changes have lint problems.');76}7778return $warnings;79}8081protected function renderHarbormasterStatus(82DifferentialDiff $diff,83array $messages) {8485$status_value = $diff->getLintStatus();86$status = DifferentialLintStatus::newStatusFromValue($status_value);8788$status_icon = $status->getIconIcon();89$status_color = $status->getIconColor();90$status_name = $status->getName();9192$status = id(new PHUIStatusListView())93->addItem(94id(new PHUIStatusItemView())95->setIcon($status_icon, $status_color)96->setTarget($status_name));9798return $status;99}100101private function getModernLintMessageDictionary(array $map) {102// Strip out `null` values to satisfy stricter typechecks.103foreach ($map as $key => $value) {104if ($value === null) {105unset($map[$key]);106}107}108109// TODO: We might need to remap some stuff here?110return $map;111}112113114}115116117