]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
11 years agoImprove the "inline HTML" linter rule
Joshua Spence [Wed, 19 Aug 2015 05:34:43 +0000 (15:34 +1000)]
Improve the "inline HTML" linter rule

Summary: Improve `ArcanistInlineHTMLXHPASTLinterRule` such that it doesn't raise duplicate warnings. Also be a bit more lax with whitespace.

Test Plan: Unit tests now pass.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13896

11 years agoAdd a linter rule for the use of `parse_str`
Joshua Spence [Thu, 13 Aug 2015 21:44:19 +0000 (07:44 +1000)]
Add a linter rule for the use of `parse_str`

Summary: The use of the [[http://php.net/manual/en/function.parse-str.php | parse_str]] method (when called without sepcifying a second parameter) hinders static analysis. Specifically, the `parse_str('...')` behaves similarly to [[http://php.net/manual/en/function.extract.php | extract]].

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13857

11 years agoAdd a linter rule for inline HTML
Joshua Spence [Thu, 13 Aug 2015 21:41:41 +0000 (07:41 +1000)]
Add a linter rule for inline HTML

Summary: Ref T7409. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php | InlineHTMLSniff]].

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T9140, T7409

Differential Revision: https://secure.phabricator.com/D13871

11 years agoAdd a linter rule for global variables
Joshua Spence [Thu, 13 Aug 2015 21:37:48 +0000 (07:37 +1000)]
Add a linter rule for global variables

Summary: Ref T7409. Global variables are gross and should be avoided like the plague.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T7409

Differential Revision: https://secure.phabricator.com/D13882

11 years agoAdd a linter rule for list assignments
Joshua Spence [Wed, 12 Aug 2015 03:22:37 +0000 (13:22 +1000)]
Add a linter rule for list assignments

Summary: Add a linter rule to prevent trailing commas in a list assignment. `list($x, $y,)` is equivalent to `list($x, $y)`, but the latter is cleaner and should be preferred.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13870

11 years agoRestore default "yes" behavior for lint patch
Aiden Scandella [Tue, 11 Aug 2015 21:49:48 +0000 (14:49 -0700)]
Restore default "yes" behavior for lint patch

Summary:
Fixes T9029

See T9029 for more details, but basically at some point phutil_console_confirm
(which takes a `$default_no` parameter) was refactored to `$console->confirm()`
which takes a `$default` parameter with semantics negated..

Test Plan:
Run `arc lint` on a repository where patch is suggested. Default
option should be "[Y/n]" to accept the patch.

Reviewers: joshuaspence, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T9029

Differential Revision: https://secure.phabricator.com/D13873

11 years agoMove a test file
Joshua Spence [Tue, 11 Aug 2015 12:50:57 +0000 (22:50 +1000)]
Move a test file

Summary: This is a test case for `ArcanistXHPASTLinter`, not `ArcanistPhutilXHPASTLinter`.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13866

11 years agoFix `arc unit --everything`
Joshua Spence [Tue, 11 Aug 2015 12:37:28 +0000 (22:37 +1000)]
Fix `arc unit --everything`

Summary: This was broken in D13573.

Test Plan: Ran `arc unit --everything` in rPHU.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13864

11 years agoVarious linter fixes
Joshua Spence [Tue, 11 Aug 2015 12:35:40 +0000 (22:35 +1000)]
Various linter fixes

Summary: Self explanatory.

Test Plan: `arc lint`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13861

11 years agoImprove linter rules for array formatting
Joshua Spence [Tue, 11 Aug 2015 12:34:38 +0000 (22:34 +1000)]
Improve linter rules for array formatting

Summary: Modify `ArcanistParenthesesSpacingXHPASTLinterRule` and `ArcanistCallParenthesesXHPASTLinterRule` to apply to `array()` and `list()` as well. Depends on D13858.

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13859

11 years agoFix failing JSHint linter test
Joshua Spence [Tue, 11 Aug 2015 12:33:12 +0000 (22:33 +1000)]
Fix failing JSHint linter test

Summary: This test case is failing on JSHint v2.8.0.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13860

11 years agoPreserve more information when merging coverage
epriestley [Mon, 10 Aug 2015 22:35:15 +0000 (15:35 -0700)]
Preserve more information when merging coverage

Summary:
Ref T8096. Each test reports coverage information, which we sometimes merge into a combined coverage report.

Usually, each test will report results for every line in the file, so if the file is 30 lines long, coverage is usually 30 characters long.

However, for whatever reason, tests might report results for only the first part of the file. This is allowed and we handle it properly.

Right now, if one test reports 10 lines of results and another reports 30 lines of results, we only use the first 10 lines of results. Instead, extend the merged coverage to include the extra 20 lines of results.

(This is an uncommon case which I only hit because I was manually banging on my keyboard to generate test data, but there's no reason not to handle it better.)

Test Plan: Used web UI, added + executed unit tests.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8096

Differential Revision: https://secure.phabricator.com/D13854

11 years agoAutomatically use the configuration driven unit test engine
Joshua Spence [Mon, 10 Aug 2015 21:55:38 +0000 (07:55 +1000)]
Automatically use the configuration driven unit test engine

Summary: Ref T5568. Use the `ArcanistConfigurationDrivenUnitTestEngine` automatically, if an `.arcunit` file exists. This behavior mimics the auto-detection for the configuration driven lint engine.

Test Plan:
Ran through the following scenarios:

  - Ran `arc unit` and saw unit tests execute.
  - Ran `arc unit --engine PhutilUnitTestEngine`
  - Remove the `.arcunit` file and ran `arc unit`... got an exception.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T5568

Differential Revision: https://secure.phabricator.com/D13855

11 years agoMinor improvement for array value linter rule
Joshua Spence [Mon, 10 Aug 2015 21:55:11 +0000 (07:55 +1000)]
Minor improvement for array value linter rule

Summary:
This linter rule fails on multi-line arrays with no whitespace before the first array value. Specifically, the following exception is thrown:

```
Fatal error: Call to a member function isAnyWhitespace() on boolean in arcanist/src/lint/linter/xhpast/rules/ArcanistArrayValueXHPASTLinterRule.php on line 40
```

Test Plan: Added another test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13856

11 years agoAdd a linter rule for array elements
Joshua Spence [Mon, 10 Aug 2015 20:58:28 +0000 (06:58 +1000)]
Add a linter rule for array elements

Summary: Add a linter rule to ensure that array elements occupy a single line each.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13842

11 years agoRough version of configuration driven unit test engine
Joshua Spence [Mon, 10 Aug 2015 20:54:15 +0000 (06:54 +1000)]
Rough version of configuration driven unit test engine

Summary: Ref T5568. As discussed in IRC. This is very rough and not widely useable, but represents a solid first step.

Test Plan: Ran `arc unit` with a bunch of flags.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: rfreebern, aripringle, jaydiablo, BYK, tycho.tatitscheff, epriestley, Korvin

Maniphest Tasks: T5568

Differential Revision: https://secure.phabricator.com/D13579

11 years agoUse PhutilClassMapQuery instead of PhutilSymbolLoader
Joshua Spence [Mon, 10 Aug 2015 20:50:47 +0000 (06:50 +1000)]
Use PhutilClassMapQuery instead of PhutilSymbolLoader

Summary: Use `PhutilClassMapQuery` instead of `PhutilSymbolLoader`, mainly for consistency. Depends on D13572.

Test Plan: This hasn't been tested very comphrehensively as of yet.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13573

11 years agoFix self member reference rule for PHP 5.3
Joshua Spence [Mon, 10 Aug 2015 20:49:54 +0000 (06:49 +1000)]
Fix self member reference rule for PHP 5.3

Summary:
Fixes T8674. Currently, `ArcanistSelfMemberReferenceXHPASTLinterRule` warns if a fully-qualified class name is used in place of `self`. This is fine in most cases, but in some specific scenarios fails for PHP 5.3 because `self` (and also `$this`) cannot be used in an anonymous closure (see [[http://php.net/manual/en/functions.anonymous.php | anonymous functions]] and [[https://wiki.php.net/rfc/closures/removal-of-this | removal of `$this` in closures]]).

In order to do this, I also had to modify the manner in which configuration was passed to individual linter rule. Previously, it was only possible or an individual linter rule to be set with a configuration value. Once the linter rule had set this value, there was no means by which to allow this value to be shared amongst linter rules.

Depends on D13819.

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T8674

Differential Revision: https://secure.phabricator.com/D13820

11 years agoImprove useless overriding method linter rule
Joshua Spence [Mon, 10 Aug 2015 20:49:20 +0000 (06:49 +1000)]
Improve useless overriding method linter rule

Summary:
Improve `ArcanistUselessOverridingMethodXHPASTLinterRule` by allowing overriding methods which set default values. For example, the following scenario is perfectly valid:

```lang=php

class SomeClass {
  public function __construct($x) {}
}

class SomeOtherClass extends Class {
  public function __construct($x = null) {
    parent::__construct($x);
  }
}
```

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13840

11 years agoImprove PHP compatibility linter
Joshua Spence [Mon, 10 Aug 2015 20:48:56 +0000 (06:48 +1000)]
Improve PHP compatibility linter

Summary: Ref T8674. Adds to `ArcanistPHPCompatibilityXHPASTLinterRule` such that an error is raised whenever `self` or `$this` is used in an anonymous closure prior to PHP 5.4.

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T8674

Differential Revision: https://secure.phabricator.com/D13841

11 years agoImprove declaration formatting linter rule for anonymous functions
Joshua Spence [Sat, 8 Aug 2015 13:30:24 +0000 (23:30 +1000)]
Improve declaration formatting linter rule for anonymous functions

Summary: Ref T8742. Anonymous functions should have a space after the `function` keyword. Additionally, ensure that there is a space before and after the `use` token.

Test Plan: Modified existing test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T8742

Differential Revision: https://secure.phabricator.com/D13804

11 years agoMinor linter fix
Joshua Spence [Sat, 8 Aug 2015 00:18:59 +0000 (10:18 +1000)]
Minor linter fix

Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13807

11 years agoAdd a linter rule for unary postfix expression spacing
Joshua Spence [Thu, 6 Aug 2015 01:38:14 +0000 (11:38 +1000)]
Add a linter rule for unary postfix expression spacing

Summary: Unary postfix expressions should not have a space before the operator.

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13805

11 years agoAdd a linter rule for object operator spacing
Joshua Spence [Wed, 5 Aug 2015 21:14:38 +0000 (07:14 +1000)]
Add a linter rule for object operator spacing

Summary: Add a linter rule to check that there is no whitespace surrounding the object operator, `->`.

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13798

11 years agoAdd a linter rule for unary prefix expression spacing
Joshua Spence [Wed, 5 Aug 2015 21:00:32 +0000 (07:00 +1000)]
Add a linter rule for unary prefix expression spacing

Summary: Add a linter rule to ensure that there is no space between the operator and the operand in a unary prefix expression.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13797

11 years agoAdd a linter rule for spacing before opening parenthesis in function calls
Joshua Spence [Wed, 5 Aug 2015 20:57:46 +0000 (06:57 +1000)]
Add a linter rule for spacing before opening parenthesis in function calls

Summary: Repurpose `ArcanistClosingCallParenthesesXHPASTLinterRule` (and rename it to `ArcanistCallParenthesesXHPASTLinterRule`) to ensure that there is no spacing before opening parenthesis in function calls.

Test Plan: Added test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13796

11 years agoImprove undeclared variables linter rule
Joshua Spence [Wed, 5 Aug 2015 20:57:16 +0000 (06:57 +1000)]
Improve undeclared variables linter rule

Summary: Currently `ArcanistUndeclaredVariableXHPASTLinterRule` does not properly handle anonymous closures.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: johnny-bit, Korvin

Differential Revision: https://secure.phabricator.com/D13795

11 years agoAllow closing tags in files containing HTML
Joshua Spence [Wed, 5 Aug 2015 20:56:26 +0000 (06:56 +1000)]
Allow closing tags in files containing HTML

Summary: Ref T8742. PHP files which contain inline HTML should be allowed to use PHP closing tags (`?>`). This is in accordance with [[https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md | PSR-2 guidelines]].

Test Plan: Updated unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T8742

Differential Revision: https://secure.phabricator.com/D13794

11 years agoAdd more information about Harbormaster/Unit result codes to Arcanist
epriestley [Tue, 4 Aug 2015 20:05:38 +0000 (13:05 -0700)]
Add more information about Harbormaster/Unit result codes to Arcanist

Summary: Ref T7419. This makes it easier to render helpful documentation in the next diff without having to copy/paste things.

Test Plan:
In next diff:

{F688894}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7419

Differential Revision: https://secure.phabricator.com/D13788

11 years agoFix some failing unit tests
Joshua Spence [Sun, 2 Aug 2015 20:47:47 +0000 (06:47 +1000)]
Fix some failing unit tests

Summary: I somehow missed these.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13693

11 years agoFix an undeclared property
Joshua Spence [Sun, 2 Aug 2015 20:47:20 +0000 (06:47 +1000)]
Fix an undeclared property

Summary: `NoseTestEngine::$parser` is undefined.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13760

11 years agoAlso coerce "char" for lint messages
epriestley [Tue, 28 Jul 2015 23:31:03 +0000 (16:31 -0700)]
Also coerce "char" for lint messages

Summary: Ref T8921. See similar change in D13695. This expands the scope to also coerce `setChar()`.

Test Plan: `arc unit --everything`

Reviewers: btrahan

Subscribers: epriestley

Maniphest Tasks: T8921

Differential Revision: https://secure.phabricator.com/D13737

11 years agoAdd $projectRoot to PytestTestEngine
Lukas Sparrow [Fri, 24 Jul 2015 12:11:32 +0000 (05:11 -0700)]
Add $projectRoot to PytestTestEngine

Summary:
Fixes T8912. Property `$project_root` was missing in `PytestTestEngine` class, resulting in
broken py.test wrapper. Also renaming the property so the linter is happy.

Test Plan: `arc unit --everything`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: kparal, epriestley, Korvin

Maniphest Tasks: T8912

Differential Revision: https://secure.phabricator.com/D13698

11 years agoImprove strictness around `setLine()` types in ArcanistLintMessage
epriestley [Thu, 23 Jul 2015 20:19:53 +0000 (13:19 -0700)]
Improve strictness around `setLine()` types in ArcanistLintMessage

Summary: Fixes T8921. Harbormaster is strict about types it accepts, but `ArcanistLintMessage` is more liberal. Push the strictness barrier down to the linter level, while maintaining reasonable flexibility in the API.

Test Plan: `arc unit --everything`

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T8921

Differential Revision: https://secure.phabricator.com/D13695

11 years agoFix checkstyle severities
Joshua Spence [Wed, 22 Jul 2015 23:09:33 +0000 (09:09 +1000)]
Fix checkstyle severities

Summary: "Advice" is not a valid severity for Checkstyle... valid severities are `ignore`, `info`, `warning` and `error`.

Test Plan: Read the [[http://checkstyle.sourceforge.net/property_types.html | documentation]].

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13684

11 years agoImprove the declaration parentheses linting
Joshua Spence [Wed, 22 Jul 2015 20:43:35 +0000 (06:43 +1000)]
Improve the declaration parentheses linting

Summary: Improve `ArcanistClosingDeclarationParenthesesXHPASTLinterRule` (and rename it to `ArcanistDeclarationParenthesesXHPASTLinterRule`) to ensure that there is no whitespace before the opening parenthesis of a function/method declaration.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13675

11 years agoFix typo. Closes T8915.
Yomi [Tue, 21 Jul 2015 18:14:39 +0000 (11:14 -0700)]
Fix typo. Closes T8915.

Summary:
From 'or' to 'are'.
Closes T8915.

Test Plan: Wait 30 seconds.

Reviewers: joshuaspence, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8915

Differential Revision: https://secure.phabricator.com/D13664

11 years agoFix brace formatting linter rule
Joshua Spence [Fri, 17 Jul 2015 06:40:45 +0000 (16:40 +1000)]
Fix brace formatting linter rule

Summary: Fixes T8847.

Test Plan:
Ran `arc lint` on a test file:

```lang=php
<?php

if ($x) {
  echo 'foo';
}else {
  echo 'bar';
}
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8847

Differential Revision: https://secure.phabricator.com/D13633

11 years agoFix unitialized variable in ArcanistPhpunitTestResultParser
Sebastian Szulc [Thu, 16 Jul 2015 20:40:04 +0000 (13:40 -0700)]
Fix unitialized variable in ArcanistPhpunitTestResultParser

Summary:
This is to fix `arc unit` when running a test file with no test results (e.g. skipped)
```
EXCEPTION: (RuntimeException) Undefined variable: last_test_finished at [<phutil>/src/error/PhutilErrorHandler.php:210]
arcanist(head=master, ref.master=d54cb072facd), deviantart(), phutil(head=master, ref.master=75f675747648)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<arcanist>/src/unit/parser/ArcanistPhpunitTestResultParser.php:95]
  #1 ArcanistPhpunitTestResultParser::parseTestResults(string, string) called at [<deviantart>/unit/DaUnitEngine.php:150]
  #2 DaUnitEngine::parseTestResults(string, TempFile, string, string) called at [<deviantart>/unit/DaUnitEngine.php:82]
  #3 DaUnitEngine::run() called at [<arcanist>/src/workflow/ArcanistUnitWorkflow.php:186]
  #4 ArcanistUnitWorkflow::run() called at [<arcanist>/scripts/arcanist.php:382]
```

Test Plan: Create a test file with skipped tests. Run `arc unit`. Make sure the exception is not thrown.

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D13640

11 years agoMake test result parsing stricter about duration formats
epriestley [Wed, 15 Jul 2015 20:26:15 +0000 (13:26 -0700)]
Make test result parsing stricter about duration formats

Summary: Fixes T8805. Explicitly require int/float for duration. Adjust XUnit/Go parsers to provide one.

Test Plan: Ran unit tests.

Reviewers: btrahan, joshuaspence, chad

Reviewed By: chad

Subscribers: jsotuyod, champo, epriestley

Maniphest Tasks: T8805

Differential Revision: https://secure.phabricator.com/D13637

11 years agoOutput lint XML results to a file
Joshua Spence [Tue, 14 Jul 2015 20:57:39 +0000 (06:57 +1000)]
Output lint XML results to a file

Summary:
Ref T8332. I find it really odd that I need to run `arc lint --everything --output xml > checkstyle.xml` and feel that it would be much more intuitive to just run `arc lint --everything --output xml` and have the output written to `checkstyle.xml`.

To provide context, we are running `arc lint --everything` in a CI job and parsing the results.

Test Plan: Ran `arc lint --everything --output xml` and saw the output written to file.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8332

Differential Revision: https://secure.phabricator.com/D13570

11 years agoRemove verbose output from `arc lint --trace`
Joshua Spence [Wed, 8 Jul 2015 10:03:00 +0000 (20:03 +1000)]
Remove verbose output from `arc lint --trace`

Summary: I think that this output was used during the early stage of `ArcanistConfigurationDrivenLintEngine`, but I question it's value nowadays. In particular, I find that this output makes the output of `arc lint --trace` significantly less useful.

Test Plan: Ran `./bin/arc lint --trace` and saw useful output.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13593

11 years agoMinor performance optimization
Joshua Spence [Wed, 8 Jul 2015 08:32:08 +0000 (18:32 +1000)]
Minor performance optimization

Summary: Avoid using `idx` in `PhutilTestCase::endCoverage`.

Test Plan: Compared [[https://secure.phabricator.com/xhprof/profile/PHID-FILE-tgmc6ci74daivtankuck/?symbol=idx | before]] and [[https://secure.phabricator.com/xhprof/profile/PHID-FILE-nd77mled6xnezyxidd6m/?symbol=idx | after]].

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13595

11 years agoUpdate references to "www.phabricator.com" in Arcanist
epriestley [Tue, 7 Jul 2015 20:34:56 +0000 (13:34 -0700)]
Update references to "www.phabricator.com" in Arcanist

Summary: This host is no longer in service.

Test Plan: `git grep -i www.phabricator.com`

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D13586

11 years agoUse PhutilClassMapQuery
Joshua Spence [Tue, 7 Jul 2015 09:22:12 +0000 (19:22 +1000)]
Use PhutilClassMapQuery

Summary: Use `PhutilClassMapQuery` where appropriate.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13428

11 years agoLinter performance optimization
Joshua Spence [Tue, 7 Jul 2015 07:56:12 +0000 (17:56 +1000)]
Linter performance optimization

Summary: Optimize `ArcanistXHPASTLinterRule::getLintID`.

Test Plan: Compare [[https://secure.phabricator.com/xhprof/profile/PHID-FILE-wwgi4xzupt4z2fvbyff3/?symbol=mpull | before]] and [[https://secure.phabricator.com/xhprof/profile/PHID-FILE-rn2ialomtr2apnkzisb3/?symbol=mpull | after]].

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13541

11 years agoRaise a more tailored error message when a third-party test engine returns bad results
epriestley [Wed, 1 Jul 2015 11:48:52 +0000 (04:48 -0700)]
Raise a more tailored error message when a third-party test engine returns bad results

Summary: Fixes T8714. When a test engine isn't returning the correct result type, shift suspicion onto it.

Test Plan: Faked error, got exception blaming test engine.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8714

Differential Revision: https://secure.phabricator.com/D13486

11 years agoDon't fail lint builds for "advice"; make lint/unit upload failures louder
epriestley [Thu, 25 Jun 2015 17:05:54 +0000 (10:05 -0700)]
Don't fail lint builds for "advice"; make lint/unit upload failures louder

Summary:
Ref T8670. Ref T8657.

  - When lint only has advice (no warnings/errors), consider it a "passing" build.
  - Be a little louder about `sendmessage` calls failing because this stuff is not totally broken and that makes T8670-related things easier to catch/fix.

Test Plan: Created this revision.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8657, T8670

Differential Revision: https://secure.phabricator.com/D13436

11 years agoReturn `$this` from setter methods
Joshua Spence [Thu, 25 Jun 2015 12:30:33 +0000 (22:30 +1000)]
Return `$this` from setter methods

Summary: Return `$this` from a bunch of setter methods for consistency. See also D13422.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13423

11 years agoEnsure that a space is used after a catch token
Joshua Spence [Wed, 24 Jun 2015 21:09:17 +0000 (07:09 +1000)]
Ensure that a space is used after a catch token

Summary: For consistency, a single space should separate `catch` and the following parenthetical expression.

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13389

11 years agoTry to ship lint and unit results to Harbormaster autotargets
epriestley [Tue, 23 Jun 2015 17:22:57 +0000 (10:22 -0700)]
Try to ship lint and unit results to Harbormaster autotargets

Summary:
Ref T8095. Before uploading lint/unit results in the old way, try to ship them to autotargets.

If we can query and upload data to autotargets, do so, and then skip the older style uploads.

Test Plan: Used `arc diff` to ship data up via Harbormaster.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8095

Differential Revision: https://secure.phabricator.com/D13381

11 years agoFix arcanist shell completion
Joshua Spence [Fri, 19 Jun 2015 03:15:43 +0000 (13:15 +1000)]
Fix arcanist shell completion

Summary: Fixes T8560.

Test Plan: Ran `arc shell-complete` outside of a working copy.

Reviewers: avivey, #blessed_reviewers, epriestley

Reviewed By: avivey, #blessed_reviewers, epriestley

Subscribers: avivey, epriestley, Korvin

Maniphest Tasks: T8560

Differential Revision: https://secure.phabricator.com/D13338

11 years agoUse PhutilInvalidStateException
Joshua Spence [Thu, 18 Jun 2015 12:41:29 +0000 (22:41 +1000)]
Use PhutilInvalidStateException

Summary: Use `PhutilInvalidStateException` where appropriate.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13333

11 years agoFix missing property on ArcanistTestResultParser
epriestley [Mon, 15 Jun 2015 20:59:54 +0000 (13:59 -0700)]
Fix missing property on ArcanistTestResultParser

Fixes T8554 (properly, this time).

Auditors: joshuaspence

11 years agoFix missing property in ArcanistPhpunitTestResultParser
epriestley [Mon, 15 Jun 2015 20:39:00 +0000 (13:39 -0700)]
Fix missing property in ArcanistPhpunitTestResultParser

Fixes T8554.

Auditors: joshuaspence

11 years agoAdd some tests for subclasses
Joshua Spence [Mon, 15 Jun 2015 10:00:54 +0000 (20:00 +1000)]
Add some tests for subclasses

Summary: Add some tests to ensure that `ArcanistXHPASTLinterRule` subclasses are properly implemented. This should catch issues such as two linter rules having the same `ID` value. See D13272 for a similar change.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13274

11 years agoExtend from Phobject
Joshua Spence [Mon, 15 Jun 2015 05:45:13 +0000 (15:45 +1000)]
Extend from Phobject

Summary: All base classes should extend from `Phobject` or some other classes. See D13275 for some explanation.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13281

11 years agoAdd a linter rule for extending Phobject
Joshua Spence [Mon, 15 Jun 2015 05:44:00 +0000 (15:44 +1000)]
Add a linter rule for extending Phobject

Summary: If I understand correctly, all classes should extend from `Phobject`?

Test Plan: This needs some further work

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13275

11 years agoRemove "@stable" annotation
Joshua Spence [Sun, 14 Jun 2015 21:51:43 +0000 (07:51 +1000)]
Remove "@stable" annotation

Summary: I don't believe that `@stable` is useful anymore?

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13285

11 years agoFurther improvements to test discovery
Joshua Spence [Sun, 14 Jun 2015 21:23:17 +0000 (07:23 +1000)]
Further improvements to test discovery

Summary: I found another issue with T8042... it seems that tests from the root directory (i.e. `src/__tests__` are not being discovered properly). The handling of this case (`$library_path` being the library root directory) can probably be improved, and I am open to suggestions. Depends on D13202.

Test Plan: Added to existing test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D13185

11 years agoMark some strings for translation
Joshua Spence [Mon, 8 Jun 2015 21:17:39 +0000 (07:17 +1000)]
Mark some strings for translation

Summary: Add some more `pht`izations.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D13198

11 years agoMinor documentation improvements
Joshua Spence [Mon, 8 Jun 2015 01:31:35 +0000 (11:31 +1000)]
Minor documentation improvements

Summary: Minor tidying of documentation and adding some groups.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D13135

11 years agoImprove test discovery with PhutilUnitTestEngine
Joshua Spence [Wed, 3 Jun 2015 11:07:17 +0000 (21:07 +1000)]
Improve test discovery with PhutilUnitTestEngine

Summary:
Ref T8042. Tests were not being discovered in two different scenarios:

  # Files modified at the same level as the library root directory.
  # "Normal" directories like `src/unit/engine`.

This regression was caused by D12689.

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8042

Differential Revision: https://secure.phabricator.com/D13126

11 years agoLinter fixes
Joshua Spence [Tue, 2 Jun 2015 12:13:21 +0000 (22:13 +1000)]
Linter fixes

Summary: Apply various minor linter fixes.

Test Plan: `arc lint`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aurelijus, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D13106

11 years agoFix a translation ("to ignore these changes...")
epriestley [Mon, 1 Jun 2015 13:50:46 +0000 (06:50 -0700)]
Fix a translation ("to ignore these changes...")

Summary: Fixes T8374.

Test Plan:
```
$ arc diff
You have untracked files in this working copy.

  Working copy: /Users/epriestley/dev/core/lib/arcanist/

  Untracked changes in working copy:
  (To ignore this change, add it to ".git/info/exclude".)
    derp

    Ignore this untracked file and continue? [y/N] ^C
```

Reviewers: btrahan, joshuaspence, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T8374

Differential Revision: https://secure.phabricator.com/D13096

11 years agoSplit the `ArcanistXHPASTLinter` into modular rules
Joshua Spence [Mon, 1 Jun 2015 05:49:16 +0000 (15:49 +1000)]
Split the `ArcanistXHPASTLinter` into modular rules

Summary:
The `ArcanistXHPASTLinter` class is becoming quite bloated. This diff separates the class into one-class-per-rule, which makes everything much more modular. One downside to this decoupling is that code reuse between linter rules is much more difficult, although this only affects a very small number of linter rules.

There is still some further work that could be done here, but I defer this until a later diff:

  - Rewrite `ArcanistPhutilXHPASTLinter` using `ArcanistXHPASTLinterRule`.
  - Change the unit tests so that they are truly only testing a single linter rule.
  - Maybe improve the way in which linter configuration options are handled.
  - Make it easier to keep track of the linter rule IDs (see T6859).

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: johnny-bit, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10541

11 years agoAlways return an array from ArcanistWorkflow->loadProjectRepository()
epriestley [Thu, 28 May 2015 23:10:59 +0000 (16:10 -0700)]
Always return an array from ArcanistWorkflow->loadProjectRepository()

Summary: Fixes T8344. Prior to D12971, this always returned `array()`. It may now sometimes return `null`. Switch the behavior to be more similar to the old behavior.

Test Plan: Inspection.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T8344

Differential Revision: https://secure.phabricator.com/D13061

11 years agoAllow PhutilUnitTestEngine to execute tests from a single path
Joshua Spence [Thu, 28 May 2015 08:25:56 +0000 (18:25 +1000)]
Allow PhutilUnitTestEngine to execute tests from a single path

Summary: Fixes T8042. Changes the way that `PhutilUnitTestEngine` discovers unit tests. In particular, if you only modify a single test case then there is no reason to run all other test cases within the same directory (which is the current behavior).

Test Plan: Added some unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8042

Differential Revision: https://secure.phabricator.com/D12689

11 years agoSend arcanist error output to STDERR
Joshua Spence [Wed, 27 May 2015 23:10:32 +0000 (09:10 +1000)]
Send arcanist error output to STDERR

Summary: Currently, arcanist error output is sent to `STDOUT` instead of `STDOUT`. This is annoying because I am running `arc lint --everything --never-apply-patches --output=xml > checkstyle.xml` and the `checkstyle.xml` file is not valid XML.

Test Plan: Forced a linter to throw an exception and ran `arc lint >/dev/null`... saw error output.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D13043

11 years agoPush to staging areas when running "arc diff"
epriestley [Wed, 27 May 2015 17:27:03 +0000 (10:27 -0700)]
Push to staging areas when running "arc diff"

Summary: Ref T8238. If a staging area is configured for a repository (see D13019), push a copy of changes to it after creating a diff.

Test Plan: Ran `arc diff` with various options, saw applicable changes get pushed to staging.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: cburroughs, epriestley

Maniphest Tasks: T8238

Differential Revision: https://secure.phabricator.com/D13020

11 years agoProvide more documentation for Arcanist upload stuff
epriestley [Wed, 27 May 2015 17:26:27 +0000 (10:26 -0700)]
Provide more documentation for Arcanist upload stuff

Summary: Ref T8259. Make some highly-ambiguous methods like `setData()` more clear.

Test Plan: reading

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8259

Differential Revision: https://secure.phabricator.com/D13038

11 years agoUse file.allocate to upload large files from `arc diff`
epriestley [Wed, 27 May 2015 17:26:12 +0000 (10:26 -0700)]
Use file.allocate to upload large files from `arc diff`

Summary: Fixes T8259. Depends on D13016. Use modern logic to support large file uploads.

Test Plan:
  - Diffed with some images, saw them show up in the diff.
  - Diffed with a 12MB binary, saw it upload in chunks.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8259

Differential Revision: https://secure.phabricator.com/D13017

11 years agoMove Conduit file upload logic into a separate class
epriestley [Wed, 27 May 2015 17:25:53 +0000 (10:25 -0700)]
Move Conduit file upload logic into a separate class

Summary:
Ref T8259. Currently, `arc upload` uses new logic but `arc diff` uses older logic internally. This prevents `arc diff` from uploading files larger than 4MB to newer servers.

Split the upload logic apart so the two upload pathways can share it. Callers now build a list of FileDataRefs and hand them to an Uploader for upload.

Test Plan:
Ran `arc upload` on:

  - One file.
  - Several files.
  - Small files.
  - Big files.
  - Directories.
  - Unreadable files.
  - Files full of random data.
  - The same file over and over again.
  - The same big file over and over again.
  - Artificially broke `file.allocate` and redid some of the simple cases (large/chunked aren't expected to work in this case).

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T8259

Differential Revision: https://secure.phabricator.com/D13016

11 years agoFix invalid parameter in phutil_console_wrap()
Nevogd [Tue, 26 May 2015 13:07:02 +0000 (06:07 -0700)]
Fix invalid parameter in phutil_console_wrap()

Summary:
Fixes T8314. Change the phutil_console_wrap() call to only have a single
string parameter.

Test Plan:
Ran `arc diff` added text into the title, summary and test plan fields,
but did not specify any reviewers. When prompted to continue, clicked 'No' and
saw the '(Message saved to commit message.)' string.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T8314

Differential Revision: https://secure.phabricator.com/D13015

11 years agoRemove arcanist projects from working copy code
Joshua Spence [Mon, 25 May 2015 21:08:56 +0000 (07:08 +1000)]
Remove arcanist projects from working copy code

Summary: Ref T7604. Remove "arcanist projects" from `ArcanistWorkingCopy` and a few other callsites. Depends on D12999.

Test Plan: Can't really think of how to test this.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12945

11 years agoRemove "project.name" from `.arcconfig"
Joshua Spence [Mon, 25 May 2015 12:42:31 +0000 (22:42 +1000)]
Remove "project.name" from `.arcconfig"

Summary: Ref T7604. Remove the `project.name` configuration from `.arcconfig`. Depends on D12999.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D13003

11 years agoRemove reentrant code
Joshua Spence [Mon, 25 May 2015 12:41:22 +0000 (22:41 +1000)]
Remove reentrant code

Summary: Ref T7604. Remove the `reenter_if_this_is_arcanist_or_libphutil` function. Some discussion in D12945.

Test Plan: Ran `./bin/arc --trace help` and saw things happen as expected.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12999

11 years agoRemove call to "arcanist.projectinfo" from ArcanistWorkflow
Joshua Spence [Mon, 25 May 2015 12:04:50 +0000 (22:04 +1000)]
Remove call to "arcanist.projectinfo" from ArcanistWorkflow

Summary: Ref T7604. Remove call to the `arcanist.projectinfo` #conduit endpoint from `ArcanistWorkflow`. Depends on D12992.

Test Plan: Ran `arc which` and verified that repository information was present.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12971

11 years agoFix some format strings
Joshua Spence [Mon, 25 May 2015 11:20:43 +0000 (21:20 +1000)]
Fix some format strings

Summary: These `pht` calls use `%d` instead of `%s`.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12994

11 years agoFix sanity checks for patch workflow
Joshua Spence [Mon, 25 May 2015 08:38:55 +0000 (18:38 +1000)]
Fix sanity checks for patch workflow

Summary:
Ref T7604. Ref T8307. This was broken in D12962 because I only tested `arc patch --arcbundle`. Furthermore, this particular sanity check doesn't actually do anything now (see T8307).

Test Plan:
Ran `arc patch --nobranch D12971` successfully.

Auditors: epriestley

11 years agoRemove call to "arcanist.projectinfo" from `arc export`
Joshua Spence [Mon, 25 May 2015 08:31:09 +0000 (18:31 +1000)]
Remove call to "arcanist.projectinfo" from `arc export`

Summary:
Ref T7604. Remove a call to `arcanist.projectinfo` from `arc export`. This Conduit call was only used to detect the repository encoding, which we should be able to do locally anyway.

I was considering removing the `$projectName` from `ArcanistBundle` as well, but I'm not convinved that this is a good idea. Specifically, doing so would make it difficult to issue the "This patch is for the 'X' project, but the working copy belongs to the 'Y' project" error. We could potentially use the repository callsign for this purposes, but this isn't portable across installs.

Test Plan: I'm not quite sure how to test this. I suspect that this functionality isn't widely used anyway.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12962

11 years agoChange visibility of some linter methods
Joshua Spence [Sat, 23 May 2015 21:45:01 +0000 (07:45 +1000)]
Change visibility of some linter methods

Summary: Change the visibility of the `raiseLintAtSomething` methods, mainly to allow linter rules to raise linter messages (see D10541).

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12976

11 years ago`pht`ize a bunch more strings
Joshua Spence [Fri, 22 May 2015 07:09:55 +0000 (17:09 +1000)]
`pht`ize a bunch more strings

Summary: I found a few strings that I had missed, using a mostly-broken-but-somewhat-okay custom linter ruler (https://secure.phabricator.com/differential/diff/30988/).

Test Plan: Intense eyeballing.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aurelijus, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12888

11 years agoRemove an unused variable
Joshua Spence [Fri, 22 May 2015 07:09:18 +0000 (17:09 +1000)]
Remove an unused variable

Summary: Ref T7604. Remove an unused variable from `ArcanistDiffWorkflow`.

Test Plan: This diff, I guess.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12972

11 years agoImprove behavior for detecting the failure to parse external linter output
Joshua Spence [Thu, 21 May 2015 21:29:36 +0000 (07:29 +1000)]
Improve behavior for detecting the failure to parse external linter output

Summary:
Currently, a lot of `ArcanistExternalLinter` subclasses have something like this:

```lang=php
if ($err && !$messages) {
  return false;
}
```

We can avoid this code duplication by moving this check to the `ArcanistExternalLinter` class.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11321

11 years agoAllow getXHPASTTreeForPath to return the tree for an arbitrary path
Joshua Spence [Thu, 21 May 2015 05:06:04 +0000 (15:06 +1000)]
Allow getXHPASTTreeForPath to return the tree for an arbitrary path

Summary: This allows `ArcanistBaseXHPASTLinter::getXHPASTTreeForPath` to return the parse tree for a file that wasn't explicitly linted. In my particular use case, I am writing a linter rule to determine if it is necessary to import a PHP file with `require_once` (i.e. the file consists only of class/interface definitions which are autoloadable).

Test Plan: Tested externally using a custom linter.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12271

11 years agoRemove "commit hook mode" workarounds for ArcanistXHPASTLinter
Joshua Spence [Thu, 21 May 2015 05:05:50 +0000 (15:05 +1000)]
Remove "commit hook mode" workarounds for ArcanistXHPASTLinter

Summary: Ref T7674. `ArcanistXHPASTLinter` has some workarounds for running in "commit hook" mode (which has since been removed). This linter should always have a working copy.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7674

Differential Revision: https://secure.phabricator.com/D12956

11 years agoRemove deprecated linter configuration
Joshua Spence [Wed, 20 May 2015 20:57:23 +0000 (06:57 +1000)]
Remove deprecated linter configuration

Summary:
Removes the deprecated method of configuring linters (via the `.arcconfig` file). There is one main caveat here:

- There is currently no convenient method by which to change the path for an external linter (T5057). This means that there is no direct replacement for the deprecated `lint.ruby.prefix` configuration. The workaround is to symlink these binaries into `arcanist/externals/bin`.

Test Plan: Wait a sufficient amount of time before landing this.

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aik099, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10005

11 years agoRemove "arcanist projects" from arcanist
Joshua Spence [Wed, 20 May 2015 01:29:41 +0000 (11:29 +1000)]
Remove "arcanist projects" from arcanist

Summary: Ref T7604. Remove "arcanist projects". Depends on D12894.

Test Plan: This diff (so meta).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12901

11 years agoAdd linter rule for invalid modifiers
Joshua Spence [Tue, 19 May 2015 23:43:37 +0000 (09:43 +1000)]
Add linter rule for invalid modifiers

Summary: Add some linter rule to detect invalid modifiers for class methods/properties.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12922

11 years agoRename ArcanistPhutilTestCase to PhutilTestCase and Remove ArcanistTestCase
Joshua Spence [Tue, 19 May 2015 23:37:44 +0000 (09:37 +1000)]
Rename ArcanistPhutilTestCase to PhutilTestCase and Remove ArcanistTestCase

Summary: Ref T7977. The `ArcanistTestCase` class is pointless and can be replaced by `ArcanistPhutilTestCase`. Furthermore, it sorta makes sense to just rename `ArcanistPhutilTestCase` to `PhutilTestCase`. Depends on D12664 and D12666.

Test Plan: `arc unit`

Reviewers: avivey, #blessed_reviewers, epriestley

Reviewed By: avivey, #blessed_reviewers, epriestley

Subscribers: aurelijus, Korvin, epriestley

Maniphest Tasks: T7977

Differential Revision: https://secure.phabricator.com/D12665

11 years agoImprove getLink method for unit tests
Joshua Spence [Tue, 19 May 2015 23:36:22 +0000 (09:36 +1000)]
Improve getLink method for unit tests

Summary:
Ref T7977. The `PhutilTestCase::getLink` method currently relies on arcanist projects instead of repositories. Instead, make this logic a bit smarter by looking up the base URI from `phabricator.uri` (currently it is hardcoded to `https://secure.phabricator.com`).

Ideally, we would pass `?repositories=$REPOSITORY_PHID` to `DiffusionSymbolController` as well, but I don't know if this is worth pursuing.

Test Plan: This diff.

Reviewers: avivey, #blessed_reviewers, epriestley

Reviewed By: avivey, #blessed_reviewers, epriestley

Subscribers: aurelijus, Korvin, epriestley

Maniphest Tasks: T7977

Differential Revision: https://secure.phabricator.com/D12664

11 years agoProvide a getProjectRoot method for ArcanistLinter
Joshua Spence [Tue, 19 May 2015 23:16:36 +0000 (09:16 +1000)]
Provide a getProjectRoot method for ArcanistLinter

Summary: Adds a `getProjectRoot()` method to the `ArcanistLinter` class, simplifying a bunch of code.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12474

11 years agoImprove the robustness of the "alias function" linter rule
Joshua Spence [Tue, 19 May 2015 22:36:12 +0000 (08:36 +1000)]
Improve the robustness of the "alias function" linter rule

Summary: Improve the `ArcanistXHPASTLinter::LINT_ALIAS_FUNCTION` linter rule. Currently this rule does not correctly handle alias functions which are not strictly lowercase.

Test Plan: Added a test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12921

11 years agoAdd a linter rule for modifier ordering
Joshua Spence [Tue, 19 May 2015 21:23:34 +0000 (07:23 +1000)]
Add a linter rule for modifier ordering

Summary: Fixes T7417. Adds `ArcanistXHPASTLinter::LINT_MODIFIER_ORDERING` for ensuring that method/property modifiers (`public`, `protected`, `private`, `static`, `abstract` and `final`) are consistently ordered. The modifier ordering that is enforced is consistent with [[http://www.php-fig.org/psr/psr-2 | PSR-2]].

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7417

Differential Revision: https://secure.phabricator.com/D12421

11 years agoFurther improvements to array comma linter rule
Joshua Spence [Tue, 19 May 2015 21:05:34 +0000 (07:05 +1000)]
Further improvements to array comma linter rule

Summary:
Improve the `ArcanistXHPASTLinter::LINT_ARRAY_SEPARATOR` rule to be able to autofix the following code:

```lang=php
array(
  1,
  2,
  3, /* comment */ );
```

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D12308

11 years agoDon't explicitly use an interpreter for `pep8`
Joshua Spence [Tue, 19 May 2015 21:04:07 +0000 (07:04 +1000)]
Don't explicitly use an interpreter for `pep8`

Summary: Depends on D9430. If we are using the system installation of `pep8`, then it probably unnecessary (and possibly wrong) to specify `python2.6` as the default interpreter.

Test Plan: Ran `arc unit`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: vrusinov, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9474

11 years agoDon't bundle PEP8
Joshua Spence [Tue, 19 May 2015 21:03:22 +0000 (07:03 +1000)]
Don't bundle PEP8

Summary: Currently, we bundle a specific version of `pep8` with Arcanist. Whilst maybe this made sense historically, as pointed out by @epriestley in D9412#6, there is no longer much point in doing so.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: talshiri, vrusinov, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D9430

11 years agoRemove the `ArcanistConduitLinter`
Joshua Spence [Tue, 19 May 2015 21:01:53 +0000 (07:01 +1000)]
Remove the `ArcanistConduitLinter`

Summary: This linter is a relic from Facebook days. As Harbormaster becomes more useful (T1049) this linter should become obsolete. Instead of modernising this linter to be compatible with modern infrastructure, it is easier to just let it die.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10533

11 years agoMove the getFunctionCalls method to ArcanistBaseXHPASTLinter
Joshua Spence [Tue, 19 May 2015 21:00:29 +0000 (07:00 +1000)]
Move the getFunctionCalls method to ArcanistBaseXHPASTLinter

Summary: Move the `getFunctionCalls` method to the `ArcanistBaseXHPASTLinter` so that it can be used by subclasses.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12472