Display lint overview in Diffusion
Summary: I will add links from /diffusion/ARC/lint/ in future diff. Test Plan: /diffusion/ - clicked on lint messages link. /diffusion/ARC/ - clicked on lint messages link. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3926
This commit is contained in:
		| @@ -360,6 +360,7 @@ phutil_register_library_map(array( | ||||
|     'DiffusionInlineCommentPreviewController' => 'applications/diffusion/controller/DiffusionInlineCommentPreviewController.php', | ||||
|     'DiffusionLastModifiedController' => 'applications/diffusion/controller/DiffusionLastModifiedController.php', | ||||
|     'DiffusionLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionLastModifiedQuery.php', | ||||
|     'DiffusionLintController' => 'applications/diffusion/controller/DiffusionLintController.php', | ||||
|     'DiffusionMercurialBranchQuery' => 'applications/diffusion/query/branch/DiffusionMercurialBranchQuery.php', | ||||
|     'DiffusionMercurialBrowseQuery' => 'applications/diffusion/query/browse/DiffusionMercurialBrowseQuery.php', | ||||
|     'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php', | ||||
| @@ -1599,6 +1600,7 @@ phutil_register_library_map(array( | ||||
|     'DiffusionInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController', | ||||
|     'DiffusionLastModifiedController' => 'DiffusionController', | ||||
|     'DiffusionLastModifiedQuery' => 'DiffusionQuery', | ||||
|     'DiffusionLintController' => 'DiffusionController', | ||||
|     'DiffusionMercurialBranchQuery' => 'DiffusionBranchQuery', | ||||
|     'DiffusionMercurialBrowseQuery' => 'DiffusionBrowseQuery', | ||||
|     'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery', | ||||
|   | ||||
| @@ -41,6 +41,7 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication { | ||||
|           'diff/'                       => 'DiffusionDiffController', | ||||
|           'tags/(?P<dblob>.*)'          => 'DiffusionTagListController', | ||||
|           'branches/(?P<dblob>.*)'      => 'DiffusionBranchTableController', | ||||
|           'lint/(?P<dblob>.*)'          => 'DiffusionLintController', | ||||
|  | ||||
|           'commit/(?P<commit>[a-z0-9]+)/branches/' | ||||
|             => 'DiffusionCommitBranchesController', | ||||
|   | ||||
| @@ -53,6 +53,11 @@ abstract class DiffusionController extends PhabricatorController { | ||||
|     } | ||||
|  | ||||
|     $drequest = $this->getDiffusionRequest(); | ||||
|     $branch = $drequest->loadBranch(); | ||||
|  | ||||
|     if ($branch && $branch->getLintCommit()) { | ||||
|       $navs['lint'] = 'Lint View'; | ||||
|     } | ||||
|  | ||||
|     foreach ($navs as $action => $name) { | ||||
|       $href = $drequest->generateURI( | ||||
| @@ -243,6 +248,9 @@ abstract class DiffusionController extends PhabricatorController { | ||||
|       case 'browse': | ||||
|         $view_name = 'Browse'; | ||||
|         break; | ||||
|       case 'lint': | ||||
|         $view_name = 'Lint'; | ||||
|         break; | ||||
|       case 'change': | ||||
|         $view_name = 'Change'; | ||||
|         $crumb_list[] = phutil_escape_html($path).' ('.$commit_link.')'; | ||||
| @@ -306,7 +314,7 @@ abstract class DiffusionController extends PhabricatorController { | ||||
|         ), | ||||
|         'Jump to HEAD'); | ||||
|       $last_crumb .= " @ {$commit_link} ({$jump_link})"; | ||||
|     } else { | ||||
|     } else if ($spec['view'] != 'lint') { | ||||
|       $last_crumb .= " @ HEAD"; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -98,11 +98,20 @@ final class DiffusionHomeController extends DiffusionController { | ||||
|           number_format($size)); | ||||
|       } | ||||
|  | ||||
|       $lint_count = ''; | ||||
|       $lint_branches = ipull(idx($lint_messages, $id, array()), 'n', 'name'); | ||||
|       $branch = $repository->getDefaultArcanistBranch(); | ||||
|  | ||||
|       if (isset($lint_branches[$branch])) { | ||||
|         $show_lint = true; | ||||
|         $lint_count = phutil_render_tag( | ||||
|           'a', | ||||
|           array( | ||||
|             'href' => DiffusionRequest::generateDiffusionURI(array( | ||||
|               'callsign' => $repository->getCallsign(), | ||||
|               'action' => 'lint', | ||||
|             )), | ||||
|           ), | ||||
|           number_format($lint_branches[$branch])); | ||||
|       } | ||||
|  | ||||
|       $date = '-'; | ||||
| @@ -123,9 +132,7 @@ final class DiffusionHomeController extends DiffusionController { | ||||
|         PhabricatorRepositoryType::getNameForRepositoryType( | ||||
|           $repository->getVersionControlSystem()), | ||||
|         $size, | ||||
|         (isset($lint_branches[$branch]) | ||||
|           ? $lint_branches[$branch] | ||||
|           : ''), | ||||
|         $lint_count, | ||||
|         $commit | ||||
|           ? DiffusionView::linkCommit( | ||||
|               $repository, | ||||
|   | ||||
| @@ -0,0 +1,93 @@ | ||||
| <?php | ||||
| // Copyright 2004-present Facebook. All Rights Reserved. | ||||
|  | ||||
| final class DiffusionLintController extends DiffusionController { | ||||
|  | ||||
|   public function processRequest() { | ||||
|     $codes = $this->loadLintCodes(); | ||||
|     $codes = array_reverse(isort($codes, 'n')); | ||||
|  | ||||
|     $rows = array(); | ||||
|     foreach ($codes as $code) { | ||||
|       $rows[] = array( | ||||
|         $code['n'], | ||||
|         $code['files'], | ||||
|         phutil_escape_html(ArcanistLintSeverity::getStringForSeverity( | ||||
|           $code['maxSeverity'])), | ||||
|         phutil_escape_html($code['code']), | ||||
|         phutil_escape_html($code['maxName']), | ||||
|         phutil_escape_html($code['maxDescription']), | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     $table = id(new AphrontTableView($rows)) | ||||
|       ->setHeaders(array( | ||||
|         'Problems', | ||||
|         'Files', | ||||
|         'Severity', | ||||
|         'Code', | ||||
|         'Name', | ||||
|         'Example', | ||||
|       )); | ||||
|  | ||||
|     $content = array(); | ||||
|  | ||||
|     $content[] = $this->buildCrumbs( | ||||
|       array( | ||||
|         'branch' => true, | ||||
|         'path'   => true, | ||||
|         'view'   => 'lint', | ||||
|       )); | ||||
|  | ||||
|     $content[] = id(new AphrontPanelView()) | ||||
|       ->setHeader(array_sum(ipull($codes, 'n')).' Lint Messages') | ||||
|       ->appendChild($table); | ||||
|  | ||||
|     $nav = $this->buildSideNav('lint', false); | ||||
|     $nav->appendChild($content); | ||||
|  | ||||
|     return $this->buildStandardPageResponse( | ||||
|       $nav, | ||||
|       array('title' => array( | ||||
|         'Lint', | ||||
|         $this->getDiffusionRequest()->getRepository()->getCallsign(), | ||||
|       ))); | ||||
|   } | ||||
|  | ||||
|   private function loadLintCodes() { | ||||
|     $drequest = $this->getDiffusionRequest(); | ||||
|     $branch = $drequest->loadBranch(); | ||||
|     if (!$branch) { | ||||
|       return array(); | ||||
|     } | ||||
|  | ||||
|     $conn = $branch->establishConnection('r'); | ||||
|  | ||||
|     $where = ''; | ||||
|     if ($drequest->getPath() != '') { | ||||
|       $is_dir = (substr($drequest->getPath(), -1) == '/'); | ||||
|       $where = qsprintf( | ||||
|         $conn, | ||||
|         'AND path '.($is_dir ? 'LIKE %>' : '= %s'), | ||||
|         '/'.$drequest->getPath()); | ||||
|     } | ||||
|  | ||||
|     return queryfx_all( | ||||
|       $conn, | ||||
|       'SELECT | ||||
|           code, | ||||
|           MAX(severity) AS maxSeverity, | ||||
|           MAX(name) AS maxName, | ||||
|           MAX(description) AS maxDescription, | ||||
|           COUNT(DISTINCT path) AS files, | ||||
|           COUNT(*) AS n | ||||
|         FROM %T | ||||
|         WHERE branchID = %d | ||||
|         %Q | ||||
|         GROUP BY code', | ||||
|       PhabricatorRepository::TABLE_LINTMESSAGE, | ||||
|       $branch->getID(), | ||||
|       $where); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @@ -377,6 +377,7 @@ abstract class DiffusionRequest { | ||||
|       case 'lastmodified': | ||||
|       case 'tags': | ||||
|       case 'branches': | ||||
|       case 'lint': | ||||
|         $req_callsign = true; | ||||
|         break; | ||||
|       case 'branch': | ||||
| @@ -411,6 +412,7 @@ abstract class DiffusionRequest { | ||||
|       case 'lastmodified': | ||||
|       case 'tags': | ||||
|       case 'branches': | ||||
|       case 'lint': | ||||
|         $uri = "/diffusion/{$callsign}{$action}/{$path}{$commit}{$line}"; | ||||
|         break; | ||||
|       case 'branch': | ||||
|   | ||||
| @@ -81,8 +81,14 @@ final class DiffusionBrowseTableView extends DiffusionView { | ||||
|  | ||||
|     $lint = self::loadLintMessagesCount($drequest); | ||||
|     if ($lint !== null) { | ||||
|       $return['lint'] = (string)$lint; | ||||
|       $return['lint'] = phutil_render_tag( | ||||
|         'a', | ||||
|         array( | ||||
|           'href' => $drequest->generateURI(array('action' => 'lint')), | ||||
|         ), | ||||
|         number_format($lint)); | ||||
|     } | ||||
|  | ||||
|     return $return; | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 vrana
					vrana