]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
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

11 years agoFix CPP Lint severity
epriestley [Tue, 19 May 2015 14:58:24 +0000 (07:58 -0700)]
Fix CPP Lint severity

Summary: Currently all CPPLint issues are hard-coded to warning level, which prevents customising the severity in .arclint. Change to pick up the configured severity. Note that getLintMessageSeverity will call getDefaultMessageSeverity if nothing is configured for that error category.

Test Plan: Tested manually to confirm configured categories display with the correct severity and that non-configured ones return with the default severity (ERROR).

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

11 years agoAdd a linter rule for invalid default parameters
Joshua Spence [Mon, 18 May 2015 20:59:50 +0000 (06:59 +1000)]
Add a linter rule for invalid default parameters

Summary: See http://www.phpwtf.org/default-arguments-and-type-hinting.

Test Plan: Added test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoChange parameters for `diffusion.getlintmessages` call
Joshua Spence [Mon, 18 May 2015 14:08:10 +0000 (00:08 +1000)]
Change parameters for `diffusion.getlintmessages` call

Summary: Ref T7604. Change the parameter for `diffusion.getlintmessages` from `arcanistProject` to `repositoryPHID`.

Test Plan: Ran `arc --conduit-uri='http://phabricator.local lint --only-new=1`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

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

11 years agoAdd a linter rule for the instanceof operator
Joshua Spence [Mon, 18 May 2015 08:00:08 +0000 (18:00 +1000)]
Add a linter rule for the instanceof operator

Summary: The `instanceof` operator expects the first argument to be an object instance. See http://www.phpwtf.org/instanceof-smart.

Test Plan: Added test case

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoFix `arc which` output
Joshua Spence [Sun, 17 May 2015 23:40:43 +0000 (09:40 +1000)]
Fix `arc which` output

Summary: Fixes T8231. This was derped in some recent refactoring.

Test Plan: Ran `arc which` and saw expected output.

Reviewers: avivey, epriestley, #blessed_reviewers

Reviewed By: avivey, epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8231

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

11 years agoImprove ArcanistXHPASTLinter::LINT_TOSTRING_EXCEPTION
Joshua Spence [Sun, 17 May 2015 23:04:22 +0000 (09:04 +1000)]
Improve ArcanistXHPASTLinter::LINT_TOSTRING_EXCEPTION

Summary:
The `ArcanistXHPASTLinter::LINT_TOSTRING_EXCEPTION` linter rule was introduced in D12854, but fails for the following:

  - Interfaces which declare the `__toString()` method.
  - Classes which mark the `__toString()` method as `abstract`.

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoAdd a linter rule to prevent the __lambda_func function from being redeclared
Joshua Spence [Sun, 17 May 2015 22:23:48 +0000 (08:23 +1000)]
Add a linter rule to prevent the __lambda_func function from being redeclared

Summary:
See http://phpsadness.com/sad/39. Declaring a function named `__lambda_func` prevents the `create_function` function from working. This is because `create_function` eval-declares the function `__lambda_func`, then modifies the symbol table so that the function is instead named `"\0lambda_".(++$i)`, and returns that name.

NOTE: Personally, I don't think that anyone should use `create_function`. However, despite this, I think it is reasonable that no function is named `__lambda_func` in case some external library relies on `create_function`.

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoAdd a linter rule to prevent exceptions from being thrown in a toString method
Joshua Spence [Sun, 17 May 2015 22:17:32 +0000 (08:17 +1000)]
Add a linter rule to prevent exceptions from being thrown in a toString method

Summary: Fixes T8207. It is not possible to throw an exception from within the `__toString()` method. Add a linter rule to prevent this from happening.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8207

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

11 years agoAdd a linter rule for spacing after a cast
Joshua Spence [Sun, 17 May 2015 22:06:05 +0000 (08:06 +1000)]
Add a linter rule for spacing after a cast

Summary: Ref T7409. Add a linter rule to ensure that a cast is not followed by a space. This is largely based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php | Generic_Sniffs_Formatting_NoSpaceAfterCastSniff]].

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoAdd a linter rule for alias functions
Joshua Spence [Sun, 17 May 2015 21:55:27 +0000 (07:55 +1000)]
Add a linter rule for alias functions

Summary: Ref T7409. Adds `ArcanistXHPASTLinter::LINT_ALIAS_FUNCTION` for linting the use of alias funtions. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php | Generic_Sniffs_PHP_ForbiddenFunctionsSniff]]. See [[http://php.net/manual/en/aliases.php | list of function aliases]].

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoImprove error message from ArcanistXHPASTLinter::LINT_FORMATTED_STRING
Joshua Spence [Sun, 17 May 2015 21:48:03 +0000 (07:48 +1000)]
Improve error message from ArcanistXHPASTLinter::LINT_FORMATTED_STRING

Summary: Currently the error message from `ArcanistXHPASTLinter::LINT_FORMATTED_STRING` is slightly wrong, mentioning `xsprintf` instead of the actual `sprintf`-style function which was used. This diff changes the error message to be more correct.

Test Plan: Linted a file containing `sprintf('%s')` and saw a reasonable lint message.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoImprove the "invalid parent scope" linter rule
Joshua Spence [Sun, 17 May 2015 21:47:19 +0000 (07:47 +1000)]
Improve the "invalid parent scope" linter rule

Summary: This linter rule was introduced in D12420, but fails to handle a specific edge case.

Test Plan: Added test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoRemove deprecated "base" classes
Joshua Spence [Sat, 16 May 2015 00:15:39 +0000 (10:15 +1000)]
Remove deprecated "base" classes

Summary: Ref T5655. After D9983, `ArcanistBaseWorkflow` and `ArcanistBaseUnitTestEngine` are deprecated.

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

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5655

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

11 years agoImprove linter rule for useless overriding methods
Joshua Spence [Thu, 14 May 2015 21:10:28 +0000 (07:10 +1000)]
Improve linter rule for useless overriding methods

Summary: Ref T7409. This linter rule was added in D12419, but fails in some specific cases. Improve the handling of `n_DECLARATION_PARAMETER_LIST`.

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoMinor linter fixes
Joshua Spence [Thu, 14 May 2015 21:09:30 +0000 (07:09 +1000)]
Minor linter fixes

Summary: Minor linter fixes.

Test Plan: `arc lint`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoImprove translation of an "arc land" string
epriestley [Thu, 14 May 2015 17:58:22 +0000 (10:58 -0700)]
Improve translation of an "arc land" string

Summary: This lost formatting in a pht() conversion; give the bold back and make it properly translatable.

Test Plan: Will land.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

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

11 years agoFix missing comma in sprintf() in ArcanistWorkflow.
Andrew Finnemore [Thu, 14 May 2015 12:59:43 +0000 (05:59 -0700)]
Fix missing comma in sprintf() in ArcanistWorkflow.

Summary: Refs D12607. Fixes T8195. Replace period in the sprintf() arguments with a comma.

Test Plan: Ran `arc diff` in the patch applied, did not get the sprintf() error

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T8195

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

11 years agoAdd a linter rule for incorrect use of parent scope
Joshua Spence [Thu, 14 May 2015 08:01:43 +0000 (18:01 +1000)]
Add a linter rule for incorrect use of parent scope

Summary:
The following code is invalid:

```
final class MyClass {
  public function __construct() {
    parent::__construct(null);
  }
}

$x = new MyClass();
```

Running the above code will produce a fatal error:

```
PHP Fatal error:  Cannot access parent:: when current class scope has no parent
```

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoModernize `ArcanistPylintLinter`
Joshua Spence [Thu, 14 May 2015 07:49:24 +0000 (17:49 +1000)]
Modernize `ArcanistPylintLinter`

Summary:
Ref T2039. Convert the `ArcanistPylintLinter` to an `ArcanistExternalLinter` and make it compatible with `.arclint`. In doing so, it was necessary to drop support of older versions of `pylint` by setting the minimum version to be 1.0.0. I think that dropping support for older versions is reasonable because version 1.0.0 was released ~18 months ago. In the case than an incompatible version is detected, an `ArcanistMissingLinterException` is thrown.

One caveat here is that support for `lint.pylint.codes.(error|warning|advice)` is dropped. Any installs that are relying on this configuration will need to migrate to using the `.arclint` file for specifying linter severity. We could potentially continue to support this deprecated configuration, but I'm not sure if this is worthwhile.

Test Plan: Wrote and executed unit tests with `arc unit`. I ran the unit tests on all `pylint` releases after (and including) 1.0.0. Specifically, the tests were run on v1.0.0, v1.1.0, v1.2.0, v1.3.0 and v1.4.0.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

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

11 years agoUse `__CLASS__` instead of hardcoding class names
Joshua Spence [Wed, 13 May 2015 21:09:53 +0000 (07:09 +1000)]
Use `__CLASS__` instead of hardcoding class names

Summary: Use `__CLASS__` instead of hardcoding class names. Depends on D12804.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoAdd a linter rule for useless overriding methods
Joshua Spence [Wed, 13 May 2015 11:03:39 +0000 (21:03 +1000)]
Add a linter rule for useless overriding methods

Summary: Ref T7409. Adds `ArcanistXHPASTLinter::LINT_USELESS_OVERRIDING_METHOD` for detecting method which only call their parent method. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php | Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff]].

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years ago`pht` all the things
Joshua Spence [Wed, 13 May 2015 08:05:15 +0000 (18:05 +1000)]
`pht` all the things

Summary: `pht`ize almost all strings in rARC.

Test Plan: ¯\_(ツ)_/¯

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aurelijus, Korvin, epriestley

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

11 years agoAdd a linter rule to prevent hardcoded class names
Joshua Spence [Tue, 12 May 2015 20:50:30 +0000 (06:50 +1000)]
Add a linter rule to prevent hardcoded class names

Summary: Add a linter rule to advise against the use of hardcoded class names. Hardcoded class names make the code harder to refactor and it is generally preferable to use the `__CLASS__` magic constant instead.

Test Plan: This works, but needs some polish.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoAllow Arcanist to parse bare revision IDs from "Differential Revisions:" field
epriestley [Thu, 7 May 2015 18:10:08 +0000 (11:10 -0700)]
Allow Arcanist to parse bare revision IDs from "Differential Revisions:" field

Summary: Ref T8087. Prepares for eventually making these optional after T6030. See also T7443.

Test Plan:
  - See the next change for the server-side part of this.
  - With both patches applied, rigged the server to return `D123`.
  - Created a revision, saw bare `D123`.
  - Updated it with bare `D123`, things worked properly.
  - Created this revision with full URIs.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: cburroughs, epriestley

Maniphest Tasks: T8087

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

11 years agoMake --conduit-token work without requiring .arcrc
epriestley [Thu, 7 May 2015 18:09:58 +0000 (11:09 -0700)]
Make --conduit-token work without requiring .arcrc

Summary:
Ref T5955. This logic is a little cleaner than the previous version.

Don't require `~/.arcrc` to exist if the caller provides `--conduit-token`.

Test Plan:
  - Made calls with `--conduit-token` and no `~/.arcrc`.
  - Made calls with `--conduit-token` and a normal `~/.arcrc`.
  - Made calls with normal `arc`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: mbishopim3, epriestley

Maniphest Tasks: T5955

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

11 years agoFix broken ArcanistPhpunitTestResultParser
Sascha Egerer [Thu, 7 May 2015 15:41:28 +0000 (08:41 -0700)]
Fix broken ArcanistPhpunitTestResultParser

Summary:
The ArcanistPhpunitTestResultParser has been changed
to use phutil_json_decode instead of json_decode in
rARCa4d33ef117aa8702181154b60ce1ce52bcfc119b
That has broken the functionality as json_decode has returned
an object before but phutil_json_decode does return an array.
The code has now been adopted to work with the array result
instead of an object.

Test Plan: Run a phpunit test case

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aurelijus, epriestley

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

11 years agoFix linter config check
Aviv Eyal [Tue, 5 May 2015 21:03:01 +0000 (14:03 -0700)]
Fix linter config check

Summary: Fixes T6311 and T5124 by returning all configured linters from `buildLinter()`, and making `ArcanistExternalLinter::checkBinaryConfiguration()` not crash if there's no executable to run.

Test Plan: `arc linters` in rP shows "Configured" and "ERROR" as appropriate; Adding a broken linter to `.arclint` in rARC doesn't invoke it's not actually needed, and prints error if it is.

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: joshuaspence, epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6311

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

11 years agoAdd a --conduit-token parameter to `arc`
epriestley [Tue, 5 May 2015 21:02:54 +0000 (14:02 -0700)]
Add a --conduit-token parameter to `arc`

Summary: Ref T5955. This makes it easier to write scripts which call Conduit via `arc call-conduit`.

Test Plan: Used `arc --conduit-token ... call-conduit user.whoami` to make calls as various users.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: mbishopim3, epriestley

Maniphest Tasks: T5955

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

11 years agoRemove hook functionality
Joshua Spence [Tue, 5 May 2015 10:57:23 +0000 (20:57 +1000)]
Remove hook functionality

Summary: Fixes T7674. Remove remaining commit hook functionality.

Test Plan: Unit tests still pass?

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7674

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

11 years agoModernize Script-and-Regex linter for ConfigurationDriven
Aviv Eyal [Tue, 5 May 2015 10:50:19 +0000 (03:50 -0700)]
Modernize Script-and-Regex linter for ConfigurationDriven

Summary: Support and prefer configuration from .arclint over Configuration Manager

Test Plan: arc lint with several combinations of values in .arcconfig and .arclint.

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: joshuaspence, epriestley, #blessed_reviewers

Subscribers: vrusinov, jpoehls, Korvin, epriestley

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

11 years agoRemove commit linter
Joshua Spence [Tue, 5 May 2015 10:56:45 +0000 (20:56 +1000)]
Remove commit linter

Summary: Ref T7674. This linter doesn't make sense without commit hooks.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7674

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

11 years agoRemove support for passing data via STDIN
Joshua Spence [Tue, 5 May 2015 10:55:49 +0000 (20:55 +1000)]
Remove support for passing data via STDIN

Summary: Ref T7674. Remove support for passing data to linters via `STDIN`. This functionality exists primarily for pre-receive workflows (which don't have a working copy to act on), but these workflows are going away soon.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7674

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

11 years agoFix a failing XML unit test
Joshua Spence [Tue, 5 May 2015 08:47:19 +0000 (18:47 +1000)]
Fix a failing XML unit test

Summary: Ref T7215. This test case is consistently failing locally (with a `LIBXML_VERSION` of `20902`).

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7215

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

11 years agoRemove pre-commit hooks
Joshua Spence [Mon, 4 May 2015 21:22:26 +0000 (07:22 +1000)]
Remove pre-commit hooks

Summary: Ref T7674. The `arc git-hook-pre-receive` and `arc svn-hook-pre-commit` workflows are being removed.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7674

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

11 years agoFix a typo
Joshua Spence [Mon, 4 May 2015 21:14:40 +0000 (07:14 +1000)]
Fix a typo

Summary: This variable is misnamed.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoUse phutil_json_decode instead of json_decode
Joshua Spence [Mon, 4 May 2015 12:28:21 +0000 (22:28 +1000)]
Use phutil_json_decode instead of json_decode

Summary: Generally, `phutil_json_decode` should be preferred over `json_decode`.

Test Plan: Eyeballed.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aurelijus, Korvin, epriestley

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

11 years agoRemove unused ArcanistUncommittedChangesException class
Joshua Spence [Sun, 3 May 2015 00:07:15 +0000 (10:07 +1000)]
Remove unused ArcanistUncommittedChangesException class

Summary: Remove the `ArcanistUncommittedChangesException` class which is unused after D11843.

Test Plan: `grep`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoMove the getSuperGlobalNames method to ArcanistBaseXHPASTLinter
Joshua Spence [Sun, 3 May 2015 00:05:35 +0000 (10:05 +1000)]
Move the getSuperGlobalNames method to ArcanistBaseXHPASTLinter

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

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: virendra20888, Korvin, epriestley

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

11 years agoMemoize paths
Joshua Spence [Mon, 27 Apr 2015 13:20:31 +0000 (23:20 +1000)]
Memoize paths

Summary: Ref T7892. Memoize paths returned from `ARcanistLinter::getPaths()` to improve runtime performance.

Test Plan: Wiped ~0.5 seconds off the total time to lint rARC.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7892

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

11 years agoRemove vqueryfx from linters
Joshua Spence [Mon, 27 Apr 2015 11:19:38 +0000 (21:19 +1000)]
Remove vqueryfx from linters

Summary: These methods are gone. Depends on D12566.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoImprove performance of LINT_UNNECESSARY_SEMICOLON
Joshua Spence [Thu, 23 Apr 2015 10:15:00 +0000 (20:15 +1000)]
Improve performance of LINT_UNNECESSARY_SEMICOLON

Summary: Ref T7892. Improve the performance of `ArcanistXHPASTLinter::LINT_UNNECESSARY_SEMICOLON`.

Test Plan: Wiped 6 seconds off the total time to lint rARC.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7892

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

11 years agoMemoize PHP compatibility info
Joshua Spence [Thu, 23 Apr 2015 10:14:46 +0000 (20:14 +1000)]
Memoize PHP compatibility info

Summary: Ref T7892. Avoid reading the PHP compatibility information for every file being linted.

Test Plan:
```name=Before
real    1m24.327s
user    1m19.571s
sys 0m5.239s
```

```lang=After
real    1m12.029s
user    1m5.756s
sys 0m5.502s
```

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7892

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

11 years agoSplit large path lists into blocks when linting
epriestley [Wed, 22 Apr 2015 12:15:57 +0000 (05:15 -0700)]
Split large path lists into blocks when linting

Summary:
Fixes T5097. When linting a large list of paths (e.g., with `--everything`), do this internally:

  $chunks = array_chunk($paths, 32);
  foreach ($chunks as $chunk) {
    $this->lintChunk($chunk);
  }

This keeps the advantages of parallelism and artifact sharing for future-based linters, without having memory usage grow in an unbounded way.

These callbacks changed:

  - `willLintPath()`: Useless, no meaningful implementations. Internalized the required side effect and broke the hook.
  - `didRunLinters()`: Now useless, with no meaningful implementations. Broke the hook.
  - `didLintPaths()`: New hook which executes opposite `willLintPaths()`.
  - `lintPath()`: Linters no longer need to implement this method.

XHPAST now has an explicit way to release shared futures.

These minor changes also happened:

  - Formalized the "linter ID", which is a semi-durable identifier for the cache.
  - Removed linter -> exception explicit mapping, which was unused. We now just collect exceptions.
  - We do the `canRun()` checks first (and separately) now.
  - Share more service call profiling code.
  - Fix an issue where the test harness would use the path on disk, even if configuration set a different path.

Test Plan:
  - Ran `arc lint --everything` in `arcanist/`.
    - With no chunking, saw **unstable** memory usage with a peak at 941 MB.
    - With chunk size 32, saw **stable** memory usage with a peak at 269 MB.
    - With chunk size 8, saw **stable** memory usage with a peak at 180 MB.
  - Ran with `--trace` and saw profiling information.
  - Created this diff.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5097

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

11 years agoAdd a linter rule for lowercase function names
Joshua Spence [Wed, 22 Apr 2015 12:02:09 +0000 (22:02 +1000)]
Add a linter rule for lowercase function names

Summary: Ref T7409. Adds `ArcanistXHPASTLinter::LINT_LOWERCASE_FUNCTIONS` to ensure that builtin PHP functions are lowercased. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php | Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff]].

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoallow either (<time> seconds) or (<time>s) format for test result time
ArtemTitoulenko [Tue, 21 Apr 2015 19:02:32 +0000 (12:02 -0700)]
allow either (<time> seconds) or (<time>s) format for test result time

Summary: The default Go Test Parser stopped showing the test function name at the end of the package after some Go upgrade. We fixed it locally and wanted to share it upstream.

Test Plan: We ran it on our test suite using go1.4.2 darwin/amd64. We have version-dependent code which cannot be compiled with earlier versions of Go, unfortunately.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: avivey, Korvin, epriestley

Maniphest Tasks: T7845

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

11 years agoAdd a linter rule for default parameters
Joshua Spence [Mon, 20 Apr 2015 09:23:23 +0000 (19:23 +1000)]
Add a linter rule for default parameters

Summary: Ref T7409. Adds `ArcanistXHPASTLinter::LINT_DEFAULT_PARAMETERS` for ensuring function/method parameters with a default value are declared after those without a default value. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php | PEAR_Sniffs_Functions_ValidDefaultValueSniff]].

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoMinor tidying of `ArcanistXHPASTLinter`
Joshua Spence [Mon, 13 Apr 2015 20:30:59 +0000 (06:30 +1000)]
Minor tidying of `ArcanistXHPASTLinter`

Summary: Modernizing a couple of linter rules.

Test Plan: Unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years ago`pht`ize a bunch of strings
Joshua Spence [Mon, 13 Apr 2015 20:30:13 +0000 (06:30 +1000)]
`pht`ize a bunch of strings

Summary: `pht`ize a bunch of strings in `ArcanistXHPASTLinter`.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoMinor improvement to self member reference linter rule
Joshua Spence [Mon, 13 Apr 2015 20:29:58 +0000 (06:29 +1000)]
Minor improvement to self member reference linter rule

Summary: Ref T7409. If `::` is surrounded by whitespace tokens and the whitespace token contains a newline character, allow it.

Test Plan: Added test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoAdd a linter rule for declaring nested functions
Joshua Spence [Mon, 13 Apr 2015 20:29:44 +0000 (06:29 +1000)]
Add a linter rule for declaring nested functions

Summary: Ref T7409. Adds `ArcanistXHPASTLinter::LINT_INNER_FUNCTION` to advise against declaring PHP functions within an outer function. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php | Squiz_Sniffs_PHP_InnerFunctionsSniff]].

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoVarious linter fixes
Joshua Spence [Mon, 13 Apr 2015 20:29:07 +0000 (06:29 +1000)]
Various linter fixes

Summary: Apply various linter fixes.

Test Plan: Unit tests + eyeballing.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoImprovements to "self member reference" linter rule
Joshua Spence [Mon, 13 Apr 2015 20:27:17 +0000 (06:27 +1000)]
Improvements to "self member reference" linter rule

Summary: Ref T7409. A few fixes and improvements to `ArcanistXHPASTLinter::LINT_SELF_MEMBER_REFERENCE`.

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoMove README to Markdown
Chad Little [Mon, 13 Apr 2015 20:01:16 +0000 (13:01 -0700)]
Move README to Markdown

Summary: n/a

Test Plan: Markdown editor

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

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

11 years agoAdd a linter rule for logical operators
Joshua Spence [Sun, 12 Apr 2015 21:34:17 +0000 (07:34 +1000)]
Add a linter rule for logical operators

Summary:
Ref T7409. Adds `ArcanistXHPASTLinter::LINT_LOGICAL_OPERATORS` for advising:

  - `&&` in favor of `and`.
  - `||` in favor of `or`.

Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php | Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff]].

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoAdd a linter rule for self member references
Joshua Spence [Sun, 12 Apr 2015 21:27:45 +0000 (07:27 +1000)]
Add a linter rule for self member references

Summary:
Ref T7409. Adds a linter rule for the following:

  - `self::` is used instead of `Self::`.
  - `self::` is used for local static member reference.
  - `self::` is used instead of `self ::`.

Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php | Squiz_Sniffs_Classes_SelfMemberReferenceSniff]].

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoFurther improvements to keyword casing linter rule
Joshua Spence [Sun, 12 Apr 2015 21:27:20 +0000 (07:27 +1000)]
Further improvements to keyword casing linter rule

Summary: Ref T7409. Improve the `ArcanistXHPASTLinter::LINT_KEYWORD_CASING` linter rule to check that magic constants are uppercase.

Test Plan: Added unit test.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoImprove `LINT_KEYWORD_CASING` linter rule
Joshua Spence [Sun, 12 Apr 2015 21:25:54 +0000 (07:25 +1000)]
Improve `LINT_KEYWORD_CASING` linter rule

Summary: Ref T7409. Improve `ArcanistXHPASTLinter::LINT_KEYWORD_CASING` to include additional token types. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php | Generic_Sniffs_PHP_LowerCaseKeywordSniff]].

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoAdd a linter rule for uppercase constant definitions
Joshua Spence [Sun, 12 Apr 2015 21:21:39 +0000 (07:21 +1000)]
Add a linter rule for uppercase constant definitions

Summary: Ref T7409. Adds a linter rule to ensure that constant are defined as being uppercase. Based on [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php | Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff]].

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoTrim trailing whitespace from diff hints
Joshua Spence [Sun, 12 Apr 2015 21:21:07 +0000 (07:21 +1000)]
Trim trailing whitespace from diff hints

Summary: Although these don't do any harm, they show up in my editor which is configured to highlight trailing whitespace.

Test Plan: Submitted this diff... saw no trailing whitespace.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoFix a failing unit test
Joshua Spence [Sun, 12 Apr 2015 08:46:55 +0000 (18:46 +1000)]
Fix a failing unit test

Summary: D11640 incorrectly changed the line endings in this file.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoFix text lint issues
Joshua Spence [Tue, 7 Apr 2015 08:09:26 +0000 (18:09 +1000)]
Fix text lint issues

Summary: Ref T5105. This is a proof-of-concept for D11458.

Test Plan: `arc lint --everything`

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T5105

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

11 years agoImprove array comma rule
Joshua Spence [Mon, 6 Apr 2015 21:51:52 +0000 (07:51 +1000)]
Improve array comma rule

Summary: Improve `ArcanistXHPASTLinter::LINT_ARRAY_SEPARATOR` in handling multi-line arrays, see D12280 and D12281 for example.  Depends on D12295.

Test Plan: Updated unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoDon't pass data to `jshint` via STDIN
Joshua Spence [Mon, 6 Apr 2015 21:26:09 +0000 (07:26 +1000)]
Don't pass data to `jshint` via STDIN

Summary: Fixes T7464. JSHint is unable to exclude files from linting (via the `jshintignore` file) if the data is piped through `STDIN`. An alternative would be to pass `$options[] = '--filename='.$this->getActivePath()`, but `$this->getActivePath()` is not set when the command arguments are constructed.

Test Plan: Created a file and linted it with `ArcanistJSHintLinter`. Was able to exclude the file from linting with a `jshintignore` file.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7464

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

11 years agoFix parsing of PHP compatibility info
Joshua Spence [Mon, 6 Apr 2015 21:25:58 +0000 (07:25 +1000)]
Fix parsing of PHP compatibility info

Summary: The format of this file has changed. Depends on D12278.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoAdd a linter rule to detect unnecessary semicolons
Joshua Spence [Mon, 6 Apr 2015 21:24:20 +0000 (07:24 +1000)]
Add a linter rule to detect unnecessary semicolons

Summary:
Ref T7409. Adds a rule to detect unnecessary semicolons. The most common scenario I've seen in the wild is the use of semicolons after a class definition:

```lang=php
class MyClass {
  // ...
};
```

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoRemove deprecated `ComprehensiveLintEngine` class
Joshua Spence [Mon, 6 Apr 2015 21:22:59 +0000 (07:22 +1000)]
Remove deprecated `ComprehensiveLintEngine` class

Summary: Ref T5655. This class was deprecated in D11673.

Test Plan: Wait a few months.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T5655

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

11 years agoAdded RuboCop linter
cburroughs [Mon, 6 Apr 2015 16:11:06 +0000 (09:11 -0700)]
Added RuboCop linter

Test Plan:
Add the following JSON to your `.arclint`:

```lang=json
"rubocop": {
  "type": "rubocop",
  "include": "(\\.rb$)"
}
```

Then, add a ruby file with errors, for instance:

```lang=ruby
def hello()
  puts 'world'
end
```

Run `arc lint`. It should come up with something along the line of: "Omit the parentheses in defs when the method doesn't accept any arguments."

Reviewers: joshuaspence, remon, #blessed_reviewers, epriestley

Reviewed By: joshuaspence, #blessed_reviewers, epriestley

Subscribers: reu, calfzhou, jjooss, cburroughs, chad, Korvin, epriestley

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

11 years agoFix an odd looking array
Joshua Spence [Sun, 5 Apr 2015 12:27:52 +0000 (22:27 +1000)]
Fix an odd looking array

Summary: This array looks a little odd, most likely due to the autofix applied by `ArcanistXHPASTLinter::LINT_ARRAY_SEPARATOR`. See D12296 in which I attempt to improve the autocorrection from this linter rule.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

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

11 years agoPrompt users to ignore or abort on untracked files
epriestley [Thu, 2 Apr 2015 20:40:14 +0000 (13:40 -0700)]
Prompt users to ignore or abort on untracked files

Summary:
Fixes T7521. This separates things into two prompts and doesn't try to automatically add untracked files.

This also fixes T7512, or at least I can't reproduce it after this change.

Test Plan:
  - Ran `arc diff` in a `git` directory with untracked files.
  - Ran `arc diff` in a `svn` directory with untracked files.
  - Ran `arc diff` in a `hg` directory with untracked files.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7512, T7521

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

11 years agoAdd a linter rule for unnecessary use of the `final` modifier
Joshua Spence [Mon, 23 Mar 2015 13:11:19 +0000 (00:11 +1100)]
Add a linter rule for unnecessary use of the `final` modifier

Summary: Ref T7409. This was based on rhttps://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php.

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7409

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

11 years agoFix a few edge cases for call-time pass-by-reference linting
Joshua Spence [Mon, 23 Mar 2015 12:21:18 +0000 (23:21 +1100)]
Fix a few edge cases for call-time pass-by-reference linting

Summary: Fix a few false positives.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoFix chunk upload fallback behavior
epriestley [Thu, 19 Mar 2015 02:06:27 +0000 (19:06 -0700)]
Fix chunk upload fallback behavior

Summary:
Ref T7594. Currently, if a chunk upload fails, we incorrectly swallow the failure and fall back to single-file upload, which will often fail by hitting size limits. This also silences the original error.

Instead, do chunk uploads outside the block so that any exceptions escape, and we don't try to fall back to single-file upload.

Mostly just trying to get more info about what's going wrong on @joshuaspence's install.

Test Plan: Faked an exception in chunk upload, ran `arc upload` on a big file, saw the exception displayed on the console.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley, joshuaspence

Maniphest Tasks: T7594

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

11 years agoExplicitly draw progress bar when resuming file uploads in `arc upload`
epriestley [Sun, 15 Mar 2015 18:31:56 +0000 (11:31 -0700)]
Explicitly draw progress bar when resuming file uploads in `arc upload`

Summary: Ref T7149. Make sure we sit at "Resuming: 60%" or whatever while uploading the first chunk.

Test Plan: Ran `arc upload` on a large file, cancelled it, resumed it, got sensible progress bar.

Reviewers: chad, btrahan

Reviewed By: chad, btrahan

Subscribers: epriestley

Maniphest Tasks: T7149

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

11 years agoRemove "force chunking" code from Arcanist
epriestley [Sun, 15 Mar 2015 18:31:41 +0000 (11:31 -0700)]
Remove "force chunking" code from Arcanist

Summary: Ref T7149. This was just for testing and is no longer required.

Test Plan: `grep`

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7149

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

11 years agoMake "arc upload" chunk-aware
epriestley [Fri, 13 Mar 2015 18:30:50 +0000 (11:30 -0700)]
Make "arc upload" chunk-aware

Summary: Ref T7149. This makes the client try to use the new `file.allocate` API before falling back to the old stuff.

Test Plan: Used `arc upload` to upload files. With chunking forced, uploaded chunked files.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T7149

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

11 years agoAdd a space in the translation when a error message is printed.
Yomi [Thu, 12 Mar 2015 22:23:37 +0000 (15:23 -0700)]
Add a space in the translation when a error message is printed.

Summary: Change 'themto' to 'them to'.

Test Plan: Check message printed...

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoAdd untracked files to commit using prompt
nevogd [Fri, 6 Mar 2015 12:41:00 +0000 (04:41 -0800)]
Add untracked files to commit using prompt

Summary:
Refs D11990. When using `arc diff` with untracked files in the working
copy, add the untracked file(s) to the commit (as they weren't stashed or
ignored). Add the untracked paths to the list of changes in the editor
template, indicating that the files were added to the commit.

This doesn't add a separate prompt to add untracked files as per the
behaviour prior to D11843.

Test Plan:
Ran `arc diff` with only untracked files, answered yes to the 'create
new commit' prompt. Saw the commit-message with the updated changes
including untracked files. Completed the arc template, and got commit
containing uncommitted, unstaged and untracked files.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agoCheck for untracked files in order to fire untracked file prompt
epriestley [Thu, 5 Mar 2015 22:44:59 +0000 (14:44 -0800)]
Check for untracked files in order to fire untracked file prompt

Summary: Fixes T7465. I think I just missed this when untangling the old logic.

Test Plan: Ran `arc diff` with //only// untrakced files, saw warning.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T7465

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

11 years agoFix a newline issue in "arc" workflows
epriestley [Mon, 2 Mar 2015 16:34:46 +0000 (08:34 -0800)]
Fix a newline issue in "arc" workflows

Summary:
We end up with one too few newline here in some workflows, like `arc land` with unstaged changes.

Root issue here is that `phutil_console_prompt|confirm` lead with too much whitespace but that's a harder fix.

Test Plan: Saw reasonable whitespace.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

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

11 years agoMake "arc which --show-base" work as expected
epriestley [Wed, 25 Feb 2015 21:09:00 +0000 (13:09 -0800)]
Make "arc which --show-base" work as expected

Summary: This is supposed to just print out the base revision, but actually prints out the repository section first.

Test Plan: Ran `arc which`, `arc which --show-base`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

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

11 years agoUse $EDITOR to prompt users when creating a new commit out of dirty working copy...
epriestley [Sat, 21 Feb 2015 10:37:58 +0000 (02:37 -0800)]
Use $EDITOR to prompt users when creating a new commit out of dirty working copy changes

Summary:
Fixes T7344.
Currently, we use `phutil_console_prompt()`, which isn't a very good editor. Use the real $EDITOR instead.

100% of the logic here was also a gigantic mess. Clean it up.

Test Plan: Will update in a second with console output from this run.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7344

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

11 years agoUpdate arcanist to work with more modular translations
epriestley [Wed, 11 Feb 2015 21:02:11 +0000 (13:02 -0800)]
Update arcanist to work with more modular translations

Summary:
Ref T7152. Ref T1139.

  - Tweak API.
  - Move translations out of __init__ file.

Test Plan:
  - Ran `arc`.
  - Added a goofy translation and made sure it was working.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7152, T1139

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

11 years agoFix `xsprintf` callback
Joshua Spence [Wed, 11 Feb 2015 07:29:12 +0000 (18:29 +1100)]
Fix `xsprintf` callback

Summary: After all that, I forgot to change this back.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

11 years agolosen pep8 version check
cburroughs [Tue, 10 Feb 2015 14:17:25 +0000 (06:17 -0800)]
losen pep8 version check

Summary:
pep8 has used both 2 (`1.2`) and 3 (`1.2.1`) digit versions.  Losen
the version check to allow for both.

NOTE: This is the same regex as flake8.

Test Plan: `arc unit` with a 2 and 3 digit pep8 version on `$PATH`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: joshuaspence, epriestley

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

11 years agoFix `pht` method calls
Joshua Spence [Tue, 10 Feb 2015 07:45:30 +0000 (18:45 +1100)]
Fix `pht` method calls

Summary: Ref T7046. This is mainly a proof-of-concept for D11661.

Test Plan: `arc lint`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7046

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

11 years agoAdd a linter rule to detect mismatched parameters for formatted strings
Joshua Spence [Tue, 10 Feb 2015 07:40:15 +0000 (18:40 +1100)]
Add a linter rule to detect mismatched parameters for formatted strings

Summary: Fixes T7046. Adds a linter rule to detect mismatched parameters for formatted strings. Originally I had considered putting this rule in `ArcanistPhutilXHPASTLinter`, but I later decided to move it to `ArcanistXHPASTLinter` as I think that it is general enough to be more widely useful.

Test Plan: This seems to work but needs some polish.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7046

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

11 years agoRename `ComprehensiveLintEngine` class for consistency
Joshua Spence [Mon, 9 Feb 2015 19:57:17 +0000 (06:57 +1100)]
Rename `ComprehensiveLintEngine` class for consistency

Summary: Ref T5655.

Test Plan: Ran `arc lint` with `lint.engine` set to `ComprehensiveLintEngine` and saw a deprecation notice.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Maniphest Tasks: T5655

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

11 years agoRename `ArcanistCompilerLikeLintRenderer`
Joshua Spence [Mon, 9 Feb 2015 19:57:10 +0000 (06:57 +1100)]
Rename `ArcanistCompilerLikeLintRenderer`

Summary: Ref T5655. "Compiler-like" seems a bit odd to me.

Test Plan: `arc lint` + `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T5655

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

11 years agoRemove deprecated support for specifying flags as a string
Joshua Spence [Mon, 9 Feb 2015 19:55:27 +0000 (06:55 +1100)]
Remove deprecated support for specifying flags as a string

Summary: It should be safe to remove this now.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoRename `ArcanistXHPASTLintTestSwitchHook` class
Joshua Spence [Mon, 9 Feb 2015 19:55:03 +0000 (06:55 +1100)]
Rename `ArcanistXHPASTLintTestSwitchHook` class

Summary: Ref T5655.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T5655

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