1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-14 02:42:40 +01:00
Commit graph

1690 commits

Author SHA1 Message Date
Joshua Spence
9090efcb40 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
2015-05-13 06:51:15 +10:00
epriestley
73aca1f9f0 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
2015-05-07 11:10:08 -07:00
epriestley
6c5d12d839 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
2015-05-07 11:09:58 -07:00
Sascha Egerer
3e36b3fc43 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
2015-05-07 08:41:28 -07:00
Aviv Eyal
6f7bedaceb 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
2015-05-05 14:03:01 -07:00
epriestley
111b9b035a 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
2015-05-05 14:02:54 -07:00
Joshua Spence
8919a9c5b5 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
2015-05-05 21:10:47 +10:00
Aviv Eyal
c00899ad60 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
2015-05-05 04:10:19 -07:00
Joshua Spence
0846c6aff5 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
2015-05-05 20:56:45 +10:00
Joshua Spence
4330b27c07 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
2015-05-05 20:55:49 +10:00
Joshua Spence
0a711315f8 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
2015-05-05 18:57:22 +10:00
Joshua Spence
2b6568a4b9 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
2015-05-05 07:22:26 +10:00
Joshua Spence
f477682726 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
2015-05-05 07:14:40 +10:00
Joshua Spence
a4d33ef117 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
2015-05-04 22:36:14 +10:00
Joshua Spence
977baacc32 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
2015-05-03 10:07:15 +10:00
Joshua Spence
eb5621c998 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
2015-05-03 10:06:49 +10:00
Joshua Spence
46ce8a5a35 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
2015-04-27 23:20:31 +10:00
Joshua Spence
805ae12408 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
2015-04-27 21:19:38 +10:00
Joshua Spence
9ddf37b9ee 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
2015-04-23 20:18:54 +10:00
Joshua Spence
d6f4bded25 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
2015-04-23 20:14:46 +10:00
epriestley
f4aadb9604 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
2015-04-22 05:15:57 -07:00
Joshua Spence
ab4eac6f31 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
2015-04-22 22:06:49 +10:00
ArtemTitoulenko
a9ebe1cb4f 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
2015-04-21 12:02:32 -07:00
Joshua Spence
c56e4a56dc 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
2015-04-20 19:23:23 +10:00
Joshua Spence
eb036465dc 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
2015-04-14 06:30:59 +10:00
Joshua Spence
58d8656696 phtize 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
2015-04-14 06:30:13 +10:00
Joshua Spence
51b5c70010 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
2015-04-14 06:29:58 +10:00
Joshua Spence
e233b158f2 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
2015-04-14 06:29:44 +10:00
Joshua Spence
7bba30f66c 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
2015-04-14 06:29:07 +10:00
Joshua Spence
c011f948d3 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
2015-04-14 06:27:17 +10:00
Joshua Spence
b11757fa23 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
2015-04-13 07:35:38 +10:00
Joshua Spence
fc70dfe268 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
2015-04-13 07:32:05 +10:00
Joshua Spence
6525a309c2 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
2015-04-13 07:27:20 +10:00
Joshua Spence
515e98f1d2 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
2015-04-13 07:25:54 +10:00
Joshua Spence
f86f4f24e6 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
2015-04-13 07:23:02 +10:00
Joshua Spence
bf1b30ae26 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
2015-04-13 07:21:07 +10:00
Joshua Spence
e101496508 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
2015-04-12 18:46:55 +10:00
Joshua Spence
f2a3fdf5e3 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
2015-04-07 18:09:27 +10:00
Joshua Spence
3a5ffdc2fd 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
2015-04-07 07:51:52 +10:00
Joshua Spence
4b2d8e3f69 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
2015-04-07 07:26:10 +10:00
Joshua Spence
637832d06f 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
2015-04-07 07:25:58 +10:00
Joshua Spence
c5df885d7b 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
2015-04-07 07:24:20 +10:00
Joshua Spence
92713cf922 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
2015-04-07 07:22:59 +10:00
cburroughs
41ddd34aeb 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
2015-04-06 09:11:15 -07:00
epriestley
8bbcbdd3b6 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
2015-04-02 13:40:14 -07:00
Joshua Spence
e79032fec2 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
2015-03-24 07:30:10 +11:00
Joshua Spence
8530cfcec1 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
2015-03-23 23:38:59 +11:00
epriestley
1a2829d281 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
2015-03-18 19:06:27 -07:00
epriestley
b961869eda 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
2015-03-15 11:31:56 -07:00
epriestley
856cbed527 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
2015-03-15 11:31:41 -07:00
epriestley
a01d3c3b1a 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
2015-03-13 11:30:50 -07:00
Yomi
f51f55a63c 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
2015-03-12 15:23:37 -07:00
nevogd
3d871b4214 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
2015-03-06 04:41:00 -08:00
epriestley
c36b4ceb18 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
2015-03-05 14:44:59 -08:00
epriestley
4e98454840 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
2015-03-02 08:34:46 -08:00
epriestley
d8182cf55d 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
2015-02-25 13:09:00 -08:00
epriestley
dd59423d56 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
2015-02-21 02:37:58 -08:00
epriestley
8f8fe44b05 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
2015-02-11 13:02:11 -08:00
Joshua Spence
3f132f4a4e 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
2015-02-11 18:29:12 +11:00
cburroughs
6dadb6b48c 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
2015-02-10 06:17:25 -08:00
Joshua Spence
17ec3859cd 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
2015-02-10 18:48:38 +11:00
Joshua Spence
d8ba7e6f71 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
2015-02-10 18:43:03 +11:00
Joshua Spence
b32cce79b2 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
2015-02-10 06:57:43 +11:00
Joshua Spence
3498d6adfc 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
2015-02-10 06:57:10 +11:00
Joshua Spence
f13b7d73d0 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
2015-02-10 06:55:49 +11:00
Joshua Spence
bf7b32fe2c 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
2015-02-10 06:55:03 +11:00
Joshua Spence
7c9b8237a0 Change a method name
Summary: Ref T5655.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D11713
2015-02-10 06:53:53 +11:00
Joshua Spence
59640f7eae phtize some strings in ArcanistPhutilTestCaseTestCase
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11671
2015-02-05 07:22:00 +11:00
Joshua Spence
992d939e3a Remove the ArcanistArcanistLinterTestCase
Summary: I don't think that this provides too much value. I think that we should rework this to be inferred from the `.arcconfig` file perhaps?

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11662
2015-02-05 07:21:00 +11:00
Bob Trahan
5c20df1818 Arcanist / Conduit - stop using deprecated diffusion.getcommits
Summary: Fixes T7113. This one was a bit trickier than others as the API output changed a bit. In particular, there is no "errors" emitted so much as the result set just doesn't include the answer if things are garbage. Ergo, check the "identifier map" to either check for diff existence or to lookup the phid to grab the actual diff data from the "data" part of the result.

Test Plan: called `arc backout D11665` and got some working output...!

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7113

Differential Revision: https://secure.phabricator.com/D11667
2015-02-03 14:33:06 -08:00
Bob Trahan
d98c104991 Arcanist / Conduit - stop using deprecated differential.getdiff API
Summary: Fixes T7112. Nothing too difficult here.

Test Plan:
meta - submitting this with the new arcanist code
used conduit API to verify the difference between getdiff (just the latest diff) and querydiffs (all diffs that match, with the latest diff first in the set)

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7112

Differential Revision: https://secure.phabricator.com/D11665
2015-02-03 14:18:10 -08:00
epriestley
a08383aa1b Make "no working copy" a more explicit "arc" VCS
Summary:
Some commands (like `get-config`) do not require a working copy at all. Recent changes prevented these commands from running outside a VCS working copy.

Let `null` mean "no working copy".

See also <https://github.com/phacility/phabricator/issues/800>.

Test Plan:
  - Ran `arc get-config` from outside a working copy.
  - Ran `arc list` from outside a working copy, got an error.
  - Ran `arc commit` in a Git working copy, got an error.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11643
2015-02-03 12:32:46 -08:00
Joshua Spence
77eb24b13a Only allow arc branch to be used under git
Summary: Explicitly declare that the `arc branch` command is only supported under `git`.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11552
2015-02-04 06:58:53 +11:00
Joshua Spence
0fd04109e9 Indicate relevant VCS for arc feature
Summary: This workflow only works on git + mercurial.

Test Plan: I don't even subversion.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11626
2015-02-04 06:54:08 +11:00
Joshua Spence
6b31c0b98a List supported VCS for arc backout
Summary: This workflow does not work on subversion.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11625
2015-02-04 06:53:58 +11:00
Joshua Spence
7eb86b2371 Mark git-hook-pre-receive as git only
Summary: It doesn't make any sense to run this command on another VCS.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11624
2015-02-04 06:53:47 +11:00
Joshua Spence
6bca7f0146 Mark arc svn-hook-pre-commit for subversion only
Summary: It doesn't make any sense to run this command on any other VCS.

Test Plan: Ran `arc svn-hook-pre-commit` and hit the usage exception.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11623
2015-02-04 06:53:41 +11:00
Joshua Spence
24ab7b7f38 Allow ArcanistPhutilLibraryLinter to run with an out-of-date XHPAST binary
Summary: There is no need to check if the XHPAST binary is available here because this linter does not actually parse PHP, it only considers the library map.

Test Plan: Removed the XHPAST binary and ran `arc lint` on a bunch of files.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11528
2015-02-03 08:01:11 +11:00
Joshua Spence
70f9b5d3ae Use PhutilXHPASTBinary methods
Summary: Use `PhutilXHPASTBinary` methods instead of `xhpast_parse` functions. Depends on D11517.

Test Plan: N/A, this is a direct swap.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11613
2015-02-03 06:58:33 +11:00
Joshua Spence
0ef326f3a5 Use XHPAST version instead of checksum as cache version
Summary: Rely on the output of `xhpast --version` when determing the lint cache key.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11611
2015-02-03 06:56:35 +11:00
Joshua Spence
0584d4a06f phtize strings in ArcanistSettings
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11610
2015-02-03 06:54:46 +11:00
Joshua Spence
e4be031778 Explicitly check for supported VCS
Summary: Instead of having an `ArcanistWorkflow` subclass explicitly throw an exception when run in an unsupported VCS, consolidate this code and move it to `arcanist.php`. In doing so, we lose some specificity in some of the error messages, but this otherwise feels cleaner. We could consider adding a `getUnsupportedRevisionControlSystemMessage()` method to provide a more tailored error message. Depends on D11604.

Test Plan:
Ran `arc bookmark` in a `git` working copy:

```
Usage Exception: `arc bookmark` is only supported under hg.
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11550
2015-02-03 06:54:22 +11:00
Joshua Spence
52277fc06f Modernize ArcanistPhpcsLinter
Summary: Allow `--severity` to be specified using `.arclint`.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11511
2015-02-03 06:43:55 +11:00
Joshua Spence
623df14ae5 Change "any" to explicitly list revision control systems
Summary: Using `array('any')` to represent `array('git', 'hg', 'svn')` is a bit magical and leads to a lot of special-casing.

Test Plan: Verified that tab completion (ala `ArcanistShellCompleteWorkflow`) still worked.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11604
2015-02-02 18:19:29 +11:00
Joshua Spence
8cad12034f Minor tidying of ArcanistPasteWorkflow
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11566
2015-02-01 21:57:49 +11:00
Joshua Spence
8208cd3231 Minor tidying of ArcanistRevertWorkflow
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11557
2015-02-01 21:56:28 +11:00
Joshua Spence
589ee20a76 Minor tidying of ArcanistUploadWorkflow
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11556
2015-02-01 21:54:53 +11:00
Joshua Spence
3e63402fef Minor tidying of ArcanistPhrequentWorkflow classes
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11555
2015-02-01 21:49:53 +11:00
Joshua Spence
62e15dcc15 Minor tidying of ArcanistCallConduitWorkflow
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11567
2015-02-01 11:05:27 +11:00
Joshua Spence
fcd882815a Minor tidying of ArcanistUpgradeWorkflow
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11554
2015-02-01 11:01:37 +11:00
Joshua Spence
c76c5d893e Minor tidying of ArcanistVersionWorkflow
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11553
2015-01-30 07:15:05 +11:00
Joshua Spence
e9ffde30ba Fix ArcanistJscsLinter unit tests
Summary: These tests are failing with the latest version of `jscs` (v1.10.0).

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11520
2015-01-28 06:49:02 +11:00
Joshua Spence
edc60cefc4 Fix failing unit tests for ArcanistLesscLinter
Summary: A bunch of unit tests are failing with the latest version of `lessc` (v2.3.0). I decided to delete a bunch of test cases for this linter as we have far too many at the moment.

Test Plan: `arc unit`

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11521
2015-01-28 06:48:50 +11:00
Joshua Spence
d0f84e8492 phtize some strings
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11503
2015-01-27 06:58:31 +11:00
Joshua Spence
c450fa6c06 phtize a bunch of strings
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11501
2015-01-27 06:58:19 +11:00
Joshua Spence
1a3afa4429 Add a linter rule to detect call-time pass-by-reference
Summary: Call-time [[http://php.net/manual/en/language.references.pass.php | pass-by-reference]] is an awful "feature" of PHP that is deprecated and removed in PHP 5.4 (see http://us1.php.net/manual/en/migration54.incompatible.php). Add a linter rule to `ArcanistXHPASTLinter` to detect the use of this feature and raise an error.

Test Plan: Added a test case for `arc unit`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10537
2015-01-23 07:56:58 +11:00
Joshua Spence
0b22838cca Allow arc unit --everything to work without a base commit
Summary: Fixes T2461. Similarly to `arc lint --everything`, `arc unit --everything` should work without a base commit.

Test Plan: Removed the `.git/arc/default-relative-commit` file and ran `arc unit --everything`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T2461

Differential Revision: https://secure.phabricator.com/D11459
2015-01-23 07:21:53 +11:00
Joshua Spence
937861ce58 Improve handling of options for arc workflows
Summary: Allow `--severity=warning` to mean the same as `--severity warning`. Longer term, we should convert this code to use `PhutilArgumentParser`, although it doesn't seem that `PhutilArgumentParser` support British spelling ;)

Test Plan: Ran `arc lint --severity=warning`. Also `var_dump`ed `$args` to make sure it looked reasonable.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11464
2015-01-23 07:07:37 +11:00
epriestley
1cc8f3f377 Don't use newInstanceWithoutConstructor in Arcanist unit test
Summary: This requires PHP 5.4. Use `newv()` instead. I don't think the "without constructor" part is meaningful (or desirable). Simplify slightly.

Test Plan: `arc unit --everything`

Reviewers: hach-que, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11450
2015-01-20 15:39:21 -08:00
Joshua Spence
8173ea3eea Fix visibility of the ArcanistPhpcsLinter::getMandatoryFlags method
Summary: Ref T6822.

Test Plan: All the cool linters are doing it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6822

Differential Revision: https://secure.phabricator.com/D11414
2015-01-16 07:40:06 +11:00
Joshua Spence
6694834f29 Minor tidying of ArcanistPhutilLibraryLinter
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11330
2015-01-15 22:17:36 +11:00
Joshua Spence
272f737110 Write tests for ArcanistNoLintLinter
Summary: With a special guest appearance from `ArcanistGeneratedLinter`.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11345
2015-01-15 07:06:19 +11:00
Joshua Spence
afc53ed322 Add unit tests for ArcanistChmodLinter
Summary: Moar test coverage.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11343
2015-01-15 06:58:11 +11:00
Joshua Spence
7aa89ddf96 Lint against undefined magic symbols
Summary: Fixes T5639. Allows the detection of undefined magic symbols, such as the use of `__DIR__` in a codebase that targets <  PHP 5.3.0.

Test Plan: Added a test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T5639

Differential Revision: https://secure.phabricator.com/D11386
2015-01-15 06:55:45 +11:00
Joshua Spence
bb8e9d7357 Fix visibility of ArcanistMercurialAPI::didReloadCommitRange
Summary: Ref T6822.

Test Plan: `grep`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6822

Differential Revision: https://secure.phabricator.com/D11369
2015-01-14 06:48:25 +11:00
Joshua Spence
af4ab07381 Improve lint handling of declare() special statement blocks
Summary: Fixes T6830. Don't require `n_STATEMENT` nested under `n_DECLARE` to be written using braces.

Test Plan: Added a test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6830

Differential Revision: https://secure.phabricator.com/D11350
2015-01-13 07:23:01 +11:00
Joshua Spence
f58642a8ab Add unit tests for ArcanistFilenameLinter
Summary: Self-explanatory.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11341
2015-01-13 06:47:19 +11:00
Joshua Spence
c86c1ff6f2 Minor changes to ArcanistChmodLinter
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11342
2015-01-13 06:37:25 +11:00
Joshua Spence
25f4563fc8 Minor tidying of ArcanistConduitLinter
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11344
2015-01-13 06:36:19 +11:00
Joshua Spence
3152db6cce Disable the customization of linter severities for ArcanistCommitLinter
Summary: The expectation is that this linter only raises errors.

Test Plan: This is mostly theoretical.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11331
2015-01-12 07:24:53 +11:00
Joshua Spence
b780ef0868 Use the raw formatter for coffeelint
Summary: Using `--reporter=raw` exposes raw JSON output rather than a limited XML output. This allows us to pull more context from the `coffeelint` output.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11320
2015-01-12 07:23:42 +11:00
Joshua Spence
23bc9f294c Change the default value for ArcanistExternalLinter::shouldExpectCommandErrors
Summary: It is more common for linters to exit with a non-zero status than it is for linters to return with a zero exit status, Really this function serves very little purposes, it simply determines whether or not to throw an exception if a non-zero status is returned by the external linter.

Test Plan: `arc unit`

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11322
2015-01-12 07:21:33 +11:00
Joshua Spence
564dab0989 Fix a lint renderering issue
Summary: Currently there is an issue when renderering linter messages with `ArcanistConsoleLintRenderer` if `$message->getChar()` returns `0` (i.e. the value is unset).

Test Plan:
**Before**
{F265586}

**After**
{F265587}

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11319
2015-01-12 06:49:14 +11:00
Joshua Spence
c2a9d88711 Don't explicitly pass --color=never to coffeelint
Summary: This flag doesn't do anything in combination with `--reporter=checkstyle`.

Test Plan:
```lang=bash
> coffeelint --reporter=checkstyle test.coffee
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="test.coffee">
<error line="1"
    severity="error"
    message="Class names should be camel cased; context: class name: boaConstrictor"
    source="coffeelint"/>
</file>
</checkstyle>

> coffeelint --reporter=checkstyle --color=never test.coffee
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="test.coffee">
<error line="1"
    severity="error"
    message="Class names should be camel cased; context: class name: boaConstrictor"
    source="coffeelint"/>
</file>
</checkstyle>
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11318
2015-01-12 06:48:24 +11:00
Joshua Spence
5455fe4430 Don't explicitly implement ArcanistPuppetLintLinter::supportsReadDataFromStdin
Summary: `false` is the default return value for this method.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11314
2015-01-12 06:48:01 +11:00
Joshua Spence
e4149e43cd Improve parsing of csslint output
Summary: `csslint` returns an `evidence` field which contains the line of the "original text" which produced the linter message (see 5dd84b259b/src/core/Reporter.js (L64)). We can use this data instead of trying to achieve the same result using `$this->getData($path)`.

Test Plan: {F265449}

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11311
2015-01-12 06:47:51 +11:00
Joshua Spence
7b383632dd Minor tidying of ArcanistCSSLintLinter
Summary: Minor tidying.

Test Plan: Eyeball it.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11307
2015-01-12 06:47:16 +11:00
Joshua Spence
1b3d600098 Don't pass --quiet to csslint
Summary: Similar to D11198. This flag doesn't do anything when combined with `--format=lint-xml`.

Test Plan:
```lang=bash
> csslint *.css
csslint *.css

csslint: There are 1 problems in /home/joshua/workspace/github.com/phacility/arcanist/fail.css.

fail.css
1: error at line 1, col 1
Unexpected token '~' at line 1, col 1.
~

csslint: No errors in /home/joshua/workspace/github.com/phacility/arcanist/pass.css.

> csslint --quiet *.css
csslint --quiet *.css

csslint: There are 1 problems in /home/joshua/workspace/github.com/phacility/arcanist/fail.css.

fail.css
1: error at line 1, col 1
Unexpected token '~' at line 1, col 1.
~

> csslint --format=lint-xml *.css
<?xml version="1.0" encoding="utf-8"?><lint>
<file name="/home/joshua/workspace/github.com/phacility/arcanist/fail.css"><issue line="1" char="1" severity="error" reason="Unexpected token '~' at line 1, col 1." evidence="~"/></file>
</lint>

> csslint --format=lint-xml --quiet *.css
<?xml version="1.0" encoding="utf-8"?><lint>
<file name="/home/joshua/workspace/github.com/phacility/arcanist/fail.css"><issue line="1" char="1" severity="error" reason="Unexpected token '~' at line 1, col 1." evidence="~"/></file>
</lint>
```

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11308
2015-01-12 06:46:34 +11:00
Joshua Spence
1c3278e3fb Move linter exception classes to src/lint/linter/exception
Summary: The `src/lint/linter` directory is a bit cluttered at the moment.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11309
2015-01-12 06:46:23 +11:00
Joshua Spence
14e5fbbd6b Fix parsing of puppet-lint --version
Summary: This seems to be off, at least for `puppet-lint` versions greater than 1.0.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11312
2015-01-12 06:44:08 +11:00
Joshua Spence
9c0568e12d Delete a problematic test case
Summary: This test case is currently failing with various different versions of `puppet-lint`. I was considering fixing this test case, but I feel that we have more than enough test cases for `ArcanistPuppetLintLinter` anyway. Since this is an `ArcanistExternalLinter`, we only really need to test that the bindings are working as expected (rather than the linter functionality).

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11313
2015-01-12 06:43:58 +11:00
Joshua Spence
50a5d54e71 Minor tidying of the ArcanistPuppetLintLinter class
Summary: Self-explanatory.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11317
2015-01-12 06:43:07 +11:00
Joshua Spence
ce7e8f28f5 Pass --error-level=all to puppet-lint
Summary: Without explicitly passing `--error-level=all` to `puppet-lint`, the configuration file for `puppet-lint` could contain `--error-level=error`. This would limit the ability of `arc lint` to detect linter issues and therefore we should override this flag from the command line explicitly.

Test Plan: This is mostly theoretical.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11316
2015-01-12 06:41:46 +11:00
Joshua Spence
fa37d3135f Minor improvements to ArcanistJSONLinter
Summary: Self-explanatory.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11324
2015-01-12 06:40:40 +11:00
Joshua Spence
4e38fac47d Make properties in the PhutilUnitTestEngineTestCase class private
Summary: There's no need for these properties to be (implicitly) public.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11276
2015-01-08 22:43:44 +11:00
Joshua Spence
5492f0fad6 Minor improvements to ArcanistPhpLinter
Summary: Various minor improvements to `ArcanistPhpLinter`.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11265
2015-01-08 19:40:37 +11:00
Joshua Spence
a232f7d5b8 Improvements to LINT_IMPLICIT_VISIBILITY
Summary: See D10687#104589.

Test Plan: Wrote unit tests.

Reviewers: richardvanvelzen, epriestley, #blessed_reviewers

Reviewed By: richardvanvelzen, epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11267
2015-01-08 07:30:31 +11:00
Joshua Spence
2ad2c04774 Simplify version parsing for ArcanistPhpLinter
Summary: We can use `php --run "echo phpversion();"` to return a nice, compact representation of the PHP version.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11264
2015-01-07 23:55:34 +11:00
Joshua Spence
ff3d3792ba Minor tidying of the ArcanistXMLLinter class
Summary: Self-explanatory

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11263
2015-01-07 23:55:08 +11:00
Joshua Spence
a28bf87633 Fix unit parser tests
Summary: This directory was missed, but should have been moved in D11202.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11262
2015-01-07 23:54:49 +11:00
Joshua Spence
4f5203375e Add a linter rule to detect implict method visibility
Summary: I'm not sure whether this is in any coding standards, but it seems to be an unspoken rule that methods should have a visiblity modifier (`public`, `protected` or `private`) explicitly specified. According to the [[http://php.net/manual/en/language.oop5.visibility.php#language.oop5.visiblity-methods | PHP documentation]], methods declared without any explicit visibility keyword are defined as public.

Test Plan: Added a test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10687
2015-01-07 07:42:41 +11:00
Joshua Spence
fbefe61fb9 Use PhutilLibraryTestCase
Summary: Depends on D11231.

Test Plan: `arc unit`

Reviewers: btrahan, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11232
2015-01-07 07:37:59 +11:00
Joshua Spence
828fb41ea7 Fix visibility of various ArcanistLinter methods
Summary: Ref T6822.

Test Plan: Visual inspection. These methods are only called from within the `ArcanistExternalLinter` and `ArcanistLinter` subclasses.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6822

Differential Revision: https://secure.phabricator.com/D11237
2015-01-07 07:36:07 +11:00
Joshua Spence
c70009d90f Fix visibility of various ArcanistWorkflow methods
Summary: Ref T6822.

Test Plan: Visual inspection. These methods are only called from within the `ArcanistShellCompleteWorkflow` class.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6822

Differential Revision: https://secure.phabricator.com/D11238
2015-01-07 07:36:00 +11:00
Joshua Spence
cd591318ca Fix visibility of the ArcanistLintEngine::buildLinters() method
Summary: Ref T6822. This method needs to be public so that it can be called from `ArcanistLintersWorkflow`.

Test Plan: Ran `arc linters`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6822

Differential Revision: https://secure.phabricator.com/D11239
2015-01-07 07:35:20 +11:00
jjoos
439413ae29 Remove the noconfig flag
Summary:
D11196 introduced a regression that made it impossible for coffeelint to read any configuration. I'm reverting the change in that diff.

Created a pull request changing the documentation of coffeelint to make sure I'm interpreting this flag correctly: https://github.com/clutchski/coffeelint/pull/364

Test Plan:
- patch
- npm install -g coffeelint

- create a `test.coffee` file with:
```
# 1234567890
```
- `arc lint test.coffee`
```
 OKAY  No lint warnings.
```
- create a `coffeelint.json` with
```
{
  "max_line_length": {
    "value": 10
  }
}
```
- `arc lint test.coffee`, expected output:
```
>>> Lint for test.coffee:

   Error  (COFFEE)
    Line exceeds maximum allowed length.

    >>>        1 # 1234567890
```
- create a `.arclint` with
```
{
  "linters": {
    "coffeelint": {
      "type": "coffeelint",
      "coffeelint.config": "coffee_lint_config_with_different_name.json"
    }
  }
}
```
- rename `coffeelint.json` to `coffee_lint_config_with_different_name.json`
- `arc lint test.coffee`, expected output:
```
>>> Lint for test.coffee:

   Error  (COFFEE)
    Line exceeds maximum allowed length.

    >>>        1 # 1234567890
```

Reviewers: Korvin, joshuaspence, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11250
2015-01-06 06:59:45 -08:00
Joshua Spence
6eed5c2514 Create a custom exception class for missing linter dependencies
Summary: I feel that we are abusing `ArcanistUsageException`. Throw a more tailed exception instead. Depends on D11197.

Test Plan: `arc lint`, I guess.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: avivey, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11205
2015-01-06 22:51:17 +11:00
Joshua Spence
0b51f4d7c9 phtize some strings
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11206
2015-01-06 22:43:52 +11:00
Joshua Spence
d477df00eb Add a linter rule to detect the use of blacklisted functions
Summary:
As mentioned in the [[https://secure.phabricator.com/book/phabcontrib/article/php_coding_standards/ | Phabricator PHP coding standards]], the `eval` function should be avoided. There is some good discussion on [[http://stackoverflow.com/questions/951373/when-is-eval-evil-in-php | StackOverflow]] as well.

Having said that, instead of hardcoding `eval()`, I have generalised this enough to allow a set of "blacklisted" functions to be defined with `xhpast.blacklisted.function` in the `.arclint` file.

Test Plan: Added a test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10686
2015-01-05 10:51:33 +11:00
Joshua Spence
eb3129408b Various improvements for ArcanistClosureLinter
Summary: WIP

Test Plan: WIP

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11207
2015-01-05 07:43:55 +11:00
Joshua Spence
9e6f876a68 Export namespace in ArcanistUnitTestResult dictionary
Summary: D7952 added namespaces to `ArcanistUnitTestResult` but these are not exported and thus don't get sent from client to server.

Test Plan: Uploaded a diff and inspected the contents of the `phabricator_differential.differential_diffproperty` table.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11208
2015-01-05 06:48:32 +11:00
Joshua Spence
4fe5243d81 Use PhutilMethodNotImplementedException in ArcanistExternalLinter
Summary: Self-explanatory.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11204
2015-01-05 06:47:12 +11:00
Joshua Spence
44f81f4351 Rename PHPUnitTestEngineTestCase for consistency
Summary: Ref T5655. `PHPUnitTestEngineTestCase` is the test case for `PhpunitTestEngine`.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aurelijus, Korvin, epriestley

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D11203
2015-01-05 06:46:24 +11:00
Joshua Spence
1c0fd5ce5d Move ArcanistTestResultParser subclasses
Summary: Move `ArcanistTestResultParser` subclasses from `src/unit/engine` to `src/unit/parser`. Depends on D11201.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aurelijus, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11202
2015-01-05 06:46:14 +11:00
Joshua Spence
63c9c6c4ff Rename ArcanistTestResultParser subclasses for consistency
Summary: Ref T5655.

Test Plan: `grep`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aurelijus, Korvin, epriestley

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D11201
2015-01-05 06:45:31 +11:00
Joshua Spence
9fdf53452c Rename UnitTestableArcanistLintEngine for consistency
Summary: Ref T5655.

Test Plan: `grep`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D11200
2015-01-05 06:44:49 +11:00
Joshua Spence
23f9a3ae66 Minor tidying of ArcanistCoffeeLintLinter
Summary: Self-explanatory.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11199
2015-01-05 06:44:33 +11:00
Joshua Spence
9c07016ee4 Don't pass --quiet to coffeelint
Summary: This flag doesn't do anything when combined with `--reporter=checkstyle`.

Test Plan:
```
> coffeelint *.coffee
  ✗ fail.coffee
     ✗ #1: Class names should be camel cased. class name: boaConstrictor.
  ✓ pass.coffee

✗ Lint! » 1 error and 0 warnings in 2 files

> coffeelint --quiet *.coffee
  ✗ fail.coffee
     ✗ #1: Class names should be camel cased. class name: boaConstrictor.

✗ Lint! » 1 error and 0 warnings in 2 files

> coffeelint --reporter=checkstyle *.coffee
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="fail.coffee">
<error line="1"
    severity="error"
    message="Class names should be camel cased; context: class name: boaConstrictor"
    source="coffeelint"/>
</file>
</checkstyle>

> coffeelint --reporter=checkstyle --quiet *.coffee
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="fail.coffee">
<error line="1"
    severity="error"
    message="Class names should be camel cased; context: class name: boaConstrictor"
    source="coffeelint"/>
</file>
</checkstyle>
```

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11198
2015-01-05 06:43:59 +11:00
Joshua Spence
da02add6c8 Create an ArcanistExternalLinterTestCase class
Summary: Creates a new base class for unit testing `ArcanistExternalLinter` subclasses. Specifically, add a test case for verifying that we are correctly parsing the output of `$external_linter --version`.

Test Plan: `arc unit`

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11197
2015-01-05 06:41:59 +11:00
Joshua Spence
f6b3f3c46a Ignore environment variables for coffeelint
Summary: According to `coffeelint --help`, `--noconfig` ignores the environment variable `COFFEELINT_CONFIG`. This means that `arc lint` will behave more consistently across developer workstations by forcing configuration to be specified with `coffeelint.config` instead of with environment variables.

Test Plan: This is mostly theoretical.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11196
2015-01-05 06:40:37 +11:00
Joshua Spence
784033dc1a Update flags for coffeelint
Summary: According to `coffeelint --help` (with an up-to-date version of `coffeelint`, version 1.8.1) , `--nocolor` is deprecated in favor of `--color=never`. According to the [[http://www.coffeelint.org/#changelog | changelog]], `--nocolor` was deprecated in v1.6.0.

Test Plan: `arc lint`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11195
2015-01-05 06:39:50 +11:00
Joshua Spence
f5db41917b Reduce boilerplate code in ArcanistLinterTestCase subclasses
Summary: This is a bit magical and is maybe a terrible idea, but it seems okayish.

Test Plan: `arc unit`

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11172
2015-01-04 18:40:57 +11:00
Joshua Spence
a10002adec Raise a linter error when removed symbols are used
Summary: Ref T5141. Utilize the `'max'` key from the `php_compat_info.json` compatibility map to lint for the use of classes/functions/symbols which have been removed from the target PHP version.

Test Plan: Added a test case for `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T5141

Differential Revision: https://secure.phabricator.com/D10538
2015-01-04 18:38:07 +11:00
Joshua Spence
b31e9c0cfe Add a linter rule to detect duplicate case statements
Summary: Fixes T6843. Adds a linter rule to `ArcanistXHPASTLinter` to detect duplicate `case` statements within a `switch` statement.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6843

Differential Revision: https://secure.phabricator.com/D11171
2015-01-04 18:08:37 +11:00
Joshua Spence
4e3df80584 Move LINT_NO_COMMIT from ArcanistTextLinter to a new linter
Summary: I don't feel that this linter rule belongs in the `ArcanistTextLinter`. In fact, this linter rule is quite similar to the rules provided by `ArcanistGeneratedLinter` and `ArcanistNoLintLinter` and these classes could possibly be consolidated. I have moved this linter rule to a standalone `ArcanistCommitLinter` class (which could possibly do additional lints in the future).

Test Plan: Moved existing test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10473
2015-01-04 16:20:32 +11:00
Joshua Spence
821ebcdd07 phtize some strings
Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11175
2015-01-03 23:53:07 +11:00
Joshua Spence
a9cfc17688 Specify the config property of lint-test files as a map
Summary: Self-explanatory. This is implied anyway as we iterate over it with a `foreach` loop.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11174
2015-01-03 23:52:56 +11:00
Joshua Spence
fba62c0d9d Remove arcconfig settings from ArcanistLinterTestCase
Summary: This doesn't make too much sense anymore as all modern linters are configured via the `.arclint` file rather than `.arcconfig`.

Test Plan: `grep`ped to make sure this option isn't used.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11173
2015-01-03 23:52:46 +11:00
Joshua Spence
201d195f29 Fix variable name
Summary: Fix a variable name to be consistent with naming conventions.

Test Plan: `arc lint`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aurelijus, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11140
2015-01-03 10:30:15 +11:00
Joshua Spence
d6af220921 Remove some unused classes
Summary: Self-explanatory.

Test Plan: `grep`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11151
2015-01-03 09:06:16 +11:00
Joshua Spence
0352db802e Suppress stdin message if input is piped
Summary: Currently we output "Waiting for JSON parameters on stdin...", even if `stdin` is piped (for example, from `echo`).

Test Plan:
```lang=bash
> echo '{}' | arc call-conduit conduit.ping
{"error":null,"errorMessage":null,"response":"ip-10-161-81-110"}

> arc call-conduit conduit.ping
Waiting for JSON parameters on stdin...
{}
^D
{"error":null,"errorMessage":null,"response":"ip-10-161-81-110"}
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11122
2015-01-02 11:36:24 +11:00
Joshua Spence
f86a70f411 Remove some old code handling the absence of the file.uploadhash Conduit method
Summary: The `file.uploadhash` method was added a long time ago (in D4899). It should be safe to assume that this method exists on most installs.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11118
2015-01-02 10:10:10 +11:00
Joshua Spence
f8be9d7737 Remove the inlines workflow
Summary: Ref T5112. The `arc inlines` workflow no longer works because the `differential.getrevisioncomments` API method has been deprecated (see T2222). The command is basically useless right now.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5112

Differential Revision: https://secure.phabricator.com/D9464
2014-12-31 10:45:41 +11:00
epriestley
a3c3d23dd7 Fix two linter issues
Summary:
  - The "exclude static variable access" branch in XHPAST incorrectly excluded all variables in a function or method which used any static access (we were selecting the wrong root node for exclusion).
  - The "PHPLinter" regexp did not work with 5.4.30. Make it more permissive in what it parses.

Test Plan:
  - Added a failing unit test for the variable case and made it pass.
  - PHPLinter tests now pass under 5.4.30

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11087
2014-12-30 10:02:43 -08:00
Joshua Spence
721bdf424b Use new FutureIterator instead of Futures
Summary: Ref T6829. Deprecate the `Futures()` function.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aurelijus, Korvin, epriestley

Maniphest Tasks: T6829

Differential Revision: https://secure.phabricator.com/D11079
2014-12-30 23:16:25 +11:00
Joshua Spence
841556134f Fix puppet-lint unit tests for the v1.1.0
Summary: This unit test is failing locally for me, using v1.1.0 of `puppet-lint`.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11057
2014-12-30 02:46:57 -08:00
epriestley
5118987757 Support simpler, token-based Conduit authentication in Arcanist
Summary:
Ref T5955. If the server supports token-based authentication, prefer it over certificate-based authentication.

Also fixes T3117.

Test Plan:
  - Used `arc install-certificate` to install credentials from both token-based and certificate-based hosts.
  - Used `arc list` with a token-based host.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3117, T2878, T5955

Differential Revision: https://secure.phabricator.com/D10988
2014-12-15 11:12:38 -08:00
Joshua Spence
565a96e0ee Minor linter fixes
Summary: Self explanatory/

Test Plan: `arc lint`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aurelijus, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10943
2014-12-08 23:48:55 +11:00
Joshua Spence
4ca3463df6 Extend LINT_BRACE_FORMATTING to support more scenarios
Summary: Extend the `ArcanistXHPASTLinter::LINT_BRACE_FORMATTING` rule to support a bunch of extra cases.

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10572
2014-12-08 23:31:21 +11:00
Joshua Spence
ee2070fadb Extend LINT_BRACE_FORMATTING to warn on missing braces
Summary: Extend the `ArcanistXHPASTLinter::LINT_BRACE_FORMATTING` rule to raise a warning when `n_STATEMENT` is used without having `n_STATEMENT_LIST` as a parent. Essentially, this means that `if ($x) { do_y(); }` is preferred over `if ($x) do_y();`.

Test Plan: Added some test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10571
2014-12-08 23:30:33 +11:00
epriestley
b46d4ed4ad Update lint engine documentation
Summary: Fixes T6627. This class documentation is out of date and somewhat misleading in the modern environment.

Test Plan: Read it.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T6627

Differential Revision: https://secure.phabricator.com/D10899
2014-11-24 15:01:19 -08:00
David Cramer
6a36584ae1 Report tests results whenever possible
Summary: This adjusts the behavior of PytestTestEngine so that it correctly reports test failures natively, rather than throwing a command error.

Test Plan: Yeah right

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10866
2014-11-17 15:25:48 -08:00
Chad Little
52947cfd92 Remove gist link that (never?) doesn't work
Summary: Removing 404 link, fixes https://github.com/phacility/arcanist/issues/180

Test Plan: n/a

Reviewers: epriestley, avivey

Reviewed By: epriestley, avivey

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10689
2014-10-13 10:48:18 -07:00
Joshua Spence
8547a25928 Fix LINT_KEYWORD_CASING for class keyword
Summary: D10653 didn't quite cut it.

Test Plan: Tested on a real file.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10656
2014-10-08 09:29:35 +11:00
Joshua Spence
f44a6e00a7 Extend ArcanistXHPASTLinter::LINT_KEYWORD_CASING
Summary: Extend `ArcanistXHPASTLinter::LINT_KEYWORD_CASING` to include the `class` keyword.

Test Plan: I can't really added a test case for this without getting "XHP19 Class-Filename Mismatch".

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10653
2014-10-08 08:54:45 +11:00
Joshua Spence
a0cb484db4 Mark some methods in ArcanistLinter as final
Summary: Minor change, self-explanatory... this seems to make sense.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10476
2014-10-08 00:07:39 +11:00
Joshua Spence
e54725ec89 Add a LINT_CONSTRUCTOR_PARENTHESES rule to ArcanistXHPASTLinter
Summary: Adds an `ArcanistXHPASTLinter::LINT_CONSTRUCTOR_PARENTHESES` rule which ensures that (possibly empty) parentheses are used when calling a constructor.

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10597
2014-10-07 23:59:03 +11:00
Joshua Spence
b1112e73c4 Minor linter fixes
Summary: Apply some linter autofixes.

Test Plan: `arc lint` and `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10568
2014-09-27 10:21:23 +10:00
Joshua Spence
8ed1459ecd Add a linter rule to detect variable arguments for break and continue
Summary: In PHP 5.4, the `break` and `continue` statements no longer accept variable arguments (e.g., `break 1 + foo() * $bar;`). Static arguments still work, such as break 2;. As a side effect of this change `break 0;` and `continue 0;` are no longer allowed.

Test Plan: Added some test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10567
2014-09-26 08:40:30 +10:00
Joshua Spence
247a4fabb8 Fix LINT_ARRAY_SEPARATOR for heredocs
Summary: It is not correct to add a trailing comma if the `n_ARRAY_VALUE` node is a heredoc string.

Test Plan: Added a test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10569
2014-09-26 08:35:40 +10:00
Joshua Spence
cb20078250 Fix LINT_ARRAY_SEPARATOR for nested arrays
Summary: The `LINT_ARRAY_SEPARATOR` rule was added to `ArcanistXHPASTLinter` in D10535. Unfortunately, it does not correctly handle nested arrays correctly. This patch fixes this. Depends on D10554.

Test Plan: Added a test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10558
2014-09-26 07:14:55 +10:00
Joshua Spence
e6e317db27 Fix incorrect linter code being raised
Summary: `ArcanistXHPASTLinter::lintSpaceAroundConcatenationOperators` should raise `LINT_CONCATENATION_OPERATOR`, not `LINT_BINARY_EXPRESSION_SPACING`.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10553
2014-09-25 12:58:37 +10:00
Joshua Spence
be428e3207 Add a linter rule for array separators
Summary:
Adds a rule to `ArcanistXHPASTLinter` which ensures that:

# Single-lined arrays //do not// contain an unnecessary trailing comma separator after the final array value.
# Multi-lined arrays //do// contain a trailing comma seperator after the final value value.

Depends on D10534.

Test Plan: Wrote and executed unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10535
2014-09-25 07:40:30 +10:00
Joshua Spence
13492c8043 Fix a fatal error in ArcanistXHPASTLinter
Summary: I had assumed that we would always be interested in `n_STATEMENT_LIST`, which is fine for `if (...) { some_statements(); }` but not for `if (...) one_statement();`.

Test Plan: Added a test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10551
2014-09-25 07:33:24 +10:00
Joshua Spence
888ada2f38 Improve LINT_DOS_NEWLINE behavior
Summary: Improve the behavior of `ArcanistTextLinter` in dealing with `LINT_DOS_NEWLINE`. In particular, provide replacement text so that these linter issues can be autofixed.

Test Plan: Added a unit test.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10472
2014-09-25 07:14:58 +10:00
Joshua Spence
5951ec26b4 phtize some strings
Summary: Self explanatory.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10536
2014-09-25 07:10:12 +10:00
Joshua Spence
a70a00a960 Explicitly enumerate PHP magic methods
Summary: Explicitly list PHP magic methods (methods beginning with `__`) instead of assuming that //all// methods beginning with `__` are okay in terms of naming conventions. These magic methods were obtained from http://us1.php.net/manual/en/language.oop5.magic.php.

Test Plan:
```
   Warning  (XHP9) Naming Conventions
    Follow naming conventions: methods should be named using lowerCamelCase.

               1 <?php
               2
               3 class Foo {
    >>>        4     function __foo() {}
               5
               6     function _bar() {}
               7 }

   Warning  (XHP9) Naming Conventions
    Follow naming conventions: methods should be named using lowerCamelCase.

               3 class Foo {
               4     function __foo() {}
               5
    >>>        6     function _bar() {}
               7 }
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10539
2014-09-23 08:02:19 +10:00
Joshua Spence
670dccee47 Minor reordering of functions
Summary: This seems somewhat neater to me, YMMV.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10468
2014-09-22 18:42:41 +10:00
Joshua Spence
be34693f23 Fix failing unit test
I goofed this up... I think my editor trimmed the trailing whitespace for me.

Auditors: epriestley
2014-09-12 08:15:53 +10:00
Joshua Spence
f4fd7ad612 Add a bunch of additional test cases for ArcanistTextLinter
Summary: Self-explanatory, improve test coverage.

Test Plan: Wrote and executed unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10474
2014-09-11 23:43:38 +10:00
Joshua Spence
75ad848b9d Fix custom severity rules not being applied
Summary: It seems that `severity.rules` does not override the default linter severities set by the `ArcanistLinter` itself. This seems incorrect and counter-intuitive.

Test Plan: Created a `"severity.rules": { "(.*)": "disabled" }"` configuration and verified that it was being applied.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10475
2014-09-11 23:39:12 +10:00
Joshua Spence
679c13b1b0 Remove a useless function from ArcanistMergeConflictLinter
Summary: This function doesn't achieve anything.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10477
2014-09-11 23:39:01 +10:00
Joshua Spence
0ed92131d7 Fix a typo
Summary: Minor styling fix.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10478
2014-09-11 23:37:36 +10:00
epriestley
e043d22afd Fix PHP version check for function calls with static/variable functions
Summary: D10132 improved this check by eliminating some false postives, but assumes an `n_FUNCTION_CALL` always starts with `n_SYMBOL_NAME`. This is true for `f()`, but not true for `C::m()` or `$v()`.

Test Plan: Added and ran unit tests.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D10467
2014-09-10 14:01:34 -07:00
Joshua Spence
3f79ae258f Allow classes/functions from a later version if they are used conditionally
Summary:
Fixes T5299. Currently, linting `src/future/http/HTTPSFuture.php` from rPHU will raise the following error:

```
   Error  (XHP31) Use Of PHP 5.3 Features
    This codebase targets PHP 5.2.3, but `curlfile` was not introduced until
    PHP 5.5.0.

             532       // use this "@" stuff.
             533
             534       if (class_exists('CURLFile')) {
    >>>      535         $file_value = new CURLFile((string)$tmp, $info['mime'], $info['name']);
             536       } else {
             537         $file_value = '@'.(string)$tmp;
             538       }
```

However, since this class is being used conditionally, it //should// be fine and no linter errors should be being raised.

Test Plan: Added a test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5299

Differential Revision: https://secure.phabricator.com/D10132
2014-09-11 00:24:08 +10:00
Joshua Spence
f0f6897fce Fix a typo
Summary: Self-explanatory.

Test Plan: Eyeball it

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10462
2014-09-10 23:40:24 +10:00
Joshua Spence
16770ed210 Fix linting for spacing around default parameter assignment in function/method declaration
Summary: Fix linting for spacing around default parameter assignment in function/method declaration so that `function foo($x = null) {}` is preferred in favor of `function foo($x=null) {}`.

Test Plan: Modified existing unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10429
2014-09-10 23:02:22 +10:00
Joshua Spence
38502ba910 Apply some autofix linter rules
Summary: Self-explanatory

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10453
2014-09-10 06:50:32 +10:00
Joshua Spence
04de931151 Add an XHPAST lint rule for empty block statements
Summary: Adds an XHPAST linter rule for empty block statements. Basically, if a block statement is empty then it is much neater if the opening (`{`) and closing (`}`) braces are adjacent. Maybe this is just my own personal preference, in which case we could reduce the default severity to `ArcanistLintSeverity::SEVERITY_DISABLED`.

Test Plan: Wrote unit tests. I had to modify a bunch of existing unit tests accordingly.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10434
2014-09-10 00:05:59 +10:00
Joshua Spence
d4f9526e76 Add some missing function parameter typehints
Summary: Add some missing function parameter typehints to the `ArcanistPhutilXHPASTLinter` class.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10430
2014-09-09 08:27:09 +10:00