]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Tweak license linter to support licenses on line immediately after <?php
authoradonohue <aran@fb.com>
Sat, 12 Feb 2011 01:48:06 +0000 (17:48 -0800)
committeradonohue <aran@fb.com>
Sat, 12 Feb 2011 01:51:55 +0000 (17:51 -0800)
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

foo.bar [deleted file]
src/lint/linter/apachelicense/ArcanistApacheLicenseLinter.php
src/lint/linter/license/ArcanistLicenseLinter.php

diff --git a/foo.bar b/foo.bar
deleted file mode 100644 (file)
index e69de29..0000000
index a57cd40fb56233717faca136f33da131f3c49a71..d20f8575fae753c3f9b6de8f08a802023d39a0d6 100644 (file)
@@ -25,6 +25,7 @@ class ArcanistApacheLicenseLinter extends ArcanistLicenseLinter {
     $year = date('Y');
 
     return <<<EOLICENSE
+
 /*
  * Copyright {$year} {$copyright_holder}
  *
index d725dad2e4f40cea01291745386f6036ff738452..fb9fa1fd5ffb7626f595f97dad9e705e4c211ff7 100644 (file)
@@ -56,12 +56,12 @@ abstract class ArcanistLicenseLinter extends ArcanistLinter {
     $patterns = $this->getLicensePatterns();
     $license = $this->getLicenseText($copyright_holder);
 
+    $data = $this->getData($path);
+    $matches = 0;
+
     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);
+        $expect = rtrim(implode('', array_slice($matches, 1)))."\n".$license;
         if (rtrim($matches[0]) != rtrim($expect)) {
           $this->raiseLintAtOffset(
             0,