'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',
'ArcanistMarkCommittedWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistNoEffectException' => 'ArcanistUsageException',
'ArcanistNoEngineException' => 'ArcanistUsageException',
+ 'ArcanistNoLintLinter' => 'ArcanistLinter',
'ArcanistPEP8Linter' => 'ArcanistLinter',
'ArcanistPatchWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistPhutilModuleLinter' => 'ArcanistLinter',
$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) {
$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));
}
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');
<?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.
*
public function lintPath($path) {
$data = $this->getData($path);
-
- if (preg_match('/@generated/', $data)) {
+
+ if (preg_match('/@'.'generated/', $data)) {
$this->stopAllLinters();
}
}
--- /dev/null
+<?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();
+ }
+ }
+}
--- /dev/null
+<?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');
--- /dev/null
+<?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 {
+
+}
--- /dev/null
+<?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');