mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 08:52:39 +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:
parent
f22d74f88d
commit
e0bc910dda
3 changed files with 5 additions and 4 deletions
0
foo.bar
0
foo.bar
|
@ -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}
|
||||||
*
|
*
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue