Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9582273
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
14 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/foo.bar b/foo.bar
new file mode 100644
index 00000000..e69de29b
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
index ba14bbba..0f12d494 100644
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1,113 +1,115 @@
<?php
/**
* This file is automatically generated. Use 'phutil_mapper.php' to rebuild it.
* @generated
*/
phutil_register_library_map(array(
'class' =>
array(
'ArcanistAmendWorkflow' => 'workflow/amend',
'ArcanistApacheLicenseLinter' => 'lint/linter/apachelicense',
'ArcanistBaseUnitTestEngine' => 'unit/engine/base',
'ArcanistBaseWorkflow' => 'workflow/base',
'ArcanistBundle' => 'parser/bundle',
'ArcanistChooseInvalidRevisionException' => 'exception',
'ArcanistChooseNoRevisionsException' => 'exception',
'ArcanistCommitWorkflow' => 'workflow/commit',
'ArcanistConfiguration' => 'configuration',
'ArcanistCoverWorkflow' => 'workflow/cover',
'ArcanistDiffChange' => 'parser/diff/change',
'ArcanistDiffChangeType' => 'parser/diff/changetype',
'ArcanistDiffHunk' => 'parser/diff/hunk',
'ArcanistDiffParser' => 'parser/diff',
'ArcanistDiffParserTestCase' => 'parser/diff/__tests__',
'ArcanistDiffUtils' => 'difference',
'ArcanistDiffWorkflow' => 'workflow/diff',
'ArcanistDifferentialCommitMessage' => 'differential/commitmessage',
'ArcanistDifferentialCommitMessageParserException' => 'differential/commitmessage',
'ArcanistDifferentialRevisionRef' => 'differential/revision',
'ArcanistExportWorkflow' => 'workflow/export',
'ArcanistFilenameLinter' => 'lint/linter/filename',
'ArcanistGeneratedLinter' => 'lint/linter/generated',
'ArcanistGitAPI' => 'repository/api/git',
'ArcanistGitHookPreReceiveWorkflow' => 'workflow/git-hook-pre-receive',
'ArcanistHelpWorkflow' => 'workflow/help',
+ 'ArcanistLicenseLinter' => 'lint/linter/license',
'ArcanistLintEngine' => 'lint/engine/base',
'ArcanistLintMessage' => 'lint/message',
'ArcanistLintPatcher' => 'lint/patcher',
'ArcanistLintRenderer' => 'lint/renderer',
'ArcanistLintResult' => 'lint/result',
'ArcanistLintSeverity' => 'lint/severity',
'ArcanistLintWorkflow' => 'workflow/lint',
'ArcanistLinter' => 'lint/linter/base',
'ArcanistListWorkflow' => 'workflow/list',
'ArcanistMarkCommittedWorkflow' => 'workflow/mark-committed',
'ArcanistNoEffectException' => 'exception/usage/noeffect',
'ArcanistNoEngineException' => 'exception/usage/noengine',
'ArcanistPEP8Linter' => 'lint/linter/pep8',
'ArcanistPatchWorkflow' => 'workflow/patch',
'ArcanistPhutilModuleLinter' => 'lint/linter/phutilmodule',
'ArcanistPhutilTestCase' => 'unit/engine/phutil/testcase',
'ArcanistPhutilTestTerminatedException' => 'unit/engine/phutil/testcase/exception',
'ArcanistRepositoryAPI' => 'repository/api/base',
'ArcanistShellCompleteWorkflow' => 'workflow/shell-complete',
'ArcanistSubversionAPI' => 'repository/api/subversion',
'ArcanistSvnHookPreCommitWorkflow' => 'workflow/svn-hook-pre-commit',
'ArcanistTextLinter' => 'lint/linter/text',
'ArcanistUnitTestResult' => 'unit/result',
'ArcanistUnitWorkflow' => 'workflow/unit',
'ArcanistUsageException' => 'exception/usage',
'ArcanistUserAbortException' => 'exception/usage/userabort',
'ArcanistWorkingCopyIdentity' => 'workingcopyidentity',
'ArcanistXHPASTLinter' => 'lint/linter/xhpast',
'ArcanistXHPASTLinterTestCase' => 'lint/linter/xhpast/__tests__',
'PhutilLintEngine' => 'lint/engine/phutil',
'PhutilModuleRequirements' => 'staticanalysis/parsers/phutilmodule',
'PhutilUnitTestEngine' => 'unit/engine/phutil',
'PhutilUnitTestEngineTestCase' => 'unit/engine/phutil/__tests__',
'UnitTestableArcanistLintEngine' => 'lint/engine/test',
),
'function' =>
array(
),
'requires_class' =>
array(
'ArcanistAmendWorkflow' => 'ArcanistBaseWorkflow',
- 'ArcanistApacheLicenseLinter' => 'ArcanistLinter',
+ 'ArcanistApacheLicenseLinter' => 'ArcanistLicenseLinter',
'ArcanistCommitWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistCoverWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistDiffParserTestCase' => 'ArcanistPhutilTestCase',
'ArcanistDiffWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistExportWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistFilenameLinter' => 'ArcanistLinter',
'ArcanistGeneratedLinter' => 'ArcanistLinter',
'ArcanistGitAPI' => 'ArcanistRepositoryAPI',
'ArcanistGitHookPreReceiveWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistHelpWorkflow' => 'ArcanistBaseWorkflow',
+ 'ArcanistLicenseLinter' => 'ArcanistLinter',
'ArcanistLintWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistListWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistMarkCommittedWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistNoEffectException' => 'ArcanistUsageException',
'ArcanistNoEngineException' => 'ArcanistUsageException',
'ArcanistPEP8Linter' => 'ArcanistLinter',
'ArcanistPatchWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistPhutilModuleLinter' => 'ArcanistLinter',
'ArcanistShellCompleteWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistSubversionAPI' => 'ArcanistRepositoryAPI',
'ArcanistSvnHookPreCommitWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistTextLinter' => 'ArcanistLinter',
'ArcanistUnitWorkflow' => 'ArcanistBaseWorkflow',
'ArcanistUserAbortException' => 'ArcanistUsageException',
'ArcanistXHPASTLinter' => 'ArcanistLinter',
'ArcanistXHPASTLinterTestCase' => 'ArcanistPhutilTestCase',
'PhutilLintEngine' => 'ArcanistLintEngine',
'PhutilUnitTestEngine' => 'ArcanistBaseUnitTestEngine',
'PhutilUnitTestEngineTestCase' => 'ArcanistPhutilTestCase',
'UnitTestableArcanistLintEngine' => 'ArcanistLintEngine',
),
'requires_interface' =>
array(
),
));
diff --git a/src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php b/src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php
index c3264cca..a57cd40f 100644
--- a/src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php
+++ b/src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php
@@ -1,97 +1,56 @@
<?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 ArcanistApacheLicenseLinter extends ArcanistLinter {
-
- const LINT_NO_LICENSE_HEADER = 1;
-
- public function willLintPaths(array $paths) {
- return;
- }
-
+class ArcanistApacheLicenseLinter extends ArcanistLicenseLinter {
public function getLinterName() {
return 'APACHELICENSE';
}
- public function getLintSeverityMap() {
- return array();
- }
-
- public function getLintNameMap() {
- return array(
- self::LINT_NO_LICENSE_HEADER => 'No License Header',
- );
- }
-
- public function lintPath($path) {
- $working_copy = $this->getEngine()->getWorkingCopy();
- $copyright_holder = $working_copy->getConfig('copyright_holder');
-
- if (!$copyright_holder) {
- return;
- }
-
+ protected function getLicenseText($copyright_holder) {
$year = date('Y');
- $maybe_php_or_script = '(#![^\n]+?[\n])?(<[?]php\s+?)?';
- $patterns = array(
- "@^{$maybe_php_or_script}//[^\n]*Copyright[^\n]*[\n]\s*@i",
- "@^{$maybe_php_or_script}/[*].*?Copyright.*?[*]/\s*@is",
- "@^{$maybe_php_or_script}\s*@",
- );
-
- $license = <<<EOLICENSE
+ return <<<EOLICENSE
/*
* Copyright {$year} {$copyright_holder}
*
* 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.
*/
EOLICENSE;
-
- foreach ($patterns as $pattern) {
- $data = $this->getData($path);
- $matches = 0;
- if (preg_match($pattern, $data, $matches)) {
- $expect = rtrim(implode('', array_slice($matches, 1)))."\n\n".$license;
- $expect = ltrim($expect);
- if (rtrim($matches[0]) != rtrim($expect)) {
- $this->raiseLintAtOffset(
- 0,
- self::LINT_NO_LICENSE_HEADER,
- 'This file has a missing or out of date license header.',
- $matches[0],
- $expect);
- }
- break;
- }
- }
}
+ protected function getLicensePatterns() {
+ $maybe_php_or_script = '(#![^\n]+?[\n])?(<[?]php\s+?)?';
+ return array(
+ "@^{$maybe_php_or_script}//[^\n]*Copyright[^\n]*[\n]\s*@i",
+ "@^{$maybe_php_or_script}/[*].*?Copyright.*?[*]/\s*@is",
+ "@^{$maybe_php_or_script}\s*@",
+ );
+ }
}
diff --git a/src/lint/linter/apachelicense/__init__.php b/src/lint/linter/apachelicense/__init__.php
index 08dd7e0e..e5067bc0 100644
--- a/src/lint/linter/apachelicense/__init__.php
+++ b/src/lint/linter/apachelicense/__init__.php
@@ -1,12 +1,10 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
-
-phutil_require_module('arcanist', 'lint/linter/base');
-
+phutil_require_module('arcanist', 'lint/linter/license');
phutil_require_source('ArcanistApacheLicenseLinter.php');
diff --git a/src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php b/src/lint/linter/license/ArcanistLicenseLinter.php
similarity index 61%
copy from src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php
copy to src/lint/linter/license/ArcanistLicenseLinter.php
index c3264cca..d725dad2 100644
--- a/src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php
+++ b/src/lint/linter/license/ArcanistLicenseLinter.php
@@ -1,97 +1,79 @@
<?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 ArcanistApacheLicenseLinter extends ArcanistLinter {
-
+abstract class ArcanistLicenseLinter extends ArcanistLinter {
const LINT_NO_LICENSE_HEADER = 1;
public function willLintPaths(array $paths) {
return;
}
- public function getLinterName() {
- return 'APACHELICENSE';
- }
-
public function getLintSeverityMap() {
return array();
}
public function getLintNameMap() {
return array(
self::LINT_NO_LICENSE_HEADER => '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) {
$working_copy = $this->getEngine()->getWorkingCopy();
$copyright_holder = $working_copy->getConfig('copyright_holder');
if (!$copyright_holder) {
return;
}
- $year = date('Y');
-
- $maybe_php_or_script = '(#![^\n]+?[\n])?(<[?]php\s+?)?';
- $patterns = array(
- "@^{$maybe_php_or_script}//[^\n]*Copyright[^\n]*[\n]\s*@i",
- "@^{$maybe_php_or_script}/[*].*?Copyright.*?[*]/\s*@is",
- "@^{$maybe_php_or_script}\s*@",
- );
-
- $license = <<<EOLICENSE
-/*
- * Copyright {$year} {$copyright_holder}
- *
- * 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.
- */
-
-
-EOLICENSE;
+ $patterns = $this->getLicensePatterns();
+ $license = $this->getLicenseText($copyright_holder);
foreach ($patterns as $pattern) {
$data = $this->getData($path);
$matches = 0;
if (preg_match($pattern, $data, $matches)) {
$expect = rtrim(implode('', array_slice($matches, 1)))."\n\n".$license;
$expect = ltrim($expect);
if (rtrim($matches[0]) != rtrim($expect)) {
$this->raiseLintAtOffset(
0,
self::LINT_NO_LICENSE_HEADER,
'This file has a missing or out of date license header.',
$matches[0],
$expect);
}
break;
}
}
}
-
}
+
+
diff --git a/src/lint/linter/apachelicense/__init__.php b/src/lint/linter/license/__init__.php
similarity index 73%
copy from src/lint/linter/apachelicense/__init__.php
copy to src/lint/linter/license/__init__.php
index 08dd7e0e..4ef6a342 100644
--- a/src/lint/linter/apachelicense/__init__.php
+++ b/src/lint/linter/license/__init__.php
@@ -1,12 +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('ArcanistApacheLicenseLinter.php');
+phutil_require_source('ArcanistLicenseLinter.php');
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 11, 06:29 (4 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
983871
Default Alt Text
(14 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline
Log In to Comment