mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 08:12:40 +01:00
Respect @nolint
Summary: Respect @nolint annotations Test Plan: New "test case" Differential Revision: 41 Reviewed By: epriestley Reviewers: epriestley CC: epriestley
This commit is contained in:
parent
309609169d
commit
c83f3f6aeb
8 changed files with 130 additions and 2 deletions
|
@ -49,6 +49,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistMarkCommittedWorkflow' => 'workflow/mark-committed',
|
||||
'ArcanistNoEffectException' => 'exception/usage/noeffect',
|
||||
'ArcanistNoEngineException' => 'exception/usage/noengine',
|
||||
'ArcanistNoLintLinter' => 'lint/linter/nolint',
|
||||
'ArcanistPEP8Linter' => 'lint/linter/pep8',
|
||||
'ArcanistPatchWorkflow' => 'workflow/patch',
|
||||
'ArcanistPhutilModuleLinter' => 'lint/linter/phutilmodule',
|
||||
|
@ -98,6 +99,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistMarkCommittedWorkflow' => 'ArcanistBaseWorkflow',
|
||||
'ArcanistNoEffectException' => 'ArcanistUsageException',
|
||||
'ArcanistNoEngineException' => 'ArcanistUsageException',
|
||||
'ArcanistNoLintLinter' => 'ArcanistLinter',
|
||||
'ArcanistPEP8Linter' => 'ArcanistLinter',
|
||||
'ArcanistPatchWorkflow' => 'ArcanistBaseWorkflow',
|
||||
'ArcanistPhutilModuleLinter' => 'ArcanistLinter',
|
||||
|
|
|
@ -53,6 +53,9 @@ class PhutilLintEngine extends ArcanistLintEngine {
|
|||
$generated_linter = new ArcanistGeneratedLinter();
|
||||
$linters[] = $generated_linter;
|
||||
|
||||
$nolint_linter = new ArcanistNoLintLinter();
|
||||
$linters[] = $nolint_linter;
|
||||
|
||||
$text_linter = new ArcanistTextLinter();
|
||||
$linters[] = $text_linter;
|
||||
foreach ($paths as $path) {
|
||||
|
@ -64,6 +67,9 @@ class PhutilLintEngine extends ArcanistLintEngine {
|
|||
$generated_linter->addPath($path);
|
||||
$generated_linter->addData($path, $this->loadData($path));
|
||||
|
||||
$nolint_linter->addPath($path);
|
||||
$nolint_linter->addData($path, $this->loadData($path));
|
||||
|
||||
$text_linter->addPath($path);
|
||||
$text_linter->addData($path, $this->loadData($path));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ phutil_require_module('arcanist', 'lint/engine/base');
|
|||
phutil_require_module('arcanist', 'lint/linter/apachelicense');
|
||||
phutil_require_module('arcanist', 'lint/linter/filename');
|
||||
phutil_require_module('arcanist', 'lint/linter/generated');
|
||||
phutil_require_module('arcanist', 'lint/linter/nolint');
|
||||
phutil_require_module('arcanist', 'lint/linter/phutilmodule');
|
||||
phutil_require_module('arcanist', 'lint/linter/text');
|
||||
phutil_require_module('arcanist', 'lint/linter/xhpast');
|
||||
|
|
|
@ -1,5 +1,21 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stops other linters from running on generated code.
|
||||
*
|
||||
|
@ -26,8 +42,8 @@ class ArcanistGeneratedLinter extends ArcanistLinter {
|
|||
|
||||
public function lintPath($path) {
|
||||
$data = $this->getData($path);
|
||||
|
||||
if (preg_match('/@generated/', $data)) {
|
||||
|
||||
if (preg_match('/@'.'generated/', $data)) {
|
||||
$this->stopAllLinters();
|
||||
}
|
||||
}
|
||||
|
|
50
src/lint/linter/nolint/ArcanistNoLintLinter.php
Normal file
50
src/lint/linter/nolint/ArcanistNoLintLinter.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stops other linters from running on code marked with
|
||||
* a nolint annotation.
|
||||
*
|
||||
* @group linter
|
||||
*/
|
||||
class ArcanistNoLintLinter extends ArcanistLinter {
|
||||
public function willLintPaths(array $paths) {
|
||||
return;
|
||||
}
|
||||
|
||||
public function getLinterName() {
|
||||
return 'NOLINT';
|
||||
}
|
||||
|
||||
public function getLintSeverityMap() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getLintNameMap() {
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
public function lintPath($path) {
|
||||
$data = $this->getData($path);
|
||||
|
||||
if (preg_match('/@'.'nolint/', $data)) {
|
||||
$this->stopAllLinters();
|
||||
}
|
||||
}
|
||||
}
|
12
src/lint/linter/nolint/__init__.php
Normal file
12
src/lint/linter/nolint/__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/base');
|
||||
|
||||
|
||||
phutil_require_source('ArcanistNoLintLinter.php');
|
29
src/lint/linter/nolint/__tests__/ArcanistNoLintTestCase.php
Normal file
29
src/lint/linter/nolint/__tests__/ArcanistNoLintTestCase.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test for @{class:ArcanistNoLintLinter}.
|
||||
*
|
||||
* Not a real test... meant to fail lint
|
||||
* if @nolint is not respected.
|
||||
*
|
||||
* @group testcase
|
||||
*/
|
||||
class ArcanistNoLintTestCaseMisnamed extends ArcanistLinterTestCase {
|
||||
|
||||
}
|
12
src/lint/linter/nolint/__tests__/__init__.php
Normal file
12
src/lint/linter/nolint/__tests__/__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/base/test');
|
||||
|
||||
|
||||
phutil_require_source('ArcanistNoLintTestCase.php');
|
Loading…
Reference in a new issue