2012-11-09 01:13:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionLintDetailsController extends DiffusionController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$limit = 500;
|
|
|
|
$offset = $this->getRequest()->getInt('offset', 0);
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2012-11-10 02:45:19 +01:00
|
|
|
$branch = $drequest->loadBranch();
|
|
|
|
$messages = $this->loadLintMessages($branch, $limit, $offset);
|
2012-11-09 01:13:21 +01:00
|
|
|
$is_dir = (substr('/'.$drequest->getPath(), -1) == '/');
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($messages as $message) {
|
|
|
|
$path = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'lint',
|
|
|
|
'path' => $message['path'],
|
|
|
|
)),
|
|
|
|
substr($message['path'], strlen($drequest->getPath()) + 1));
|
|
|
|
|
|
|
|
$line = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'path' => $message['path'],
|
|
|
|
'line' => $message['line'],
|
2012-11-10 02:45:19 +01:00
|
|
|
'commit' => $branch->getLintCommit(),
|
2012-11-09 01:13:21 +01:00
|
|
|
)),
|
|
|
|
$message['line']);
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
$path,
|
|
|
|
$line,
|
2013-02-13 23:50:15 +01:00
|
|
|
ArcanistLintSeverity::getStringForSeverity($message['severity']),
|
|
|
|
$message['name'],
|
|
|
|
$message['description'],
|
2012-11-09 01:13:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(array(
|
|
|
|
'Path',
|
|
|
|
'Line',
|
|
|
|
'Severity',
|
|
|
|
'Name',
|
2012-11-10 02:45:19 +01:00
|
|
|
'Description',
|
2012-11-09 01:13:21 +01:00
|
|
|
))
|
2012-11-10 02:45:19 +01:00
|
|
|
->setColumnClasses(array('', 'n', '', '', ''))
|
|
|
|
->setColumnVisibility(array($is_dir));
|
2012-11-09 01:13:21 +01:00
|
|
|
|
|
|
|
$content = array();
|
|
|
|
|
|
|
|
$pager = id(new AphrontPagerView())
|
|
|
|
->setPageSize($limit)
|
|
|
|
->setOffset($offset)
|
|
|
|
->setHasMorePages(count($messages) >= $limit)
|
|
|
|
->setURI($this->getRequest()->getRequestURI(), 'offset');
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
$lint = $drequest->getLint();
|
|
|
|
$link = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'lint',
|
|
|
|
'lint' => null,
|
|
|
|
)),
|
|
|
|
pht('Switch to Grouped View'));
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
$content[] = id(new AphrontPanelView())
|
2012-11-10 02:45:19 +01:00
|
|
|
->setHeader(
|
2013-02-13 23:50:15 +01:00
|
|
|
($lint != '' ? $lint." \xC2\xB7 " : '').
|
2012-11-10 02:45:19 +01:00
|
|
|
pht('%d Lint Message(s)', count($messages)))
|
|
|
|
->setCaption($link)
|
2012-11-09 01:13:21 +01:00
|
|
|
->appendChild($table)
|
|
|
|
->appendChild($pager);
|
|
|
|
|
|
|
|
$nav = $this->buildSideNav('lint', false);
|
|
|
|
$nav->appendChild($content);
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'lint',
|
|
|
|
));
|
|
|
|
$nav->setCrumbs($crumbs);
|
2012-11-09 01:13:21 +01:00
|
|
|
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
return $this->buildApplicationPage(
|
2012-11-09 01:13:21 +01:00
|
|
|
$nav,
|
|
|
|
array('title' => array(
|
|
|
|
'Lint',
|
|
|
|
$drequest->getRepository()->getCallsign(),
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
private function loadLintMessages(
|
|
|
|
PhabricatorRepositoryBranch $branch,
|
|
|
|
$limit,
|
|
|
|
$offset) {
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
if (!$branch) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$conn = $branch->establishConnection('r');
|
|
|
|
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$where = array(
|
2013-02-04 00:04:15 +01:00
|
|
|
qsprintf($conn, 'branchID = %d', $branch->getID()),
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
);
|
2013-02-04 00:04:15 +01:00
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
if ($drequest->getPath() != '') {
|
2013-02-04 00:04:15 +01:00
|
|
|
$path = '/'.$drequest->getPath();
|
|
|
|
$is_dir = (substr($path, -1) == '/');
|
|
|
|
$where[] = ($is_dir
|
|
|
|
? qsprintf($conn, 'path LIKE %>', $path)
|
|
|
|
: qsprintf($conn, 'path = %s', $path));
|
2012-11-09 01:13:21 +01:00
|
|
|
}
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
if ($drequest->getLint() != '') {
|
|
|
|
$where[] = qsprintf(
|
|
|
|
$conn,
|
|
|
|
'code = %s',
|
|
|
|
$drequest->getLint());
|
|
|
|
}
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
return queryfx_all(
|
|
|
|
$conn,
|
|
|
|
'SELECT *
|
|
|
|
FROM %T
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
WHERE %Q
|
|
|
|
ORDER BY path, code, line LIMIT %d OFFSET %d',
|
2012-11-09 01:13:21 +01:00
|
|
|
PhabricatorRepository::TABLE_LINTMESSAGE,
|
2012-11-10 02:45:19 +01:00
|
|
|
implode(' AND ', $where),
|
2012-11-09 01:13:21 +01:00
|
|
|
$limit,
|
|
|
|
$offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|