1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Add a custom lint name hook to Phabricator

Summary: Allow Conduit method so they stop raising lint warnings. See D874.

Test Plan: Ran "arc lint" on conduit files and was no longer given frivolous
warnings.

Reviewers: nh, jungejason, tuomaspelkonen, aran

Reviewed By: nh

CC: aran, nh, epriestley

Differential Revision: 875
This commit is contained in:
epriestley 2011-08-30 13:12:20 -07:00
parent 0e40b3c5b2
commit 5908a63dfe
4 changed files with 55 additions and 1 deletions

View file

@ -7,5 +7,6 @@
"remote_hooks_installed" : true, "remote_hooks_installed" : true,
"phutil_libraries" : { "phutil_libraries" : {
"phabricator" : "src/" "phabricator" : "src/"
} },
"lint.xhpast.naminghook" : "PhabricatorSymbolNameLinter"
} }

View file

@ -614,6 +614,7 @@ phutil_register_library_map(array(
'PhabricatorSlowvotePollController' => 'applications/slowvote/controller/poll', 'PhabricatorSlowvotePollController' => 'applications/slowvote/controller/poll',
'PhabricatorStandardPageView' => 'view/page/standard', 'PhabricatorStandardPageView' => 'view/page/standard',
'PhabricatorStatusController' => 'applications/status/base', 'PhabricatorStatusController' => 'applications/status/base',
'PhabricatorSymbolNameLinter' => 'infrastructure/lint/hook/xhpastsymbolname',
'PhabricatorSyntaxHighlighter' => 'applications/markup/syntax', 'PhabricatorSyntaxHighlighter' => 'applications/markup/syntax',
'PhabricatorTaskmasterDaemon' => 'infrastructure/daemon/workers/taskmaster', 'PhabricatorTaskmasterDaemon' => 'infrastructure/daemon/workers/taskmaster',
'PhabricatorTestCase' => 'infrastructure/testing/testcase', 'PhabricatorTestCase' => 'infrastructure/testing/testcase',
@ -1195,6 +1196,7 @@ phutil_register_library_map(array(
'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController', 'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController',
'PhabricatorStandardPageView' => 'AphrontPageView', 'PhabricatorStandardPageView' => 'AphrontPageView',
'PhabricatorStatusController' => 'PhabricatorController', 'PhabricatorStatusController' => 'PhabricatorController',
'PhabricatorSymbolNameLinter' => 'ArcanistXHPASTLintNamingHook',
'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon', 'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon',
'PhabricatorTestCase' => 'ArcanistPhutilTestCase', 'PhabricatorTestCase' => 'ArcanistPhutilTestCase',
'PhabricatorTimelineCursor' => 'PhabricatorTimelineDAO', 'PhabricatorTimelineCursor' => 'PhabricatorTimelineDAO',

View file

@ -0,0 +1,39 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorSymbolNameLinter extends ArcanistXHPASTLintNamingHook {
public function lintSymbolName($type, $name, $default) {
$matches = null;
if ($type == 'class' &&
preg_match('/^ConduitAPI_(.*)_Method$/', $name, $matches)) {
if (preg_match('/^[a-z]+(_[a-z]+)?$/', $matches[1])) {
// These are permitted since Conduit does reflectioney stuff to figure
// out the method name from the class name.
return null;
} else {
return 'Conduit method implementations should contain lowercase '.
'letters only, with an underscore separating group and method '.
'names for implementations, e.g. '.
'"ConduitAPI_thing_info_Method".';
}
}
return $default;
}
}

View file

@ -0,0 +1,12 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('arcanist', 'lint/linter/xhpast/naminghook');
phutil_require_source('PhabricatorSymbolNameLinter.php');