mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-20 03:31:10 +01:00
(stable) Promote 2015 Week 36
This commit is contained in:
commit
529dc0c17f
77 changed files with 484 additions and 283 deletions
|
@ -422,7 +422,7 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo fwrite(STDERR, phutil_console_format(
|
fwrite(STDERR, phutil_console_format(
|
||||||
"(%s)\n",
|
"(%s)\n",
|
||||||
pht('Run with `%s` for a full exception trace.', '--trace')));
|
pht('Run with `%s` for a full exception trace.', '--trace')));
|
||||||
}
|
}
|
||||||
|
@ -620,9 +620,9 @@ function arcanist_load_libraries(
|
||||||
throw new ArcanistUsageException($error);
|
throw new ArcanistUsageException($error);
|
||||||
} else {
|
} else {
|
||||||
fwrite(STDERR, phutil_console_wrap(
|
fwrite(STDERR, phutil_console_wrap(
|
||||||
"%s: %s\n\n",
|
phutil_console_format("%s: %s\n",
|
||||||
pht('WARNING'),
|
pht('WARNING'),
|
||||||
$error));
|
$error)));
|
||||||
}
|
}
|
||||||
} catch (PhutilLibraryConflictException $ex) {
|
} catch (PhutilLibraryConflictException $ex) {
|
||||||
if ($ex->getLibrary() != 'arcanist') {
|
if ($ex->getLibrary() != 'arcanist') {
|
||||||
|
|
|
@ -90,6 +90,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistDuplicateSwitchCaseXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDuplicateSwitchCaseXHPASTLinterRule.php',
|
'ArcanistDuplicateSwitchCaseXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDuplicateSwitchCaseXHPASTLinterRule.php',
|
||||||
'ArcanistDynamicDefineXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDynamicDefineXHPASTLinterRule.php',
|
'ArcanistDynamicDefineXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDynamicDefineXHPASTLinterRule.php',
|
||||||
'ArcanistElseIfUsageXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistElseIfUsageXHPASTLinterRule.php',
|
'ArcanistElseIfUsageXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistElseIfUsageXHPASTLinterRule.php',
|
||||||
|
'ArcanistEmptyFileXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistEmptyFileXHPASTLinterRule.php',
|
||||||
'ArcanistEmptyStatementXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistEmptyStatementXHPASTLinterRule.php',
|
'ArcanistEmptyStatementXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistEmptyStatementXHPASTLinterRule.php',
|
||||||
'ArcanistEventType' => 'events/constant/ArcanistEventType.php',
|
'ArcanistEventType' => 'events/constant/ArcanistEventType.php',
|
||||||
'ArcanistExitExpressionXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistExitExpressionXHPASTLinterRule.php',
|
'ArcanistExitExpressionXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistExitExpressionXHPASTLinterRule.php',
|
||||||
|
@ -171,6 +172,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistMissingLinterException' => 'lint/linter/exception/ArcanistMissingLinterException.php',
|
'ArcanistMissingLinterException' => 'lint/linter/exception/ArcanistMissingLinterException.php',
|
||||||
'ArcanistModifierOrderingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistModifierOrderingXHPASTLinterRule.php',
|
'ArcanistModifierOrderingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistModifierOrderingXHPASTLinterRule.php',
|
||||||
'ArcanistNamingConventionsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php',
|
'ArcanistNamingConventionsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php',
|
||||||
|
'ArcanistNewlineAfterOpenTagXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php',
|
||||||
'ArcanistNoEffectException' => 'exception/usage/ArcanistNoEffectException.php',
|
'ArcanistNoEffectException' => 'exception/usage/ArcanistNoEffectException.php',
|
||||||
'ArcanistNoEngineException' => 'exception/usage/ArcanistNoEngineException.php',
|
'ArcanistNoEngineException' => 'exception/usage/ArcanistNoEngineException.php',
|
||||||
'ArcanistNoLintLinter' => 'lint/linter/ArcanistNoLintLinter.php',
|
'ArcanistNoLintLinter' => 'lint/linter/ArcanistNoLintLinter.php',
|
||||||
|
@ -374,6 +376,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistDuplicateSwitchCaseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistDuplicateSwitchCaseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistDynamicDefineXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistDynamicDefineXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistElseIfUsageXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistElseIfUsageXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
|
'ArcanistEmptyFileXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistEmptyStatementXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistEmptyStatementXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistEventType' => 'PhutilEventType',
|
'ArcanistEventType' => 'PhutilEventType',
|
||||||
'ArcanistExitExpressionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistExitExpressionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
|
@ -455,6 +458,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistMissingLinterException' => 'Exception',
|
'ArcanistMissingLinterException' => 'Exception',
|
||||||
'ArcanistModifierOrderingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistModifierOrderingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistNamingConventionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistNamingConventionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
|
'ArcanistNewlineAfterOpenTagXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistNoEffectException' => 'ArcanistUsageException',
|
'ArcanistNoEffectException' => 'ArcanistUsageException',
|
||||||
'ArcanistNoEngineException' => 'ArcanistUsageException',
|
'ArcanistNoEngineException' => 'ArcanistUsageException',
|
||||||
'ArcanistNoLintLinter' => 'ArcanistLinter',
|
'ArcanistNoLintLinter' => 'ArcanistLinter',
|
||||||
|
|
|
@ -57,7 +57,6 @@ abstract class ArcanistLintEngine extends Phobject {
|
||||||
private $changedLines = array();
|
private $changedLines = array();
|
||||||
|
|
||||||
private $enableAsyncLint = false;
|
private $enableAsyncLint = false;
|
||||||
private $postponedLinters = array();
|
|
||||||
private $configurationManager;
|
private $configurationManager;
|
||||||
|
|
||||||
private $linterResources = array();
|
private $linterResources = array();
|
||||||
|
@ -403,15 +402,6 @@ abstract class ArcanistLintEngine extends Phobject {
|
||||||
return array($line, $char);
|
return array($line, $char);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getPostponedLinters() {
|
|
||||||
return $this->postponedLinters;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function setPostponedLinters(array $linters) {
|
|
||||||
$this->postponedLinters = $linters;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getCacheVersion() {
|
protected function getCacheVersion() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ final class ArcanistTextLinter extends ArcanistLinter {
|
||||||
const LINT_TRAILING_WHITESPACE = 6;
|
const LINT_TRAILING_WHITESPACE = 6;
|
||||||
const LINT_BOF_WHITESPACE = 8;
|
const LINT_BOF_WHITESPACE = 8;
|
||||||
const LINT_EOF_WHITESPACE = 9;
|
const LINT_EOF_WHITESPACE = 9;
|
||||||
|
const LINT_EMPTY_FILE = 10;
|
||||||
|
|
||||||
private $maxLineLength = 80;
|
private $maxLineLength = 80;
|
||||||
|
|
||||||
|
@ -85,16 +86,23 @@ final class ArcanistTextLinter extends ArcanistLinter {
|
||||||
self::LINT_TRAILING_WHITESPACE => pht('Trailing Whitespace'),
|
self::LINT_TRAILING_WHITESPACE => pht('Trailing Whitespace'),
|
||||||
self::LINT_BOF_WHITESPACE => pht('Leading Whitespace at BOF'),
|
self::LINT_BOF_WHITESPACE => pht('Leading Whitespace at BOF'),
|
||||||
self::LINT_EOF_WHITESPACE => pht('Trailing Whitespace at EOF'),
|
self::LINT_EOF_WHITESPACE => pht('Trailing Whitespace at EOF'),
|
||||||
|
self::LINT_EMPTY_FILE => pht('Empty File'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lintPath($path) {
|
public function lintPath($path) {
|
||||||
|
$this->lintEmptyFile($path);
|
||||||
|
|
||||||
if (!strlen($this->getData($path))) {
|
if (!strlen($this->getData($path))) {
|
||||||
// If the file is empty, don't bother; particularly, don't require
|
// If the file is empty, don't bother; particularly, don't require
|
||||||
// the user to add a newline.
|
// the user to add a newline.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->didStopAllLinters()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->lintNewlines($path);
|
$this->lintNewlines($path);
|
||||||
$this->lintTabs($path);
|
$this->lintTabs($path);
|
||||||
|
|
||||||
|
@ -116,6 +124,29 @@ final class ArcanistTextLinter extends ArcanistLinter {
|
||||||
$this->lintEOFWhitespace($path);
|
$this->lintEOFWhitespace($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function lintEmptyFile($path) {
|
||||||
|
$data = $this->getData($path);
|
||||||
|
|
||||||
|
// It is reasonable for certain file types to be completely empty,
|
||||||
|
// so they are excluded here.
|
||||||
|
switch ($filename = basename($this->getActivePath())) {
|
||||||
|
case '__init__.py':
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (strlen($filename) && $filename[0] == '.') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/^\s*$/', $data)) {
|
||||||
|
$this->raiseLintAtPath(
|
||||||
|
self::LINT_EMPTY_FILE,
|
||||||
|
pht("Empty files usually don't serve any useful purpose."));
|
||||||
|
$this->stopAllLinters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function lintNewlines($path) {
|
protected function lintNewlines($path) {
|
||||||
$data = $this->getData($path);
|
$data = $this->getData($path);
|
||||||
$pos = strpos($this->getData($path), "\r");
|
$pos = strpos($this->getData($path), "\r");
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
error::
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
array(1, 2, 3);
|
array(1, 2, 3);
|
||||||
array(1, 2, 3,);
|
array(1, 2, 3,);
|
||||||
array(
|
array(
|
||||||
|
@ -33,14 +34,15 @@ array(
|
||||||
2,
|
2,
|
||||||
3, /* comment */ );
|
3, /* comment */ );
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:3:14
|
advice:4:14
|
||||||
advice:12:3
|
advice:13:3
|
||||||
advice:16:3
|
advice:17:3
|
||||||
advice:26:3
|
advice:27:3
|
||||||
advice:30:3
|
advice:31:3
|
||||||
advice:34:20
|
advice:35:20
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
array(1, 2, 3);
|
array(1, 2, 3);
|
||||||
array(1, 2, 3);
|
array(1, 2, 3);
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$a []= 1;
|
$a []= 1;
|
||||||
$a[] = 1;
|
$a[] = 1;
|
||||||
$a[]=1;
|
$a[]=1;
|
||||||
$a [] = 1;
|
$a [] = 1;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:3
|
warning:3:3
|
||||||
warning:2:6
|
warning:3:6
|
||||||
warning:4:5
|
warning:5:5
|
||||||
warning:5:3
|
warning:6:3
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$a[] = 1;
|
$a[] = 1;
|
||||||
$a[] = 1;
|
$a[] = 1;
|
||||||
$a[] = 1;
|
$a[] = 1;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
eval('evil code');
|
eval('evil code');
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:1
|
error:3:1
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class MyClass {
|
class MyClass {
|
||||||
public function myfunc($var) {
|
public function myfunc($var) {
|
||||||
echo $var;
|
echo $var;
|
||||||
|
@ -24,10 +25,10 @@ $foo(&$myvar);
|
||||||
array_walk(array(), function () use (&$x) {});
|
array_walk(array(), function () use (&$x) {});
|
||||||
MyClass::myfunc(array(&$x, &$y));
|
MyClass::myfunc(array(&$x, &$y));
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:7 XHP19
|
error:3:7 XHP19
|
||||||
error:9:8
|
error:10:8
|
||||||
error:12:15
|
error:13:15
|
||||||
error:15:17
|
error:16:17
|
||||||
error:18:24
|
error:19:24
|
||||||
error:18:39
|
error:19:39
|
||||||
error:22:6
|
error:23:6
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo (double)0;
|
echo (double)0;
|
||||||
echo (int) 1;
|
echo (int) 1;
|
||||||
echo (string) 2;
|
echo (string) 2;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:3:11
|
advice:4:11
|
||||||
advice:4:14
|
advice:5:14
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo (double)0;
|
echo (double)0;
|
||||||
echo (int)1;
|
echo (int)1;
|
||||||
echo (string)2;
|
echo (string)2;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class MyClass {
|
class MyClass {
|
||||||
public function someMethod() {
|
public function someMethod() {
|
||||||
return 'MyClass';
|
return 'MyClass';
|
||||||
|
@ -11,11 +12,12 @@ class MyClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:7
|
error:3:7
|
||||||
advice:4:12
|
advice:5:12
|
||||||
advice:8:10
|
advice:9:10
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class MyClass {
|
class MyClass {
|
||||||
public function someMethod() {
|
public function someMethod() {
|
||||||
return __CLASS__;
|
return __CLASS__;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('foo', 'bar');
|
define('foo', 'bar');
|
||||||
const bar = 'baz';
|
const bar = 'baz';
|
||||||
|
|
||||||
|
@ -6,7 +7,7 @@ class Foo {
|
||||||
const bar = 'baz';
|
const bar = 'baz';
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:8
|
warning:3:8
|
||||||
warning:3:7
|
warning:4:7
|
||||||
error:5:7
|
error:6:7
|
||||||
warning:6:9
|
warning:7:9
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
new Foo;
|
new Foo;
|
||||||
new Bar();
|
new Bar();
|
||||||
new Foo\Bar;
|
new Foo\Bar;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:2:5
|
advice:3:5
|
||||||
advice:4:5
|
advice:5:5
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
new Foo();
|
new Foo();
|
||||||
new Bar();
|
new Bar();
|
||||||
new Foo\Bar();
|
new Foo\Bar();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function foo($x, $y, $z) {}
|
function foo($x, $y, $z) {}
|
||||||
function bar($x, $y = null, $z) {}
|
function bar($x, $y = null, $z) {}
|
||||||
function baz($x = null, $y = null, $z = null) {}
|
function baz($x = null, $y = null, $z = null) {}
|
||||||
|
@ -7,6 +8,6 @@ class MyClass {
|
||||||
public function myMethod($x, $y = null, $z) {}
|
public function myMethod($x, $y = null, $z) {}
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:3:13
|
warning:4:13
|
||||||
error:6:7
|
error:7:7
|
||||||
warning:7:27
|
warning:8:27
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
'foobar';
|
'foobar';
|
||||||
"foo\"bar";
|
"foo\"bar";
|
||||||
"foobar\n";
|
"foobar\n";
|
||||||
|
@ -12,9 +13,10 @@ pht(
|
||||||
"This string also requires \123\345 double quotes, but ".
|
"This string also requires \123\345 double quotes, but ".
|
||||||
"this string does not. Here, they are used for consistency.");
|
"this string does not. Here, they are used for consistency.");
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:3:1
|
advice:4:1
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
'foobar';
|
'foobar';
|
||||||
'foo"bar';
|
'foo"bar';
|
||||||
"foobar\n";
|
"foobar\n";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$a = array(
|
$a = array(
|
||||||
'a' => 'val1',
|
'a' => 'val1',
|
||||||
$a => 'val2',
|
$a => 'val2',
|
||||||
|
@ -34,9 +35,9 @@ $f = array(
|
||||||
$a => 'var2',
|
$a => 'var2',
|
||||||
);
|
);
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:5:3
|
error:6:3
|
||||||
error:8:3
|
error:9:3
|
||||||
error:15:3
|
error:16:3
|
||||||
error:20:3
|
error:21:3
|
||||||
error:25:3
|
error:26:3
|
||||||
error:34:3
|
error:35:3
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$x = null;
|
$x = null;
|
||||||
$y = null;
|
$y = null;
|
||||||
switch ($x) {}
|
switch ($x) {}
|
||||||
|
@ -24,5 +25,5 @@ switch ($x) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:15:3
|
error:16:3
|
||||||
error:22:7
|
error:23:7
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('PONY', 'cute');
|
define('PONY', 'cute');
|
||||||
define($pony, 'cute');
|
define($pony, 'cute');
|
||||||
define('PONY', $cute);
|
define('PONY', $cute);
|
||||||
define($pony, $cute);
|
define($pony, $cute);
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:3:8 dynamic define
|
error:4:8 dynamic define
|
||||||
error:5:8 dynamic define
|
error:6:8 dynamic define
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
echo 'foo';
|
echo 'foo';
|
||||||
} elseif (false) {
|
} elseif (false) {
|
||||||
|
@ -7,9 +8,10 @@ if (true) {
|
||||||
echo 'baz';
|
echo 'baz';
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:4:3
|
advice:5:3
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
echo 'foo';
|
echo 'foo';
|
||||||
} else if (false) {
|
} else if (false) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function w() {}
|
function w() {}
|
||||||
function x() {
|
function x() {
|
||||||
// This is deliberately empty.
|
// This is deliberately empty.
|
||||||
|
@ -9,10 +10,11 @@ function z() {
|
||||||
|
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:6:14
|
|
||||||
advice:7:14
|
advice:7:14
|
||||||
|
advice:8:14
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function w() {}
|
function w() {}
|
||||||
function x() {
|
function x() {
|
||||||
// This is deliberately empty.
|
// This is deliberately empty.
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class Foo {};
|
final class Foo {};
|
||||||
$x = null;;
|
$x = null;;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:13 XHP19
|
error:3:13 XHP19
|
||||||
advice:2:19
|
advice:3:19
|
||||||
advice:3:11
|
advice:4:11
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class Foo {}
|
final class Foo {}
|
||||||
$x = null;
|
$x = null;
|
||||||
|
|
3
src/lint/linter/__tests__/xhpast/empty.lint-test
Normal file
3
src/lint/linter/__tests__/xhpast/empty.lint-test
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?php ?>
|
||||||
|
~~~~~~~~~~
|
||||||
|
warning::
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
exit -1;
|
exit -1;
|
||||||
strtoupper(33 * exit - 6);
|
strtoupper(33 * exit - 6);
|
||||||
|
@ -8,8 +9,8 @@ print '';
|
||||||
$x = new stdClass();
|
$x = new stdClass();
|
||||||
$y = clone $x;
|
$y = clone $x;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:3:1
|
error:4:1
|
||||||
warning:3:5
|
warning:4:5
|
||||||
warning:3:6
|
warning:4:6
|
||||||
error:4:17
|
error:5:17
|
||||||
warning:4:21
|
warning:5:21
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
printf();
|
printf();
|
||||||
printf(null);
|
printf(null);
|
||||||
printf('');
|
printf('');
|
||||||
|
@ -11,11 +12,11 @@ queryfx(null, 'x', 'y');
|
||||||
|
|
||||||
foobar(null, null, '%s');
|
foobar(null, null, '%s');
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:1
|
error:3:1
|
||||||
error:6:1
|
|
||||||
error:7:1
|
error:7:1
|
||||||
error:10:1
|
error:8:1
|
||||||
error:12:1
|
error:11:1
|
||||||
|
error:13:1
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $BASE_URL;
|
global $BASE_URL;
|
||||||
function foo() {
|
function foo() {
|
||||||
global $x, $y;
|
global $x, $y;
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:1
|
warning:3:1
|
||||||
warning:4:3
|
warning:5:3
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# no
|
# no
|
||||||
#no
|
#no
|
||||||
// yes
|
// yes
|
||||||
|
@ -20,17 +21,18 @@
|
||||||
/** yes */
|
/** yes */
|
||||||
/**** yes ****/
|
/**** yes ****/
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:1
|
|
||||||
error:3:1
|
error:3:1
|
||||||
error:5:1
|
error:4:1
|
||||||
error:6:11
|
error:6:1
|
||||||
advice:13:1
|
error:7:11
|
||||||
advice:14:1
|
advice:14:1
|
||||||
error:15:1
|
advice:15:1
|
||||||
advice:18:1
|
error:16:1
|
||||||
advice:19:1
|
advice:19:1
|
||||||
|
advice:20:1
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// no
|
// no
|
||||||
// no
|
// no
|
||||||
// yes
|
// yes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class Foo {
|
final class Foo {
|
||||||
public function bar() {}
|
public function bar() {}
|
||||||
function baz() {}
|
function baz() {}
|
||||||
|
@ -10,13 +11,14 @@ final class Foo {
|
||||||
private $z;
|
private $z;
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:13 XHP19
|
error:3:13 XHP19
|
||||||
advice:4:3
|
|
||||||
advice:5:3
|
advice:5:3
|
||||||
advice:8:3
|
advice:6:3
|
||||||
advice:9:3
|
advice:9:3
|
||||||
|
advice:10:3
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class Foo {
|
final class Foo {
|
||||||
public function bar() {}
|
public function bar() {}
|
||||||
public function baz() {}
|
public function baz() {}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
f()[0];
|
f()[0];
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:5
|
error:3:5
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
var_dump('foobar' instanceof stdClass);
|
var_dump('foobar' instanceof stdClass);
|
||||||
var_dump(123 instanceof stdClass);
|
var_dump(123 instanceof stdClass);
|
||||||
var_dump(null instanceof stdClass);
|
var_dump(null instanceof stdClass);
|
||||||
var_dump($x instanceof stdClass);
|
var_dump($x instanceof stdClass);
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:10
|
|
||||||
error:3:10
|
error:3:10
|
||||||
error:4:10
|
error:4:10
|
||||||
|
error:5:10
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function func_one(array $x) {}
|
function func_one(array $x) {}
|
||||||
function func_two(array $x = null) {}
|
function func_two(array $x = null) {}
|
||||||
function func_three(array $x = array()) {}
|
function func_three(array $x = array()) {}
|
||||||
|
@ -12,6 +13,6 @@ function func_eight(stdClass $x) {}
|
||||||
function func_nine(stdClass $x = null) {}
|
function func_nine(stdClass $x = null) {}
|
||||||
function func_ten(stdClass $x = array()) {}
|
function func_ten(stdClass $x = array()) {}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:5:31
|
error:6:31
|
||||||
error:9:35
|
error:10:35
|
||||||
error:13:33
|
error:14:33
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class SomeClass {
|
class SomeClass {
|
||||||
public $a;
|
public $a;
|
||||||
public public $b;
|
public public $b;
|
||||||
|
@ -10,9 +11,9 @@ class SomeClass {
|
||||||
abstract final public function baz() {}
|
abstract final public function baz() {}
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:7 XHP19
|
error:3:7 XHP19
|
||||||
error:4:10
|
|
||||||
error:5:10
|
error:5:10
|
||||||
error:6:11
|
error:6:10
|
||||||
error:9:10
|
error:7:11
|
||||||
error:10:12
|
error:10:10
|
||||||
|
error:11:12
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function __lambda_func() {}
|
function __lambda_func() {}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:1
|
error:3:1
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include 'foo.php';
|
include 'foo.php';
|
||||||
include_once 'foo.php';
|
include_once 'foo.php';
|
||||||
require 'foo.php';
|
require 'foo.php';
|
||||||
|
@ -17,18 +18,19 @@ require ('baz.php');
|
||||||
require_once ('baz.php');
|
require_once ('baz.php');
|
||||||
echo ('baz');
|
echo ('baz');
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:8:8
|
warning:9:8
|
||||||
warning:9:13
|
warning:10:13
|
||||||
warning:10:8
|
warning:11:8
|
||||||
warning:11:13
|
warning:12:13
|
||||||
warning:12:5
|
warning:13:5
|
||||||
warning:14:9
|
warning:15:9
|
||||||
warning:15:14
|
warning:16:14
|
||||||
warning:16:9
|
warning:17:9
|
||||||
warning:17:14
|
warning:18:14
|
||||||
warning:18:6
|
warning:19:6
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include 'foo.php';
|
include 'foo.php';
|
||||||
include_once 'foo.php';
|
include_once 'foo.php';
|
||||||
require 'foo.php';
|
require 'foo.php';
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
list($x, $y, , ,) = array();
|
list($x, $y, , ,) = array();
|
||||||
list($x, $y, , , $z) = array();
|
list($x, $y, , , $z) = array();
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:12
|
warning:3:12
|
||||||
warning:2:14
|
warning:3:14
|
||||||
warning:2:16
|
warning:3:16
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
list($x, $y ) = array();
|
list($x, $y ) = array();
|
||||||
list($x, $y, , , $z) = array();
|
list($x, $y, , , $z) = array();
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
var_dump('');
|
var_dump('');
|
||||||
Var_Dump('');
|
Var_Dump('');
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:3:1
|
advice:4:1
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
var_dump('');
|
var_dump('');
|
||||||
var_dump('');
|
var_dump('');
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
public $x;
|
public $x;
|
||||||
static protected $y;
|
static protected $y;
|
||||||
|
@ -8,12 +9,13 @@ class Foo {
|
||||||
static final public function foobar() {}
|
static final public function foobar() {}
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:7 XHP19
|
error:3:7 XHP19
|
||||||
advice:4:3
|
advice:5:3
|
||||||
advice:6:3
|
advice:7:3
|
||||||
advice:8:3
|
advice:9:3
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
public $x;
|
public $x;
|
||||||
protected static $y;
|
protected static $y;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class a {
|
final class a {
|
||||||
const b = 1, c = d;
|
const b = 1, c = d;
|
||||||
protected $E, $H;
|
protected $E, $H;
|
||||||
|
@ -7,8 +8,6 @@ final class a {
|
||||||
|
|
||||||
interface i {}
|
interface i {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function YY($ZZ) {}
|
function YY($ZZ) {}
|
||||||
|
|
||||||
final class Quack {
|
final class Quack {
|
||||||
|
@ -17,10 +16,6 @@ final class Quack {
|
||||||
public function vV($w_w) {}
|
public function vV($w_w) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function () use ($this_is_a_closure) {};
|
function () use ($this_is_a_closure) {};
|
||||||
|
|
||||||
function f(&$YY) {}
|
function f(&$YY) {}
|
||||||
|
@ -54,23 +49,24 @@ function j() {
|
||||||
Other::$y = 0;
|
Other::$y = 0;
|
||||||
$mIxEdCaSe = 1;
|
$mIxEdCaSe = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:13
|
warning:3:13
|
||||||
warning:3:9
|
warning:4:9
|
||||||
warning:3:16
|
warning:4:9
|
||||||
warning:4:13
|
warning:4:16
|
||||||
warning:4:17
|
warning:4:16
|
||||||
warning:5:19
|
warning:5:13
|
||||||
warning:5:21
|
warning:5:17
|
||||||
warning:5:25
|
warning:6:19
|
||||||
warning:8:11
|
warning:6:21
|
||||||
warning:12:10
|
warning:6:25
|
||||||
warning:12:13
|
warning:9:11
|
||||||
warning:26:13
|
warning:11:10
|
||||||
warning:29:3
|
warning:11:13
|
||||||
warning:30:3
|
warning:21:13
|
||||||
warning:31:3
|
warning:24:3
|
||||||
warning:33:3
|
warning:25:3
|
||||||
warning:37:3
|
warning:26:3
|
||||||
warning:55:3
|
warning:28:3
|
||||||
|
warning:32:3
|
||||||
|
warning:50:3
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php phpinfo() ?>
|
||||||
|
<? phpinfo(); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
phpinfo();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?
|
||||||
|
phpinfo();
|
||||||
|
~~~~~~~~~~
|
||||||
|
advice:4:6
|
||||||
|
advice:8:3
|
||||||
|
~~~~~~~~~~
|
||||||
|
<?php phpinfo() ?>
|
||||||
|
<? phpinfo(); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
phpinfo();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?
|
||||||
|
|
||||||
|
phpinfo();
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class A {}
|
abstract class A {}
|
||||||
final class F {}
|
final class F {}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
4
src/lint/linter/__tests__/xhpast/not-empty.lint-test
Normal file
4
src/lint/linter/__tests__/xhpast/not-empty.lint-test
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// This file is not empty.
|
||||||
|
~~~~~~~~~~
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo <<<'EOT'
|
echo <<<'EOT'
|
||||||
Hello World!
|
Hello World!
|
||||||
EOT;
|
EOT;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:6
|
error:3:6
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$x -> doSomething();
|
$x -> doSomething();
|
||||||
id(new Something())
|
id(new Something())
|
||||||
->doSomething();
|
->doSomething();
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:3
|
warning:3:3
|
||||||
warning:2:6
|
warning:3:6
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$x->doSomething();
|
$x->doSomething();
|
||||||
id(new Something())
|
id(new Something())
|
||||||
->doSomething();
|
->doSomething();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ( $x ) {}
|
if ( $x ) {}
|
||||||
f( );
|
f( );
|
||||||
q( );
|
q( );
|
||||||
|
@ -20,25 +21,26 @@ some_call( /* respect authorial intent */ $b,
|
||||||
$a // if comments are present
|
$a // if comments are present
|
||||||
);
|
);
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:5
|
warning:3:5
|
||||||
warning:2:8
|
warning:3:8
|
||||||
warning:3:3
|
|
||||||
warning:4:3
|
warning:4:3
|
||||||
warning:6:21
|
warning:5:3
|
||||||
warning:6:24
|
warning:7:21
|
||||||
warning:12:6
|
warning:7:24
|
||||||
warning:12:30
|
warning:13:6
|
||||||
warning:13:10
|
warning:13:30
|
||||||
warning:13:19
|
warning:14:10
|
||||||
warning:14:12
|
warning:14:19
|
||||||
warning:14:15
|
warning:15:12
|
||||||
error:15:13 XHP19 Class-Filename Mismatch
|
warning:15:15
|
||||||
warning:16:21
|
error:16:13 XHP19 Class-Filename Mismatch
|
||||||
warning:16:24
|
warning:17:21
|
||||||
warning:18:10
|
warning:17:24
|
||||||
warning:18:25
|
warning:19:10
|
||||||
|
warning:19:25
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ($x) {}
|
if ($x) {}
|
||||||
f();
|
f();
|
||||||
q();
|
q();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?
|
<?
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
warning::
|
||||||
error:1:1
|
error:1:1
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
break;
|
break;
|
||||||
break 0;
|
break 0;
|
||||||
break 1;
|
break 1;
|
||||||
|
@ -8,10 +9,10 @@ continue 0;
|
||||||
continue 1;
|
continue 1;
|
||||||
continue 1 + foo() * $bar;
|
continue 1 + foo() * $bar;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:3:7
|
error:4:7
|
||||||
error:5:7
|
error:6:7
|
||||||
error:7:10
|
error:8:10
|
||||||
error:9:10
|
error:10:10
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
{"config": {"xhpast.php-version": "5.4.0"}}
|
{"config": {"xhpast.php-version": "5.4.0"}}
|
||||||
|
|
|
@ -6,7 +6,6 @@ function foo($bar) {
|
||||||
preg_Quote('moo');
|
preg_Quote('moo');
|
||||||
preg_quote('moo', '/');
|
preg_quote('moo', '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:4:3 Wrong number of arguments to preg_quote()
|
advice:4:3 Wrong number of arguments to preg_quote()
|
||||||
advice:6:3 Wrong number of arguments to preg_quote()
|
advice:6:3 Wrong number of arguments to preg_quote()
|
||||||
|
|
|
@ -119,7 +119,6 @@ function closure4() {
|
||||||
};
|
};
|
||||||
$a++; // Reuse of $a
|
$a++; // Reuse of $a
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:6:3
|
warning:6:3
|
||||||
warning:12:8
|
warning:12:8
|
||||||
|
|
|
@ -62,7 +62,6 @@ function k($stuff, $thing) {
|
||||||
$other = array();
|
$other = array();
|
||||||
foreach ($other as $item) {}
|
foreach ($other as $item) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:43:22
|
error:43:22
|
||||||
error:53:22
|
error:53:22
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
foo();
|
foo();
|
||||||
bar() ;
|
bar() ;
|
||||||
baz()
|
baz()
|
||||||
|
|
||||||
;
|
;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:3:6
|
|
||||||
advice:4:6
|
advice:4:6
|
||||||
|
advice:5:6
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
foo();
|
foo();
|
||||||
bar();
|
bar();
|
||||||
baz();
|
baz();
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This test is checking that the LintPatcher correctly applies adjacent patches
|
// This test is checking that the LintPatcher correctly applies adjacent patches
|
||||||
// with large character delta effects.
|
// with large character delta effects.
|
||||||
function f( ) {
|
function f( ) {
|
||||||
g( );
|
g( );
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:4:12
|
warning:5:12
|
||||||
warning:5:5
|
warning:6:5
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This test is checking that the LintPatcher correctly applies adjacent patches
|
// This test is checking that the LintPatcher correctly applies adjacent patches
|
||||||
// with large character delta effects.
|
// with large character delta effects.
|
||||||
function f() {
|
function f() {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if($x) {}
|
if($x) {}
|
||||||
else{}
|
else{}
|
||||||
for(;;) {}
|
for(;;) {}
|
||||||
|
@ -25,23 +26,24 @@ do {
|
||||||
|
|
||||||
try {} catch(Exception $ex) {}
|
try {} catch(Exception $ex) {}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:1
|
|
||||||
warning:2:10
|
|
||||||
warning:3:1
|
warning:3:1
|
||||||
|
warning:3:10
|
||||||
warning:4:1
|
warning:4:1
|
||||||
warning:5:1
|
warning:5:1
|
||||||
warning:6:1
|
warning:6:1
|
||||||
warning:7:1
|
warning:7:1
|
||||||
warning:7:6
|
|
||||||
warning:8:1
|
warning:8:1
|
||||||
warning:9:11
|
warning:8:6
|
||||||
warning:10:16
|
warning:9:1
|
||||||
warning:13:3
|
warning:10:11
|
||||||
|
warning:11:16
|
||||||
warning:14:3
|
warning:14:3
|
||||||
warning:24:3
|
warning:15:3
|
||||||
warning:26:8
|
warning:25:3
|
||||||
|
warning:27:8
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ($x) {} else {}
|
if ($x) {} else {}
|
||||||
for (;;) {}
|
for (;;) {}
|
||||||
foreach ($x as $y) {}
|
foreach ($x as $y) {}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$a.$b;
|
$a.$b;
|
||||||
$a . $b;
|
$a . $b;
|
||||||
$a. $b;
|
$a. $b;
|
||||||
|
@ -24,16 +25,17 @@ array(
|
||||||
$x=>$y,
|
$x=>$y,
|
||||||
);
|
);
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:3:3
|
warning:4:3
|
||||||
warning:3:5
|
warning:4:5
|
||||||
warning:4:4
|
warning:5:4
|
||||||
warning:5:3
|
warning:6:3
|
||||||
warning:12:9
|
warning:13:9
|
||||||
warning:13:10
|
warning:14:10
|
||||||
warning:14:9
|
warning:15:9
|
||||||
warning:24:5
|
warning:25:5
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$a.$b;
|
$a.$b;
|
||||||
$a.$b;
|
$a.$b;
|
||||||
$a.$b;
|
$a.$b;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$a + $b;
|
$a + $b;
|
||||||
$a+$b;
|
$a+$b;
|
||||||
$a +$b;
|
$a +$b;
|
||||||
|
@ -23,21 +24,22 @@ if ($x instanceof z &&$w) {}
|
||||||
if ($x instanceof z && $w) {}
|
if ($x instanceof z && $w) {}
|
||||||
f(1,2);
|
f(1,2);
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:3:3
|
warning:4:3
|
||||||
warning:4:4
|
warning:5:4
|
||||||
warning:5:3
|
warning:6:3
|
||||||
warning:7:3
|
|
||||||
warning:8:3
|
warning:8:3
|
||||||
warning:9:4
|
warning:9:3
|
||||||
warning:10:3
|
warning:10:4
|
||||||
warning:11:3
|
warning:11:3
|
||||||
warning:13:14
|
warning:12:3
|
||||||
warning:20:52
|
warning:14:14
|
||||||
warning:21:54
|
warning:21:52
|
||||||
warning:22:21
|
warning:22:54
|
||||||
warning:24:4
|
warning:23:21
|
||||||
|
warning:25:4
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$a + $b;
|
$a + $b;
|
||||||
$a + $b;
|
$a + $b;
|
||||||
$a + $b;
|
$a + $b;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class Platypus {
|
final class Platypus {
|
||||||
public function platypus() {
|
public function platypus() {
|
||||||
// This method must be renamed to __construct().
|
// This method must be renamed to __construct().
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:13 XHP19 Class-Filename Mismatch
|
error:3:13 XHP19 Class-Filename Mismatch
|
||||||
error:3:19
|
error:4:19
|
||||||
|
|
|
@ -15,7 +15,6 @@ $skip_cache = true || $some_complicated_expression;
|
||||||
$skip_cache = $a || $b;
|
$skip_cache = $a || $b;
|
||||||
$skip_cache = false && something();
|
$skip_cache = false && something();
|
||||||
$skip_cache = f();
|
$skip_cache = f();
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:3:5
|
error:3:5
|
||||||
error:5:5
|
error:5:5
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class MyClass {
|
class MyClass {
|
||||||
public function __toString() {
|
public function __toString() {
|
||||||
if (some_function()) {
|
if (some_function()) {
|
||||||
|
@ -23,4 +24,4 @@ abstract class SomeAbstractClass {
|
||||||
abstract public function __toString();
|
abstract public function __toString();
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:5:7
|
error:6:7
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$x ++;
|
$x ++;
|
||||||
$y--;
|
$y--;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:3
|
warning:3:3
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$x++;
|
$x++;
|
||||||
$y--;
|
$y--;
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$f = @ fopen($path, 'rb');
|
$f = @ fopen($path, 'rb');
|
||||||
@fclose($f);
|
@fclose($f);
|
||||||
exit ();
|
exit ();
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
warning:2:7
|
warning:3:7
|
||||||
warning:4:5
|
warning:5:5
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$f = @fopen($path, 'rb');
|
$f = @fopen($path, 'rb');
|
||||||
@fclose($f);
|
@fclose($f);
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class Foo {
|
final class Foo {
|
||||||
public function bar() {}
|
public function bar() {}
|
||||||
final public function baz() {}
|
final public function baz() {}
|
||||||
}
|
}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:13 XHP19
|
error:3:13 XHP19
|
||||||
advice:4:3
|
advice:5:3
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This test is just verifying the parseability of files with a large number
|
// This test is just verifying the parseability of files with a large number
|
||||||
// (>500) of string concatenations. We emit n_CONCATENATION_LIST instead of
|
// (>500) of string concatenations. We emit n_CONCATENATION_LIST instead of
|
||||||
// n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the
|
// n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the
|
||||||
|
@ -43,6 +44,7 @@
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This test is just verifying the parseability of files with a large number
|
// This test is just verifying the parseability of files with a large number
|
||||||
// (>500) of string concatenations. We emit n_CONCATENATION_LIST instead of
|
// (>500) of string concatenations. We emit n_CONCATENATION_LIST instead of
|
||||||
// n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the
|
// n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the
|
||||||
|
|
|
@ -8,7 +8,6 @@ final class A {
|
||||||
$this->f();
|
$this->f();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:3:13 XHP19 Class-Filename Mismatch
|
error:3:13 XHP19 Class-Filename Mismatch
|
||||||
error:8:5 Use of $this in a static method.
|
error:8:5 Use of $this in a static method.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$$foo;
|
$$foo;
|
||||||
$obj->$bar; // okay
|
$obj->$bar; // okay
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:2:1
|
error:3:1
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
'a'.'b';
|
'a'.'b';
|
||||||
'a' + 'b';
|
'a' + 'b';
|
||||||
'a' + $x;
|
'a' + $x;
|
||||||
$x + $y + $z + 'q' + 0;
|
$x + $y + $z + 'q' + 0;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
error:3:1
|
|
||||||
error:4:1
|
error:4:1
|
||||||
error:5:1
|
error:5:1
|
||||||
|
error:6:1
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -146,6 +146,10 @@ abstract class ArcanistXHPASTLinterRule extends Phobject {
|
||||||
$replace);
|
$replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected function raiseLintAtPath($desc) {
|
||||||
|
return $this->linter->raiseLintAtPath($this->getLintID(), $desc);
|
||||||
|
}
|
||||||
|
|
||||||
final protected function raiseLintAtToken(
|
final protected function raiseLintAtToken(
|
||||||
XHPASTToken $token,
|
XHPASTToken $token,
|
||||||
$desc,
|
$desc,
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ArcanistEmptyFileXHPASTLinterRule
|
||||||
|
extends ArcanistXHPASTLinterRule {
|
||||||
|
|
||||||
|
const ID = 82;
|
||||||
|
|
||||||
|
public function getLintName() {
|
||||||
|
return pht('Empty File');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLintSeverity() {
|
||||||
|
return ArcanistLintSeverity::SEVERITY_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(XHPASTNode $root) {
|
||||||
|
$tokens = $root->getTokens();
|
||||||
|
|
||||||
|
foreach ($tokens as $token) {
|
||||||
|
switch ($token->getTypeName()) {
|
||||||
|
case 'T_OPEN_TAG':
|
||||||
|
case 'T_CLOSE_TAG':
|
||||||
|
case 'T_WHITESPACE':
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->raiseLintAtPath(
|
||||||
|
pht("Empty files usually don't serve any useful purpose."));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ArcanistNewlineAfterOpenTagXHPASTLinterRule
|
||||||
|
extends ArcanistXHPASTLinterRule {
|
||||||
|
|
||||||
|
const ID = 81;
|
||||||
|
|
||||||
|
public function getLintName() {
|
||||||
|
return pht('Newline After PHP Open Tag');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLintSeverity() {
|
||||||
|
return ArcanistLintSeverity::SEVERITY_ADVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(XHPASTNode $root) {
|
||||||
|
$tokens = $root->selectTokensOfType('T_OPEN_TAG');
|
||||||
|
|
||||||
|
foreach ($tokens as $token) {
|
||||||
|
for ($next = $token->getNextToken();
|
||||||
|
$next;
|
||||||
|
$next = $next->getNextToken()) {
|
||||||
|
|
||||||
|
if ($next->getTypeName() == 'T_WHITESPACE' &&
|
||||||
|
preg_match('/\n\s*\n/', $next->getValue())) {
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($token->getLineNumber() != $next->getLineNumber()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($next->getTypeName() == 'T_CLOSE_TAG') {
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$next = $token->getNextToken();
|
||||||
|
$this->raiseLintAtToken(
|
||||||
|
$next,
|
||||||
|
pht('`%s` should be separated from code by an empty line.', '<?php'),
|
||||||
|
"\n".$next->getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,6 @@ final class ArcanistUnitTestResult extends Phobject {
|
||||||
const RESULT_SKIP = 'skip';
|
const RESULT_SKIP = 'skip';
|
||||||
const RESULT_BROKEN = 'broken';
|
const RESULT_BROKEN = 'broken';
|
||||||
const RESULT_UNSOUND = 'unsound';
|
const RESULT_UNSOUND = 'unsound';
|
||||||
const RESULT_POSTPONED = 'postponed';
|
|
||||||
|
|
||||||
private $namespace;
|
private $namespace;
|
||||||
private $name;
|
private $name;
|
||||||
|
|
|
@ -28,13 +28,6 @@ final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderPostponedResult($count) {
|
|
||||||
return sprintf(
|
|
||||||
"%s %s\n",
|
|
||||||
$this->getFormattedResult(ArcanistUnitTestResult::RESULT_POSTPONED),
|
|
||||||
pht('%d test(s)', $count));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getFormattedResult($result) {
|
private function getFormattedResult($result) {
|
||||||
switch ($result) {
|
switch ($result) {
|
||||||
case ArcanistUnitTestResult::RESULT_PASS:
|
case ArcanistUnitTestResult::RESULT_PASS:
|
||||||
|
@ -54,11 +47,6 @@ final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer {
|
||||||
'<bg:yellow>** %s **</bg>',
|
'<bg:yellow>** %s **</bg>',
|
||||||
pht('UNSOUND'));
|
pht('UNSOUND'));
|
||||||
|
|
||||||
case ArcanistUnitTestResult::RESULT_POSTPONED:
|
|
||||||
return phutil_console_format(
|
|
||||||
'<bg:yellow>** %s **</bg>',
|
|
||||||
pht('POSTPONED'));
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
|
|
||||||
abstract class ArcanistUnitRenderer extends Phobject {
|
abstract class ArcanistUnitRenderer extends Phobject {
|
||||||
abstract public function renderUnitResult(ArcanistUnitTestResult $result);
|
abstract public function renderUnitResult(ArcanistUnitTestResult $result);
|
||||||
abstract public function renderPostponedResult($count);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ final class ArcanistFileUploader extends Phobject {
|
||||||
|
|
||||||
private $conduit;
|
private $conduit;
|
||||||
private $files;
|
private $files;
|
||||||
|
private $config = array();
|
||||||
|
|
||||||
|
|
||||||
/* -( Configuring the Uploader )------------------------------------------- */
|
/* -( Configuring the Uploader )------------------------------------------- */
|
||||||
|
@ -78,6 +79,33 @@ final class ArcanistFileUploader extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure a file to be temporary instead of permanent.
|
||||||
|
*
|
||||||
|
* By default, files are retained indefinitely until explicitly deleted. If
|
||||||
|
* you want to upload a temporary file instead, you can specify an epoch
|
||||||
|
* timestamp. The file will be deleted after this time.
|
||||||
|
*
|
||||||
|
* @param string Key identifying the file you want to make temporary, as
|
||||||
|
* passed to @{method:addFile}.
|
||||||
|
* @param int Epoch timestamp to retain the file until.
|
||||||
|
* @return this
|
||||||
|
* @task add
|
||||||
|
*/
|
||||||
|
public function setDeleteFileAfterEpoch($file_key, $epoch) {
|
||||||
|
if (empty($this->files[$file_key])) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'No file with given key ("%s") has been added to this uploader.',
|
||||||
|
$file_key));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config[$file_key]['deleteAfterEpoch'] = $epoch;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Uploading Files )---------------------------------------------------- */
|
/* -( Uploading Files )---------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,13 +144,20 @@ final class ArcanistFileUploader extends Phobject {
|
||||||
$conduit = $this->conduit;
|
$conduit = $this->conduit;
|
||||||
$futures = array();
|
$futures = array();
|
||||||
foreach ($files as $key => $file) {
|
foreach ($files as $key => $file) {
|
||||||
$futures[$key] = $conduit->callMethod(
|
$config = idx($this->config, $key, array());
|
||||||
'file.allocate',
|
|
||||||
array(
|
$params = array(
|
||||||
'name' => $file->getName(),
|
'name' => $file->getName(),
|
||||||
'contentLength' => $file->getByteSize(),
|
'contentLength' => $file->getByteSize(),
|
||||||
'contentHash' => $file->getContentHash(),
|
'contentHash' => $file->getContentHash(),
|
||||||
));
|
);
|
||||||
|
|
||||||
|
$delete_after = idx($config, 'deleteAfterEpoch');
|
||||||
|
if ($delete_after !== null) {
|
||||||
|
$params['deleteAfterEpoch'] = $delete_after;
|
||||||
|
}
|
||||||
|
|
||||||
|
$futures[$key] = $conduit->callMethod('file.allocate', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$iterator = id(new FutureIterator($futures))->limit(4);
|
$iterator = id(new FutureIterator($futures))->limit(4);
|
||||||
|
|
|
@ -17,7 +17,6 @@ final class ArcanistDiffWorkflow extends ArcanistWorkflow {
|
||||||
private $testResults;
|
private $testResults;
|
||||||
private $diffID;
|
private $diffID;
|
||||||
private $revisionID;
|
private $revisionID;
|
||||||
private $postponedLinters;
|
|
||||||
private $haveUncommittedChanges = false;
|
private $haveUncommittedChanges = false;
|
||||||
private $diffPropertyFutures = array();
|
private $diffPropertyFutures = array();
|
||||||
private $commitMessageFromRevision;
|
private $commitMessageFromRevision;
|
||||||
|
@ -476,7 +475,6 @@ EOTEXT
|
||||||
|
|
||||||
$lint_result = $data['lintResult'];
|
$lint_result = $data['lintResult'];
|
||||||
$this->unresolvedLint = $data['unresolvedLint'];
|
$this->unresolvedLint = $data['unresolvedLint'];
|
||||||
$this->postponedLinters = $data['postponedLinters'];
|
|
||||||
$unit_result = $data['unitResult'];
|
$unit_result = $data['unitResult'];
|
||||||
$this->testResults = $data['testResults'];
|
$this->testResults = $data['testResults'];
|
||||||
|
|
||||||
|
@ -1032,9 +1030,8 @@ EOTEXT
|
||||||
} catch (ConduitClientException $e) {
|
} catch (ConduitClientException $e) {
|
||||||
if ($e->getErrorCode() == 'ERR-BAD-ARCANIST-PROJECT') {
|
if ($e->getErrorCode() == 'ERR-BAD-ARCANIST-PROJECT') {
|
||||||
echo phutil_console_wrap(
|
echo phutil_console_wrap(
|
||||||
"%s\n",
|
pht('Lookup of encoding in arcanist project failed: %s',
|
||||||
pht('Lookup of encoding in arcanist project failed'),
|
$e->getMessage())."\n");
|
||||||
$e->getMessage());
|
|
||||||
} else {
|
} else {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -1222,7 +1219,6 @@ EOTEXT
|
||||||
return array(
|
return array(
|
||||||
'lintResult' => $lint_result,
|
'lintResult' => $lint_result,
|
||||||
'unresolvedLint' => $this->unresolvedLint,
|
'unresolvedLint' => $this->unresolvedLint,
|
||||||
'postponedLinters' => $this->postponedLinters,
|
|
||||||
'unitResult' => $unit_result,
|
'unitResult' => $unit_result,
|
||||||
'testResults' => $this->testResults,
|
'testResults' => $this->testResults,
|
||||||
);
|
);
|
||||||
|
@ -1290,12 +1286,6 @@ EOTEXT
|
||||||
pht('Lint issued unresolved errors!'),
|
pht('Lint issued unresolved errors!'),
|
||||||
'lint-excuses');
|
'lint-excuses');
|
||||||
break;
|
break;
|
||||||
case ArcanistLintWorkflow::RESULT_POSTPONED:
|
|
||||||
$this->console->writeOut(
|
|
||||||
"<bg:yellow>** %s **</bg> %s\n",
|
|
||||||
pht('LINT POSTPONED'),
|
|
||||||
pht('Lint results are postponed.'));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->unresolvedLint = array();
|
$this->unresolvedLint = array();
|
||||||
|
@ -1303,8 +1293,6 @@ EOTEXT
|
||||||
$this->unresolvedLint[] = $message->toDictionary();
|
$this->unresolvedLint[] = $message->toDictionary();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->postponedLinters = $lint_workflow->getPostponedLinters();
|
|
||||||
|
|
||||||
return $lint_result;
|
return $lint_result;
|
||||||
} catch (ArcanistNoEngineException $ex) {
|
} catch (ArcanistNoEngineException $ex) {
|
||||||
$this->console->writeOut(
|
$this->console->writeOut(
|
||||||
|
@ -2260,7 +2248,6 @@ EOTEXT
|
||||||
ArcanistLintWorkflow::RESULT_ERRORS => 'fail',
|
ArcanistLintWorkflow::RESULT_ERRORS => 'fail',
|
||||||
ArcanistLintWorkflow::RESULT_WARNINGS => 'warn',
|
ArcanistLintWorkflow::RESULT_WARNINGS => 'warn',
|
||||||
ArcanistLintWorkflow::RESULT_SKIP => 'skip',
|
ArcanistLintWorkflow::RESULT_SKIP => 'skip',
|
||||||
ArcanistLintWorkflow::RESULT_POSTPONED => 'postponed',
|
|
||||||
);
|
);
|
||||||
return idx($map, $lint_result, 'none');
|
return idx($map, $lint_result, 'none');
|
||||||
}
|
}
|
||||||
|
@ -2275,7 +2262,6 @@ EOTEXT
|
||||||
ArcanistUnitWorkflow::RESULT_FAIL => 'fail',
|
ArcanistUnitWorkflow::RESULT_FAIL => 'fail',
|
||||||
ArcanistUnitWorkflow::RESULT_UNSOUND => 'warn',
|
ArcanistUnitWorkflow::RESULT_UNSOUND => 'warn',
|
||||||
ArcanistUnitWorkflow::RESULT_SKIP => 'skip',
|
ArcanistUnitWorkflow::RESULT_SKIP => 'skip',
|
||||||
ArcanistUnitWorkflow::RESULT_POSTPONED => 'postponed',
|
|
||||||
);
|
);
|
||||||
return idx($map, $unit_result, 'none');
|
return idx($map, $unit_result, 'none');
|
||||||
}
|
}
|
||||||
|
@ -2680,8 +2666,13 @@ EOTEXT
|
||||||
pht('PUSH STAGING'),
|
pht('PUSH STAGING'),
|
||||||
pht('Pushing changes to staging area...'));
|
pht('Pushing changes to staging area...'));
|
||||||
|
|
||||||
|
$push_flags = array();
|
||||||
|
if (version_compare($api->getGitVersion(), '1.8.2', '>=')) {
|
||||||
|
$push_flags[] = '--no-verify';
|
||||||
|
}
|
||||||
$err = phutil_passthru(
|
$err = phutil_passthru(
|
||||||
'git push --no-verify -- %s %s:refs/tags/%s',
|
'git push %Ls -- %s %s:refs/tags/%s',
|
||||||
|
$push_flags,
|
||||||
$staging_uri,
|
$staging_uri,
|
||||||
$commit,
|
$commit,
|
||||||
$tag);
|
$tag);
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class ArcanistLintWorkflow extends ArcanistWorkflow {
|
||||||
const RESULT_WARNINGS = 1;
|
const RESULT_WARNINGS = 1;
|
||||||
const RESULT_ERRORS = 2;
|
const RESULT_ERRORS = 2;
|
||||||
const RESULT_SKIP = 3;
|
const RESULT_SKIP = 3;
|
||||||
const RESULT_POSTPONED = 4;
|
|
||||||
|
|
||||||
const DEFAULT_SEVERITY = ArcanistLintSeverity::SEVERITY_ADVICE;
|
const DEFAULT_SEVERITY = ArcanistLintSeverity::SEVERITY_ADVICE;
|
||||||
|
|
||||||
|
@ -19,7 +18,6 @@ final class ArcanistLintWorkflow extends ArcanistWorkflow {
|
||||||
private $shouldAmendWithoutPrompt = false;
|
private $shouldAmendWithoutPrompt = false;
|
||||||
private $shouldAmendAutofixesWithoutPrompt = false;
|
private $shouldAmendAutofixesWithoutPrompt = false;
|
||||||
private $engine;
|
private $engine;
|
||||||
private $postponedLinters;
|
|
||||||
|
|
||||||
public function getWorkflowName() {
|
public function getWorkflowName() {
|
||||||
return 'lint';
|
return 'lint';
|
||||||
|
@ -399,12 +397,6 @@ EOTEXT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It'd be nice to just return a single result from the run method above
|
|
||||||
// which contains both the lint messages and the postponed linters.
|
|
||||||
// However, to maintain compatibility with existing lint subclasses, use
|
|
||||||
// a separate method call to grab the postponed linters.
|
|
||||||
$this->postponedLinters = $engine->getPostponedLinters();
|
|
||||||
|
|
||||||
if ($this->getArgument('never-apply-patches')) {
|
if ($this->getArgument('never-apply-patches')) {
|
||||||
$apply_patches = false;
|
$apply_patches = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -650,8 +642,6 @@ EOTEXT
|
||||||
$result_code = self::RESULT_ERRORS;
|
$result_code = self::RESULT_ERRORS;
|
||||||
} else if ($has_warnings) {
|
} else if ($has_warnings) {
|
||||||
$result_code = self::RESULT_WARNINGS;
|
$result_code = self::RESULT_WARNINGS;
|
||||||
} else if (!empty($this->postponedLinters)) {
|
|
||||||
$result_code = self::RESULT_POSTPONED;
|
|
||||||
} else {
|
} else {
|
||||||
$result_code = self::RESULT_OKAY;
|
$result_code = self::RESULT_OKAY;
|
||||||
}
|
}
|
||||||
|
@ -669,8 +659,4 @@ EOTEXT
|
||||||
return $this->unresolvedMessages;
|
return $this->unresolvedMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostponedLinters() {
|
|
||||||
return $this->postponedLinters;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class ArcanistUnitWorkflow extends ArcanistWorkflow {
|
||||||
const RESULT_UNSOUND = 1;
|
const RESULT_UNSOUND = 1;
|
||||||
const RESULT_FAIL = 2;
|
const RESULT_FAIL = 2;
|
||||||
const RESULT_SKIP = 3;
|
const RESULT_SKIP = 3;
|
||||||
const RESULT_POSTPONED = 4;
|
|
||||||
|
|
||||||
private $unresolvedTests;
|
private $unresolvedTests;
|
||||||
private $testResults;
|
private $testResults;
|
||||||
|
@ -175,19 +174,13 @@ EOTEXT
|
||||||
|
|
||||||
$unresolved = array();
|
$unresolved = array();
|
||||||
$coverage = array();
|
$coverage = array();
|
||||||
$postponed_count = 0;
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$result_code = $result->getResult();
|
$result_code = $result->getResult();
|
||||||
if ($result_code == ArcanistUnitTestResult::RESULT_POSTPONED) {
|
if ($this->engine->shouldEchoTestResults()) {
|
||||||
$postponed_count++;
|
$console->writeOut('%s', $renderer->renderUnitResult($result));
|
||||||
|
}
|
||||||
|
if ($result_code != ArcanistUnitTestResult::RESULT_PASS) {
|
||||||
$unresolved[] = $result;
|
$unresolved[] = $result;
|
||||||
} else {
|
|
||||||
if ($this->engine->shouldEchoTestResults()) {
|
|
||||||
$console->writeOut('%s', $renderer->renderUnitResult($result));
|
|
||||||
}
|
|
||||||
if ($result_code != ArcanistUnitTestResult::RESULT_PASS) {
|
|
||||||
$unresolved[] = $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($result->getCoverage()) {
|
if ($result->getCoverage()) {
|
||||||
foreach ($result->getCoverage() as $file => $report) {
|
foreach ($result->getCoverage() as $file => $report) {
|
||||||
|
@ -195,11 +188,6 @@ EOTEXT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($postponed_count) {
|
|
||||||
$console->writeOut(
|
|
||||||
'%s',
|
|
||||||
$renderer->renderPostponedResult($postponed_count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($coverage) {
|
if ($coverage) {
|
||||||
$file_coverage = array_fill_keys(
|
$file_coverage = array_fill_keys(
|
||||||
|
@ -252,9 +240,6 @@ EOTEXT
|
||||||
break;
|
break;
|
||||||
} else if ($result_code == ArcanistUnitTestResult::RESULT_UNSOUND) {
|
} else if ($result_code == ArcanistUnitTestResult::RESULT_UNSOUND) {
|
||||||
$overall_result = self::RESULT_UNSOUND;
|
$overall_result = self::RESULT_UNSOUND;
|
||||||
} else if ($result_code == ArcanistUnitTestResult::RESULT_POSTPONED &&
|
|
||||||
$overall_result != self::RESULT_UNSOUND) {
|
|
||||||
$overall_result = self::RESULT_POSTPONED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ EOTEXT
|
||||||
'json' => array(
|
'json' => array(
|
||||||
'help' => pht('Output upload information in JSON format.'),
|
'help' => pht('Output upload information in JSON format.'),
|
||||||
),
|
),
|
||||||
|
'temporary' => array(
|
||||||
|
'help' => pht(
|
||||||
|
'Mark the file as temporary. Temporary files will be deleted '.
|
||||||
|
'automatically after 24 hours.'),
|
||||||
|
),
|
||||||
'*' => 'paths',
|
'*' => 'paths',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,18 +56,26 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
|
$is_temporary = $this->getArgument('temporary');
|
||||||
|
|
||||||
$conduit = $this->getConduit();
|
$conduit = $this->getConduit();
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$uploader = id(new ArcanistFileUploader())
|
$uploader = id(new ArcanistFileUploader())
|
||||||
->setConduitClient($conduit);
|
->setConduitClient($conduit);
|
||||||
|
|
||||||
foreach ($this->paths as $path) {
|
foreach ($this->paths as $key => $path) {
|
||||||
$file = id(new ArcanistFileDataRef())
|
$file = id(new ArcanistFileDataRef())
|
||||||
->setName(basename($path))
|
->setName(basename($path))
|
||||||
->setPath($path);
|
->setPath($path);
|
||||||
|
|
||||||
$uploader->addFile($file);
|
$uploader->addFile($file, $key);
|
||||||
|
|
||||||
|
if ($is_temporary) {
|
||||||
|
$uploader->setDeleteFileAfterEpoch(
|
||||||
|
$key,
|
||||||
|
time() + phutil_units('24 hours in seconds'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = $uploader->uploadFiles();
|
$files = $uploader->uploadFiles();
|
||||||
|
|
|
@ -1585,12 +1585,11 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
} catch (ConduitClientException $ex) {
|
} catch (ConduitClientException $ex) {
|
||||||
if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') {
|
if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') {
|
||||||
echo phutil_console_wrap(
|
echo phutil_console_wrap(
|
||||||
"%s\n\n",
|
|
||||||
pht(
|
pht(
|
||||||
'This feature requires a newer version of Phabricator. Please '.
|
'This feature requires a newer version of Phabricator. Please '.
|
||||||
'update it using these instructions: %s',
|
'update it using these instructions: %s',
|
||||||
'https://secure.phabricator.com/book/phabricator/article/'.
|
'https://secure.phabricator.com/book/phabricator/article/'.
|
||||||
'upgrading/'));
|
'upgrading/')."\n\n");
|
||||||
}
|
}
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue