From 8b1215ffcfc5975ed4ada4c97fcf9d2c5f3fd2a7 Mon Sep 17 00:00:00 2001 From: Bryan Cuccioli Date: Mon, 11 Feb 2013 09:04:19 -0800 Subject: [PATCH] Delete license linters. Summary: Remove all references to ArcanistLicenseLinter and ArcanistApacheLicenseLinter. Test Plan: Rerun the linter and ensure nothing is broken. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4901 --- src/__phutil_library_map__.php | 6 -- src/lint/engine/ComprehensiveLintEngine.php | 3 - .../linter/ArcanistApacheLicenseLinter.php | 53 -------------- src/lint/linter/ArcanistLicenseLinter.php | 71 ------------------- .../ArcanistApacheLicenseLinterTestCase.php | 25 ------- .../__tests__/apachelicense/c-basic.lint-test | 31 -------- .../__tests__/apachelicense/greedy.lint-test | 39 ---------- .../apachelicense/php-basic.lint-test | 27 ------- .../apachelicense/php-script.lint-test | 29 -------- .../apachelicense/php-update-mess.lint-test | 31 -------- .../apachelicense/php-update-multi.lint-test | 29 -------- .../apachelicense/php-update-single.lint-test | 29 -------- 12 files changed, 373 deletions(-) delete mode 100644 src/lint/linter/ArcanistApacheLicenseLinter.php delete mode 100644 src/lint/linter/ArcanistLicenseLinter.php delete mode 100644 src/lint/linter/__tests__/ArcanistApacheLicenseLinterTestCase.php delete mode 100644 src/lint/linter/__tests__/apachelicense/c-basic.lint-test delete mode 100644 src/lint/linter/__tests__/apachelicense/greedy.lint-test delete mode 100644 src/lint/linter/__tests__/apachelicense/php-basic.lint-test delete mode 100644 src/lint/linter/__tests__/apachelicense/php-script.lint-test delete mode 100644 src/lint/linter/__tests__/apachelicense/php-update-mess.lint-test delete mode 100644 src/lint/linter/__tests__/apachelicense/php-update-multi.lint-test delete mode 100644 src/lint/linter/__tests__/apachelicense/php-update-single.lint-test diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index b41fe264..e0c89d1f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -13,8 +13,6 @@ phutil_register_library_map(array( 'ArcanistAliasWorkflow' => 'workflow/ArcanistAliasWorkflow.php', 'ArcanistAmendWorkflow' => 'workflow/ArcanistAmendWorkflow.php', 'ArcanistAnoidWorkflow' => 'workflow/ArcanistAnoidWorkflow.php', - 'ArcanistApacheLicenseLinter' => 'lint/linter/ArcanistApacheLicenseLinter.php', - 'ArcanistApacheLicenseLinterTestCase' => 'lint/linter/__tests__/ArcanistApacheLicenseLinterTestCase.php', 'ArcanistArcanistLinterTestCase' => 'lint/linter/__tests__/ArcanistArcanistLinterTestCase.php', 'ArcanistBaseCommitParser' => 'parser/ArcanistBaseCommitParser.php', 'ArcanistBaseCommitParserTestCase' => 'parser/__tests__/ArcanistBaseCommitParserTestCase.php', @@ -75,7 +73,6 @@ phutil_register_library_map(array( 'ArcanistJSHintLinter' => 'lint/linter/ArcanistJSHintLinter.php', 'ArcanistLandWorkflow' => 'workflow/ArcanistLandWorkflow.php', 'ArcanistLiberateWorkflow' => 'workflow/ArcanistLiberateWorkflow.php', - 'ArcanistLicenseLinter' => 'lint/linter/ArcanistLicenseLinter.php', 'ArcanistLintConsoleRenderer' => 'lint/renderer/ArcanistLintConsoleRenderer.php', 'ArcanistLintEngine' => 'lint/engine/ArcanistLintEngine.php', 'ArcanistLintJSONRenderer' => 'lint/renderer/ArcanistLintJSONRenderer.php', @@ -171,8 +168,6 @@ phutil_register_library_map(array( 'ArcanistAliasWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistAmendWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistAnoidWorkflow' => 'ArcanistBaseWorkflow', - 'ArcanistApacheLicenseLinter' => 'ArcanistLicenseLinter', - 'ArcanistApacheLicenseLinterTestCase' => 'ArcanistArcanistLinterTestCase', 'ArcanistArcanistLinterTestCase' => 'ArcanistLinterTestCase', 'ArcanistBaseCommitParserTestCase' => 'ArcanistTestCase', 'ArcanistBaseWorkflow' => 'Phobject', @@ -216,7 +211,6 @@ phutil_register_library_map(array( 'ArcanistJSHintLinter' => 'ArcanistLinter', 'ArcanistLandWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistLiberateWorkflow' => 'ArcanistBaseWorkflow', - 'ArcanistLicenseLinter' => 'ArcanistLinter', 'ArcanistLintConsoleRenderer' => 'ArcanistLintRenderer', 'ArcanistLintJSONRenderer' => 'ArcanistLintRenderer', 'ArcanistLintLikeCompilerRenderer' => 'ArcanistLintRenderer', diff --git a/src/lint/engine/ComprehensiveLintEngine.php b/src/lint/engine/ComprehensiveLintEngine.php index 9adae4ec..b0f2c20f 100644 --- a/src/lint/engine/ComprehensiveLintEngine.php +++ b/src/lint/engine/ComprehensiveLintEngine.php @@ -33,9 +33,6 @@ final class ComprehensiveLintEngine extends ArcanistLintEngine { $linters[] = id(new ArcanistXHPASTLinter()) ->setPaths(preg_grep('/\.php$/', $paths)); - $linters[] = id(new ArcanistApacheLicenseLinter()) - ->setPaths(preg_grep('/\.(php|cpp|hpp|l|y)$/', $paths)); - $py_paths = preg_grep('/\.py$/', $paths); $linters[] = id(new ArcanistPyFlakesLinter())->setPaths($py_paths); $linters[] = id(new ArcanistPEP8Linter()) diff --git a/src/lint/linter/ArcanistApacheLicenseLinter.php b/src/lint/linter/ArcanistApacheLicenseLinter.php deleted file mode 100644 index f87ffe0a..00000000 --- a/src/lint/linter/ArcanistApacheLicenseLinter.php +++ /dev/null @@ -1,53 +0,0 @@ - 'No License Header', - ); - } - - /** - * Given the name of the copyright holder, return appropriate license header - * text. - */ - abstract protected function getLicenseText($copyright_holder); - /** - * Return an array of regular expressions that, if matched, indicate - * that a copyright header is required. The appropriate match will be - * stripped from the input when comparing against the expected license. - */ - abstract protected function getLicensePatterns(); - - public function lintPath($path) { - $copyright_holder = $this->getConfig('copyright_holder'); - if ($copyright_holder === null) { - $working_copy = $this->getEngine()->getWorkingCopy(); - $copyright_holder = $working_copy->getConfig('copyright_holder'); - } - - if (!$copyright_holder) { - return; - } - - $patterns = $this->getLicensePatterns(); - $license = $this->getLicenseText($copyright_holder); - - $data = $this->getData($path); - $matches = 0; - - foreach ($patterns as $pattern) { - if (preg_match($pattern, $data, $matches)) { - $expect = rtrim(implode('', array_slice($matches, 1)))."\n".$license; - if (trim($matches[0]) != trim($expect)) { - $this->raiseLintAtOffset( - 0, - self::LINT_NO_LICENSE_HEADER, - 'This file has a missing or out of date license header.', - $matches[0], - ltrim($expect)); - } - break; - } - } - } -} - - diff --git a/src/lint/linter/__tests__/ArcanistApacheLicenseLinterTestCase.php b/src/lint/linter/__tests__/ArcanistApacheLicenseLinterTestCase.php deleted file mode 100644 index b8d6bb79..00000000 --- a/src/lint/linter/__tests__/ArcanistApacheLicenseLinterTestCase.php +++ /dev/null @@ -1,25 +0,0 @@ -executeTestsInDirectory( - dirname(__FILE__).'/apachelicense/', - $linter, - $working_copy); - } - - protected function compareTransform($expected, $actual) { - $expected = str_replace('YYYY', date('Y'), $expected); - return parent::compareTransform($expected, $actual); - } - -} diff --git a/src/lint/linter/__tests__/apachelicense/c-basic.lint-test b/src/lint/linter/__tests__/apachelicense/c-basic.lint-test deleted file mode 100644 index 109eeb62..00000000 --- a/src/lint/linter/__tests__/apachelicense/c-basic.lint-test +++ /dev/null @@ -1,31 +0,0 @@ -#include - -int main(int argv, char **argv) { - return 0; -} -~~~~~~~~~~ -error:1:1 -~~~~~~~~~~ -/* - * Copyright YYYY 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. - */ - -#include - -int main(int argv, char **argv) { - return 0; -} -~~~~~~~~~~ -{"config": {"copyright_holder": "Facebook, Inc."}} diff --git a/src/lint/linter/__tests__/apachelicense/greedy.lint-test b/src/lint/linter/__tests__/apachelicense/greedy.lint-test deleted file mode 100644 index 33a8a6a7..00000000 --- a/src/lint/linter/__tests__/apachelicense/greedy.lint-test +++ /dev/null @@ -1,39 +0,0 @@ -