mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 07:20:57 +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:
parent
0e40b3c5b2
commit
5908a63dfe
4 changed files with 55 additions and 1 deletions
|
@ -7,5 +7,6 @@
|
|||
"remote_hooks_installed" : true,
|
||||
"phutil_libraries" : {
|
||||
"phabricator" : "src/"
|
||||
}
|
||||
},
|
||||
"lint.xhpast.naminghook" : "PhabricatorSymbolNameLinter"
|
||||
}
|
||||
|
|
|
@ -614,6 +614,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSlowvotePollController' => 'applications/slowvote/controller/poll',
|
||||
'PhabricatorStandardPageView' => 'view/page/standard',
|
||||
'PhabricatorStatusController' => 'applications/status/base',
|
||||
'PhabricatorSymbolNameLinter' => 'infrastructure/lint/hook/xhpastsymbolname',
|
||||
'PhabricatorSyntaxHighlighter' => 'applications/markup/syntax',
|
||||
'PhabricatorTaskmasterDaemon' => 'infrastructure/daemon/workers/taskmaster',
|
||||
'PhabricatorTestCase' => 'infrastructure/testing/testcase',
|
||||
|
@ -1195,6 +1196,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController',
|
||||
'PhabricatorStandardPageView' => 'AphrontPageView',
|
||||
'PhabricatorStatusController' => 'PhabricatorController',
|
||||
'PhabricatorSymbolNameLinter' => 'ArcanistXHPASTLintNamingHook',
|
||||
'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon',
|
||||
'PhabricatorTestCase' => 'ArcanistPhutilTestCase',
|
||||
'PhabricatorTimelineCursor' => 'PhabricatorTimelineDAO',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
12
src/infrastructure/lint/hook/xhpastsymbolname/__init__.php
Normal file
12
src/infrastructure/lint/hook/xhpastsymbolname/__init__.php
Normal 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');
|
Loading…
Reference in a new issue