1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-29 02:02:40 +01:00

Tweak license linter to support licenses on line immediately after <?php

Summary:
Tweak license linter to support licenses on line immediately after <?php

Test Plan:
Corrupt an apache license and re-lint twice.

Differential Revision: 34
Reviewed By: epriestley
Reviewers: epriestley
This commit is contained in:
adonohue 2011-02-11 17:48:06 -08:00
parent f22d74f88d
commit e0bc910dda
3 changed files with 5 additions and 4 deletions

View file

View file

@ -25,6 +25,7 @@ class ArcanistApacheLicenseLinter extends ArcanistLicenseLinter {
$year = date('Y'); $year = date('Y');
return <<<EOLICENSE return <<<EOLICENSE
/* /*
* Copyright {$year} {$copyright_holder} * Copyright {$year} {$copyright_holder}
* *

View file

@ -56,12 +56,12 @@ abstract class ArcanistLicenseLinter extends ArcanistLinter {
$patterns = $this->getLicensePatterns(); $patterns = $this->getLicensePatterns();
$license = $this->getLicenseText($copyright_holder); $license = $this->getLicenseText($copyright_holder);
foreach ($patterns as $pattern) {
$data = $this->getData($path); $data = $this->getData($path);
$matches = 0; $matches = 0;
foreach ($patterns as $pattern) {
if (preg_match($pattern, $data, $matches)) { if (preg_match($pattern, $data, $matches)) {
$expect = rtrim(implode('', array_slice($matches, 1)))."\n\n".$license; $expect = rtrim(implode('', array_slice($matches, 1)))."\n".$license;
$expect = ltrim($expect);
if (rtrim($matches[0]) != rtrim($expect)) { if (rtrim($matches[0]) != rtrim($expect)) {
$this->raiseLintAtOffset( $this->raiseLintAtOffset(
0, 0,