]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
12 years agoUpdate `ArcanistCoffeeLintLinter` to be compatible with CoffeeLint v1.4.0.
Joshua Spence [Sun, 18 May 2014 13:07:35 +0000 (06:07 -0700)]
Update `ArcanistCoffeeLintLinter` to be compatible with CoffeeLint v1.4.0.

Summary: CoffeeLint v1.4.0 deprecated the `--checkstyle` flag in favor of `--reporter=checkstyle`.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoFix the `ArcanistJSONLintLinter::getVersion` function.
Joshua Spence [Sun, 18 May 2014 01:36:25 +0000 (18:36 -0700)]
Fix the `ArcanistJSONLintLinter::getVersion` function.

Summary: Ref T4954. There was a typo in the original implementation. It wasn't noticed until now because the `getVersion` function isn't really used anywhere.

Test Plan: Ran `arc linters` in a repository with `ArcanistJSONLintLinter` configured, noticed that the version number appeared in the output.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4954

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

12 years agoRelax the version regex for `ArcanistFlake8Linter`.
Joshua Spence [Sun, 18 May 2014 01:18:03 +0000 (18:18 -0700)]
Relax the version regex for `ArcanistFlake8Linter`.

Summary: As noticed by @epriestley in D9060, `flake8 --version` can emit a string like "2.0" rather than the expected "2.0.0".

Test Plan: Uninstalled my existing version of `flake8` (v2.1.0) and installed a prior version (`pip install flake8==2.0.0`). Ran `flake8 --version` and inspected the output.

Reviewers: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

12 years agoFix the `ArcanistJSHintLinter::getVersion` function.
Joshua Spence [Sun, 18 May 2014 01:17:47 +0000 (18:17 -0700)]
Fix the `ArcanistJSHintLinter::getVersion` function.

Summary: As identified by @epriestley in D9060, `jshint --version` emits version information on stderr, not stdout.

Test Plan: Ran `jshint --version` locally and verified that the version information is output to stderr.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T4954

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

12 years agoFix "arc diff --raw-command --create"
epriestley [Sat, 17 May 2014 20:40:05 +0000 (13:40 -0700)]
Fix "arc diff --raw-command --create"

Summary: Fixes T5082. We try to access the repository API in some cases when we don't have one.

Test Plan:
  - Made revisions with "arc diff --raw-command --create".
  - Made this revision, without "--raw-command".

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5082

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

12 years agoAdd an `ArcanistCoffeeLintLinter` linter.
Joshua Spence [Sat, 17 May 2014 04:58:01 +0000 (21:58 -0700)]
Add an `ArcanistCoffeeLintLinter` linter.

Summary:
Add a wrapper around [[http://www.coffeelint.org/ | CoffeeLint]] as an `ArcanistExternalLinter`.

Depends on D9041.

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/D9051

12 years agoSet the working directory to the project root for external linter `ExecFuture` classes.
Joshua Spence [Sat, 17 May 2014 04:48:12 +0000 (21:48 -0700)]
Set the working directory to the project root for external linter `ExecFuture` classes.

Summary: Fixes T5085. Currently, the `ExecFuture` instances that are used to call an external linter are executed in the current working directory. This means that if a path is specified in the `.arclint` file, relative to the project root directory, that the path will not be properly interpreted by the external linter when `arc lint` is called from a level deeper than the project root.

Test Plan: Ran `arc lint` from a subdirectory of a project and verified that the linter did not throw an exception due to not being able to find the specified configuration file.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T5085

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

12 years agoAdd some `.arclint` configuration options for `ArcanistJSHintLinter`.
Joshua Spence [Sat, 17 May 2014 04:42:52 +0000 (21:42 -0700)]
Add some `.arclint` configuration options for `ArcanistJSHintLinter`.

Summary:
Allow `.jshintrc` and `.jshintignore` paths to be passed to `jshint`.

Ref T2039.

Test Plan: Added the `jshintrc` and `jshintignore` keys to an `.arclint` file that was configured to use `ArcanistJSHintLinter`. Ran `arc lint --trace` and inspected the flags that were passed to `jshint`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: john.snow, epriestley, Korvin

Maniphest Tasks: T2039, T5085

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

12 years agoAdd a linter rule for determining when single quotes should be used over double quotes.
Joshua Spence [Sat, 17 May 2014 02:25:37 +0000 (19:25 -0700)]
Add a linter rule for determining when single quotes should be used over double quotes.

Summary: Personally, I am a strong fan of this rule. There is currently a similar rule provided by PHP_CodeSniffer.

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/D9117

12 years agoMove `getPEP8WithTextOptions` method into `ComprehensiveLintEngine` class.
Joshua Spence [Sat, 17 May 2014 02:18:35 +0000 (19:18 -0700)]
Move `getPEP8WithTextOptions` method into `ComprehensiveLintEngine` class.

Summary: Since this method is only used within this class, it makes sense to move it here.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoFix `arc diff --raw` when run outside a repository
epriestley [Fri, 16 May 2014 02:03:29 +0000 (19:03 -0700)]
Fix `arc diff --raw` when run outside a repository

Summary: Fixes T5071. If you run `arc diff --raw` from some arbitrary, non-repository directory we incorrectly try to read information out of the working copy. Even if this information is available, `arc diff --raw` should not assume it's accurate (there's no guarantee the diff comes from the working copy).

Test Plan: Ran `arc diff --raw` in an arbitrary directory.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5071

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

12 years agoAdd Closure linter to arcanist
Vihang Mehta [Thu, 15 May 2014 16:18:24 +0000 (09:18 -0700)]
Add Closure linter to arcanist

Summary:
Found https://secure.phabricator.com/D4519 but it was horribly out of date, so decided to write a new version.
Kinda clobbered together form that diff and the new version of ArcanistJSHintLinter

Test Plan: Tested on personal projects with js files.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoFix issue where message contained % but wasn't intended for use with parameters
James Rhodes [Thu, 15 May 2014 00:11:45 +0000 (17:11 -0700)]
Fix issue where message contained % but wasn't intended for use with parameters

Summary: This fixes an issue with the C# linter where a message could be returned from cslint that wasn't intended for use with parameters.  This just ensures there's enough parameters so that it won't crash (and consequently ignore lint messages).

Test Plan: Ran the linter, it didn't crash.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoMinor improvements to the `ArcanistLintCheckstyleXMLRenderer` class.
Joshua Spence [Wed, 14 May 2014 00:32:49 +0000 (17:32 -0700)]
Minor improvements to the `ArcanistLintCheckstyleXMLRenderer` class.

Summary: Ref T4948. Move the `startDocument` code to a `renderPreamble` function so that, at least theoretically, the renderer can be reused. Otherwise, the only way to reuse the renderer would be to construct a new instance.

Test Plan: Ran `arc lint --output xml` and verified that the output looked reasonable.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4948

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

12 years agoBe more strict with the type of `.arclint` properties.
Joshua Spence [Tue, 13 May 2014 22:17:56 +0000 (15:17 -0700)]
Be more strict with the type of `.arclint` properties.

Summary: Although this provides less context in terms of the error message (for example, `Parameter has invalid type. Expected type 'optional regex|list<regex>', got type 'list<string>'.`), I think that it is the right approach. I think that `PhutilTypeSpec::checkMap` should be improved such that additional context is provided in the exception message.

Test Plan: Ran `arc lint`. Modified `.arclint` to contain an invalid regex and ran `arc lint` again.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoDon't prompt for patches when outputting lint results as XML.
Joshua Spence [Tue, 13 May 2014 21:40:27 +0000 (14:40 -0700)]
Don't prompt for patches when outputting lint results as XML.

Summary: The Checkstyle XML output format is not intended to be an interactive workflow.

Test Plan: Introduced linter issues and ran `arc lint`. Verified that no interactive prompt was shown.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoSupport Checkstyle as an output format for lint results.
Joshua Spence [Tue, 13 May 2014 20:20:29 +0000 (13:20 -0700)]
Support Checkstyle as an output format for lint results.

Summary: Fixes T4948. Add a lint renderer which supports outputting the lint results in the Checkstyle XML format.

Test Plan: Ran `arc lint --xml` and inspected the output.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4948

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

12 years agoRead 'phabricator.uri' and 'default' out of more config sources
epriestley [Tue, 13 May 2014 18:36:56 +0000 (11:36 -0700)]
Read 'phabricator.uri' and 'default' out of more config sources

Summary: We have old/inconsistent code for reading these. Instead, read from sources in a modern way.

Test Plan:
  - Removed "default" and "phabricator.uri" from user/local/project config.
  - Set "default" in "/etc/arcconfig".
  - Ran `arc tasks` and got a "connect to Phabricator" message.

Reviewers: btrahan, davedash

Reviewed By: davedash

Subscribers: davedash, epriestley

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

12 years agoMinor cleanup of linter testing code.
Joshua Spence [Tue, 13 May 2014 13:16:02 +0000 (06:16 -0700)]
Minor cleanup of linter testing code.

Summary:
Just some minor cleaning up, including:

- Removing old annotations for Diviner.
- Renaming some `lint-test` files so that the directory name bears a closer resemblance to that of the linter.
- Remove some useless `return` statements.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoRename test method.
Joshua Spence [Tue, 13 May 2014 12:44:32 +0000 (05:44 -0700)]
Rename test method.

Summary: Rename this test method for consistency with other linter test classes.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoWrite waiting message to stderr, not stdout.
epriestley [Tue, 13 May 2014 00:27:19 +0000 (17:27 -0700)]
Write waiting message to stderr, not stdout.

12 years agoFixed the error message when cppcheck isn't installed to not be completely wrong.
William R. Otte [Mon, 12 May 2014 19:58:03 +0000 (12:58 -0700)]
Fixed the error message when cppcheck isn't installed to not be completely wrong.

Summary: Arcanist is a dirty rotten liar.  I made it less of a dirty, rotten liar.

Test Plan: http://imgur.com/36qXcgI

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoPrint out a "waiting on stdin" message from 'arc call-conduit'
epriestley [Mon, 12 May 2014 18:36:19 +0000 (11:36 -0700)]
Print out a "waiting on stdin" message from 'arc call-conduit'

Summary: It looks like this command is just hanging if you skim the documentation and miss that you have to echo parameters into it. Print out a hint.

Test Plan: Ran `arc call-conduit` and got a hint.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

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

12 years agoMade some additional methods of `ArcanistLinter` and `ArcanistExternalLinter` final
Joshua Spence [Mon, 12 May 2014 16:48:52 +0000 (09:48 -0700)]
Made some additional methods of `ArcanistLinter` and `ArcanistExternalLinter` final

Summary: To me, it seems that these methods should never be overwritten in subclasses.

Test Plan: `arc unit`

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: aran, epriestley, Korvin

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

12 years agoMinor tweaks for XHPAST config
epriestley [Mon, 12 May 2014 12:06:14 +0000 (05:06 -0700)]
Minor tweaks for XHPAST config

Summary: Ref T2039. The type specs are right in theory but not quite correct in practice, since we pass strings in rather than objects.

Test Plan: While tweaking `phabricator/`, adjusted these to get desirable results.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

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

12 years agoFill out some more info functions for libphutil-specific linters
epriestley [Mon, 12 May 2014 12:06:04 +0000 (05:06 -0700)]
Fill out some more info functions for libphutil-specific linters

Summary: Ref T2039. It looks like "phutil-library" didn't make it over, I'll add that to the other two (unless I'm wrong and this isn't an oversight?).

Test Plan: Used `arc linters` to read help.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

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

12 years agoRemove the `getConfig` and `setConfig` method.
Joshua Spence [Mon, 12 May 2014 11:46:56 +0000 (04:46 -0700)]
Remove the `getConfig` and `setConfig` method.

Summary: It seems that there is a lot of overlap between `getConfig` / `setConfig` and `getLinterConfigurationOptions` / `setLinterConfigurationValue` respectively.

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

Reviewers: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoAllow `ArcanistPhutilXHPASTLinter` to be configured from `.arclint`.
Joshua Spence [Mon, 12 May 2014 11:46:41 +0000 (04:46 -0700)]
Allow `ArcanistPhutilXHPASTLinter` to be configured from `.arclint`.

Summary: Currently, `PhabricatorLintEngine` configures the `ArcanistPhutilXHPASTLinter` linter. In order to use `.arclint` instead, we need to expose the `ArcanistPhutilXHPASTLinter` configuration to the `.arclint` format.

Test Plan: See D9064.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

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

12 years agoMake the `PhutilLintEngine` final.
Joshua Spence [Mon, 12 May 2014 11:31:03 +0000 (04:31 -0700)]
Make the `PhutilLintEngine` final.

Summary:
Phabricator now uses the `ArcanistConfigurationDrivenLintEngine` lint
engine instead of the `PhabricatorLintEngine` lint engine.

Depends on D9064.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoModernize `ArcanistCppcheckLinter`.
Joshua Spence [Mon, 12 May 2014 11:30:36 +0000 (04:30 -0700)]
Modernize `ArcanistCppcheckLinter`.

Summary: Ref T2039. Make the `ArcanistCppcheckLinter` compatible with `.arclint`.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

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

12 years agoProvide `arc linters --verbose` to list all available options
epriestley [Mon, 12 May 2014 03:23:07 +0000 (20:23 -0700)]
Provide `arc linters --verbose` to list all available options

Summary:
Ref T2039. I'll update the corresponding documentation.

It feels a little awkward that this is disconnected from `getLinterConfigurationOptions()`, but I dislike returning weird ad-hoc structures more than I dislike having two methods. Most linters don't implement either of these anyway.

Test Plan: Ran `arc linters` and `arc linters --verbose`.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

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

12 years agoAdd some example .arclint files to un-lie the pending documentation
epriestley [Mon, 12 May 2014 03:22:57 +0000 (20:22 -0700)]
Add some example .arclint files to un-lie the pending documentation

Summary: Ref T2039. Provide some examples to help users figure out how to write these things.

Test Plan: Checked them with `jsonlint`.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

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

12 years agoUse the `ArcanistConfigurationDrivenLintEngine` as a linting engine.
Joshua Spence [Mon, 12 May 2014 02:33:40 +0000 (19:33 -0700)]
Use the `ArcanistConfigurationDrivenLintEngine` as a linting engine.

Summary: Ref T2039. The `.arclint` file is reasonably complete now and we should start using it if possible, since we are trying to recommend it to others.

Test Plan: `arc lint`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

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

12 years agoAllow linters to share resources by shoving them on the Engine
epriestley [Mon, 12 May 2014 02:28:46 +0000 (19:28 -0700)]
Allow linters to share resources by shoving them on the Engine

Summary:
Currently, the Phutil XHPAST Linter and vanilla XHPAST Linter reuse the same parse tree, but do this by having explicit knowledge of one another.

Instead, let them synchronize by writing to a glorified array of globals on the Engine. They no longer require knowledge of one another, so this can work under `.arclint`.

(This could probably be a little cleaner by putting more logic in the shared base class, but Facebook has some kind of goofy subclass of this thing and //this// patch won't disrupt it, while a cleaner one might.)

This should unblock D9057.

Test Plan: Ran unit tests and normal lint, got accurate looking results without duplicate invocations showing up in `--trace`.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

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

12 years agoRemove severity options from some linters.
Joshua Spence [Mon, 12 May 2014 02:28:26 +0000 (19:28 -0700)]
Remove severity options from some linters.

Summary: The `ArcanistGeneratedLinter` and `ArcanistNoLintLinter` don't actually ever raise any linter messages, so it doesn't make sense to set custom severities for these linters. Instead, don't expose this configuration.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoWarn when accessing deprecated lint config
epriestley [Mon, 12 May 2014 01:39:28 +0000 (18:39 -0700)]
Warn when accessing deprecated lint config

Summary:
Ref T2039. Addresses two issues:

  - Issues a warning for use of config which is deprecated by `.arclint`.
  - We no longer require an engine to be present for these linters, so `arc linters` doesn't fatal if they aren't configured.

Test Plan:
  - Ran `arc linters` in a repo with no JSHint.
  - Ran `arc linters` in a repo with junk in .arcconfig and got a warning when it was read. Verified it still took effect.

Reviewers: chad, btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

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

12 years agoAllow linters that extend `ArcanistExternalLinter` to customize the file parameter
Juan Pablo Civile [Sun, 11 May 2014 23:25:38 +0000 (16:25 -0700)]
Allow linters that extend `ArcanistExternalLinter` to customize the file parameter

Summary: Not all linters run on a `command file` fashion. In particular, the maven checkstyle plugin runs like `command --flag=file`.

Test Plan: Run a linter that extends `ArcanistExternalLinter`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoProvide more help text for `arc linters`
epriestley [Sun, 11 May 2014 23:16:45 +0000 (16:16 -0700)]
Provide more help text for `arc linters`

Summary: Ref T2039. This isn't exhaustive, but moves things forward by a decent chunk.

Test Plan: Used `arc linters` and read the messages.

Reviewers: chad, btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

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

12 years agoAdd 'arc linters' to list available linters and status
epriestley [Sun, 11 May 2014 20:42:56 +0000 (13:42 -0700)]
Add 'arc linters' to list available linters and status

Summary: Ref T2039. We're starting to get kind of a lot of linters; provide `arc linters` to help users review and understand them and construct `.arclint` files.

Test Plan: {F152205}

Reviewers: btrahan, joshuaspence

Reviewed By: btrahan, joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

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

12 years agoAllow global excludes to be specified in `.arclint`.
Joshua Spence [Sun, 11 May 2014 12:32:38 +0000 (05:32 -0700)]
Allow global excludes to be specified in `.arclint`.

Summary: Currently, paths to be excluded from linting need to be specified for each linter individually. This is a pain for projects that are using even a moderate number of linters and which have common paths which should be excluded from linting completely.

Test Plan: Unfortunately, it's hard to test this sort of stuff. I cloned the `arclint-examples` repository and tested my changes there,

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoMinor formatting changes to `ArcanistSpellingDefaultData`.
Joshua Spence [Sun, 11 May 2014 12:25:47 +0000 (05:25 -0700)]
Minor formatting changes to `ArcanistSpellingDefaultData`.

Summary:
Fixed a few minor nitpicks:

  - Fix indentation.
  - Change double quotes to single quotes.
  - Add trailing commas to arrays.

Test Plan: Meh.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoUse PHP type hinting in `ArcanistXHPASTLinter`.
Joshua Spence [Sat, 10 May 2014 08:56:06 +0000 (01:56 -0700)]
Use PHP type hinting in `ArcanistXHPASTLinter`.

Summary: Explicitly specify the types of the function parameters. This change is basically the same as D8388.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoModernize `ArcanistMergeConflictLinter`.
Joshua Spence [Sat, 10 May 2014 08:55:47 +0000 (01:55 -0700)]
Modernize `ArcanistMergeConflictLinter`.

Summary: The only real change here is adding a `getLinterConfigurationName` method so that this linter can be used with an `.arclint` file. Everything else is just some minor tidying.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoRemove some dead comments.
Joshua Spence [Sat, 10 May 2014 08:53:21 +0000 (01:53 -0700)]
Remove some dead comments.

Summary: These comments are redundant now.

Test Plan: N/A

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoAdd `--quiet` flags to the `ArcanistCSSLintLinter`.
Joshua Spence [Sat, 10 May 2014 08:52:57 +0000 (01:52 -0700)]
Add `--quiet` flags to the `ArcanistCSSLintLinter`.

Summary: This isn't really necessary, nor does it bear any significant benefits, however semantically it seems to make sense. From `csslint --help`, the `--quiet` flag causes `csslint` to "Only output when errors are present".

Test Plan:
Tested using `csslint` directly:

```
> csslint test.css

csslint: No errors in /home/joshua/workspace/github.com/facebook/arcanist/foo.css.
> csslint --quiet test.css
```

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoMake the methods of `ArcanistBaseXHPASTLinter` final.
Joshua Spence [Sat, 10 May 2014 08:51:44 +0000 (01:51 -0700)]
Make the methods of `ArcanistBaseXHPASTLinter` final.

Summary: No subclass should need to override these methods. Additionally, none currently do.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoPHPCS supports reading from stdin.
Joshua Spence [Sat, 10 May 2014 08:50:43 +0000 (01:50 -0700)]
PHPCS supports reading from stdin.

Summary: PHPCS does actually support reading data from stdin, so let's make `ArcanistExternalLinter` aware of this.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoModernize `ArcanistCpplintLinter`.
Joshua Spence [Sat, 10 May 2014 08:32:53 +0000 (01:32 -0700)]
Modernize `ArcanistCpplintLinter`.

Summary: Convert the `cpplint.py` wrapper linter to `ArcanistExternalLinter`. This is in preparation for T2039.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

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

12 years agoAllow .arclint to configure max line length of text linter
Phil Frost [Fri, 9 May 2014 18:31:58 +0000 (11:31 -0700)]
Allow .arclint to configure max line length of text linter

Test Plan:
Verified manually. Something like this in .arclint:

  "linters" : {
    "text" : {
      "type" : "text",
      "include" : "(\\.(txt|py|html?)$)",
      "text.max-line-length": 200
    }

changes the line length. Something other than an integer there raises an error.

Reviewers: epriestley, #blessed_reviewers, #arcanist

Reviewed By: epriestley, #blessed_reviewers, #arcanist

Subscribers: Korvin, epriestley

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

12 years agoDon't call writeLogLog. Just writeLog will do.
epriestley [Fri, 9 May 2014 17:22:50 +0000 (10:22 -0700)]
Don't call writeLogLog. Just writeLog will do.

Test Plan: Ran `arc lint` locally. Now it doesn't exit with an error.

Reviewers: #blessed_reviewers, #arcanist, epriestley

Reviewed By: #blessed_reviewers, #arcanist, epriestley

Subscribers: epriestley

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

12 years agoRemove `debug` key from `.arclint` file format.
Joshua Spence [Fri, 9 May 2014 13:00:36 +0000 (06:00 -0700)]
Remove `debug` key from `.arclint` file format.

Summary: Having a `debug` key in the `.arclint` file format doesn't seem right. Instead, it would be better to just use a `PhutilConsole` and the `writeLog` method so that "debug" messages are output when using `arc --trace`.

Test Plan: Ran `arc lint --trace` in a repository using `.arclint`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoFix a typo.
Joshua Spence [Thu, 8 May 2014 13:50:06 +0000 (06:50 -0700)]
Fix a typo.

Summary: The `lessc` binary is a part of the NPM `less` module.

Test Plan: `npm install less` works whereas `npm install lessc` does not.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoFix a typo in land workflow
Bob Trahan [Wed, 7 May 2014 16:15:14 +0000 (09:15 -0700)]
Fix a typo in land workflow

Summary: Contine is not a word methinks.

Test Plan: looks better

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

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

12 years agoAdd a LESS linter.
Joshua Spence [Tue, 6 May 2014 13:50:44 +0000 (06:50 -0700)]
Add a LESS linter.

Summary: This class provides an adapter for [[https://github.com/less/less.js/ | lessc]].

Test Plan: Wrote and executed unit tests.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoParse JSON as an associate array.
Joshua Spence [Tue, 6 May 2014 04:18:43 +0000 (21:18 -0700)]
Parse JSON as an associate array.

Summary:
It seems that in some situations, JSHint does not set the `evidence`
property. In such cases, PHP fails with `Undefined property:
stdClass::$evidence`. It would be safer to access the error object as an
associative array rather than as `stdClass`.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoAdd a `puppet-lint` linter.
Joshua Spence [Tue, 6 May 2014 03:42:40 +0000 (20:42 -0700)]
Add a `puppet-lint` linter.

Summary: This linter is a wrapper around [[http://puppet-lint.com/ | puppet-lint[]].

Test Plan: Wrote an executed unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoReduce method visibility.
Joshua Spence [Tue, 6 May 2014 03:31:33 +0000 (20:31 -0700)]
Reduce method visibility.

Summary: These methods are declared `public`, but there are meant to be `protected` (as they are declared in `ArcanistExternalLinter`).

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoAdd an XML linter.
Joshua Spence [Tue, 6 May 2014 03:15:53 +0000 (20:15 -0700)]
Add an XML linter.

Summary: Add a linter which uses [[http://php.net/simplexml | SimpleXML]] to detect errors and potential problems in XML files.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoAdd a JSON linter.
Joshua Spence [Tue, 6 May 2014 03:15:35 +0000 (20:15 -0700)]
Add a JSON linter.

Summary: Provide bindings for [[https://github.com/zaach/jsonlint | JSONLint]], which is a useful tool for linting and validating JSON. Theoretically, this could be done with pure PHP, however it would not be trivial (`json_decode`, for example, does not provide any context as to JSON validation errors).

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoUpdating the pylint linter to set the output fomat correctly depending on the version...
Andrew Jones [Thu, 10 Apr 2014 13:07:42 +0000 (09:07 -0400)]
Updating the pylint linter to set the output fomat correctly depending on the version of pylint installed

See: <https://github.com/facebook/arcanist/pull/161>

Reviewed by: epriestley

12 years agoAccept int as map key too
Burak Yigit Kaya [Wed, 30 Apr 2014 01:33:10 +0000 (18:33 -0700)]
Accept int as map key too

See: <https://github.com/facebook/arcanist/pull/163>

Reviewed by: epriestley

12 years agoFix `flake8` unit test.
Joshua Spence [Tue, 6 May 2014 01:59:35 +0000 (18:59 -0700)]
Fix `flake8` unit test.

Summary:
This unit test is failing for me. It seems that I have a newer version of `flake8`. We should probably provide support for the most recent versions of any external tools, at least until we can implement version-specific stuff.

I am running `2.1.0 (pep8: 1.5.6, pyflakes: 0.8.1, mccabe: 0.2.1) CPython 2.7.6 on Linux`.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoConvert more linters to modern formats with `.arclint` support
Joshua Spence [Tue, 6 May 2014 01:58:13 +0000 (18:58 -0700)]
Convert more linters to modern formats with `.arclint` support

Summary:
Ref T3186. Ref T2039.

  - Convert JSHint to modern format; improve granularity of errors.
  - Convert PyFlakes to modern format;
  - Remove ApacheLicenseLinter and LicenseLinter (these have been deprecated for a very long time).

This is somewhat disruptive and will break some users by no longer respecting various path/config options. I'll sequence documentation and deprecation warnings in front of these.

Test Plan: Ran unit tests.

Reviewers: btrahan, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin, joshuaspence, aran

Maniphest Tasks: T3186, T2039

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

12 years agoAdd a `getVersion` function to `ArcanistExternalLinter`.
Joshua Spence [Mon, 5 May 2014 22:10:20 +0000 (15:10 -0700)]
Add a `getVersion` function to `ArcanistExternalLinter`.

Summary:
This method will, theoretically, allow `arc lint` to be configured to require some minimum version of an external linter (although this would probably require significantly more work).

Additionally, the existence of this method simplifies the `getCacheVersion` function which, previously, was implemented by the external linters individually. Instead, a general approach to determining the version for cacheing purposes can be used.

Fixes T4954.

Test Plan: I'm not sure how to test this.

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T4954

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

12 years agoModernize `ArcanistJSHintLinter`.
Joshua Spence [Mon, 5 May 2014 21:22:26 +0000 (14:22 -0700)]
Modernize `ArcanistJSHintLinter`.

Summary: Modernize `ArcanistJSHintLinter` by extending from `ArcanistExternalLinter` instead of `ArcanistLinter`.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoArcanst - add support for custom statuses to `arc close` workflow
Bob Trahan [Thu, 1 May 2014 23:14:03 +0000 (16:14 -0700)]
Arcanst - add support for custom statuses to `arc close` workflow

Summary:
Fixes T4938. Now that we have customs statuses, this workflow needs to know about 'em.

One fun caveat is that Conduit isn't up and running to generate the help method, so I had to add a parameter to have the statuses list out. This could maybe be omitted since entering erroneous status options does indeed tell you the correct options.

Test Plan:
`arc close --list-status` -- got a list of statuses
`arc close T1` -- closed T1
`arc close T1` -- error T1 closed already
`arc close T1 -s foobar` -- T1 status set to foobar

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T1, T4938

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

12 years agoIt should be also valid to have empty change under hg
Peng Li [Tue, 29 Apr 2014 21:17:35 +0000 (14:17 -0700)]
It should be also valid to have empty change under hg

Summary: Like git, it is also valid to have empty net change under hg. Should not throw if that is the case.

Test Plan: Tried on a hg repo.

Reviewers: lifeihuang, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoAdd "CURLFile" to the class whitelist
epriestley [Tue, 29 Apr 2014 11:35:18 +0000 (04:35 -0700)]
Add "CURLFile" to the class whitelist

Summary: See D8876, etc.

Test Plan: ~o.O~

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

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

12 years agoCorrect "agument" to "argument", not "augment"
Jinghao Yan [Mon, 28 Apr 2014 23:29:06 +0000 (16:29 -0700)]
Correct "agument" to "argument", not "augment"

See: <https://github.com/facebook/arcanist/pull/162>

It looks like the word `argument` appears many more times than `augment`, so I'm assuming `agument` is most likely to be a typo of `argument`.

Reviewed by: epriestley

12 years agoAllow `ArcanistExternalLinter` flags to be specified as an array.
Joshua Spence [Wed, 23 Apr 2014 23:22:49 +0000 (16:22 -0700)]
Allow `ArcanistExternalLinter` flags to be specified as an array.

Summary: Personally, I prefer to specify command lines flags as an array rather than a string.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aran, epriestley, Korvin, chad

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

12 years agoShow build results in `arc land`
epriestley [Thu, 17 Apr 2014 22:59:54 +0000 (15:59 -0700)]
Show build results in `arc land`

Summary:
Fixes T4809. When landing a revision, check for a (non-manual) buildable of the current diff. If we find one, check its status:

  - If it passed, print out a message to inform the user that we checked.
  - If it failed or is still building, print out details about the issue and require a confirmation to continue.
  - Just ignore other cases.

Test Plan:
  - Ran `arc land` on a revision with no buildable, a passing buildable, a failed buildable, and a building buildable for the current diff.
  - Got sensible output / prompts.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4809

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

12 years agoAfter landing to a repository, hint that it should be updated
epriestley [Wed, 16 Apr 2014 20:01:14 +0000 (13:01 -0700)]
After landing to a repository, hint that it should be updated

Summary: Fixes T4605. Smart waits (see D8782) are presumably good on the balance, but may cause some delays when changes are made to rarely updated repositories. To help mitigate this, have `arc land` hint that a repository has changed.

Test Plan: Will run `arc land`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4605

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

12 years agoArcanist - fix shouldAmend code
Bob Trahan [Fri, 11 Apr 2014 20:07:54 +0000 (13:07 -0700)]
Arcanist - fix shouldAmend code

Summary: make it a real member variable. See rARC77a9c1814063 and D8753#33914.

Test Plan: sending up this diff!

Reviewers: shadowhand, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

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

12 years agoArcanist - normalize question about unstaged files across workflows (diff vs land)
Bob Trahan [Fri, 11 Apr 2014 17:52:35 +0000 (10:52 -0700)]
Arcanist - normalize question about unstaged files across workflows (diff vs land)

Summary:
Fixes T4163. Re-word the question so its the same as in "arc diff". Draw the line though and don't automagically do anything if the user says "Y", 'cuz amending / adding files last minute in 'arc land' and other workflows is batshit insane. Assuming infinite growth in the future, I think its best to get this language consistent now.

I changed the shouldAmend member variable to a shouldAmend() function with a static inside. Previously shouldAmend was getting set as a side effect and it was kind of weird. I thought maybe it was written this way because the calls to the vcs are a little slow or something. As such, I figured caching it in the static was a good idea? Didn't seem awful but maybe a premature optimization with whatever the performance reality turns out to be.

Also a modest amount of bonus pht.

Test Plan: this very diff. i'm going to arc land it laters too.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: chad, epriestley, Korvin

Maniphest Tasks: T4163

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

12 years agoArcanist - stop arc land if local is ahead of remote
Bob Trahan [Wed, 9 Apr 2014 19:35:31 +0000 (12:35 -0700)]
Arcanist - stop arc land if local is ahead of remote

Summary: Fixes T4291. Also pht user-facing strings.

Test Plan:
made a branch `foo` off master. made a commit and a diff in `foo`. switched backed to master and cowboy committed some thing. went back to branch`foo`, did an arc land, and saw the error message. went back to master, did a git resert --hard HEAD^1, went back to branch `foo`, and then successfully arc landed.

also ran arc help land and things looked good

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4291

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

12 years agoChanged the rendering of the `priority` column color based on the `priorityColor...
epriestley [Wed, 9 Apr 2014 19:13:34 +0000 (12:13 -0700)]
Changed the rendering of the `priority` column color based on the `priorityColor` property

Summary:
I changed the rendering of the bar color for the `priority` column when running `arc tasks` to match the `priorityColor` property.

If the `priorityColor` property is one of the basic colors already supported by ansi, then the bar is set to that color, otherwise it is set to white.

This will allow the user to customize maniphest priorities and then set their own colors and have those colors display correctly when running `arc tasks`

Fixed some linting errors

Test Plan:
Run `arc tasks` and ensure that:
 * the priority column is displayed with a colored bar
 * the priority column bar is the correct color (or white if it is an unsupported color)

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoChanged checking for a closed task in `arc tasks` to look for the isClosed property...
Brayden Winterton [Wed, 9 Apr 2014 14:48:24 +0000 (07:48 -0700)]
Changed checking for a closed task in `arc tasks` to look for the isClosed property instead of a non-empty status

Summary: I changed the way `arc tasks` was checking to see if a maniphest task was closed from looking for a non-empty status to looking for the isClosed property submitted in D8731.

Test Plan: Run `arc tasks` and check that the tasks show open/closed correctly.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoArcanist - allow amending revisions by other authors in the working copy
Bob Trahan [Tue, 8 Apr 2014 18:58:50 +0000 (11:58 -0700)]
Arcanist - allow amending revisions by other authors in the working copy

Summary: Fixes T4670. Give the user an option to abort but otherwise proceed.

Test Plan: arc patch D8685 (by epriestley); arc amend

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4670

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

12 years agoFix an issue in arc patch with git-svn
Peng Li [Tue, 8 Apr 2014 17:46:12 +0000 (10:46 -0700)]
Fix an issue in arc patch with git-svn

Summary:
We recently moved our HEAD and it caused some issues on `arc patch` with git-svn repos. The base revision is incorrect and patch will fail. Add the check in such case to make it work.
The check was there before but removed in change b202158. The reason wasn't mentioned there though.

Test Plan: Tried it on svn.

Reviewers: lifeihuang, JoelB, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoMake "arc land" support landing someone else's code that got there via arc patch
Bob Trahan [Mon, 7 Apr 2014 18:44:14 +0000 (11:44 -0700)]
Make "arc land" support landing someone else's code that got there via arc patch

Summary: Ref T4670.

Test Plan: arc patch D8685; arc land --hold; verified i got a nice message asking me to be sure i wanted to land epriestley's code

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4670

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

12 years agoT4670 Remove the any-author flag from the which command, make any-author the default...
Gabriel Guzman [Thu, 3 Apr 2014 18:28:24 +0000 (11:28 -0700)]
T4670 Remove the any-author flag from the which command, make any-author the default, and annotate the username of the owner of the revision.

Summary: Remove any-author flag from 'arc which' make any-author be the default behavior.  Annotate revision with the owners username.

Test Plan:
Apply a patch that you don't own (arc patch Dxxx) run 'arc which' verify that:
   1. You see the revision
   2. You see the original authors username next to the revision (owned by sjobs) etc.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

12 years agoAdd coverage reports to py.test runner
David Cramer [Wed, 2 Apr 2014 18:31:38 +0000 (11:31 -0700)]
Add coverage reports to py.test runner

Summary: Of note this now forces the pytest-cov plugin to be installed unless they turn it off.

Test Plan:
```
../arcanist/bin/arc unit

COVERAGE REPORT
     97%     changes/models/test.py
    100%     tests/changes/api/serializer/models/test_testcase.py
    100%     changes/api/serializer/models/testcase.py
 UNIT OKAY  No unit test failures.
Updated an existing Differential revision:
        Revision URI: https://tails.corp.dropbox.com/D43387

Included changes:
  M       changes/api/serializer/models/testcase.py
  M       changes/models/test.py
  M       tests/changes/api/serializer/models/test_testcase.py
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoFix escaping of bookmarknames properly for `arc patch`
epriestley [Tue, 1 Apr 2014 15:21:15 +0000 (08:21 -0700)]
Fix escaping of bookmarknames properly for `arc patch`

Summary:
Fixes T4596. I misunderstood this issue and D8512 was not correct. Specifically:

  - The `hg log` needs to be escaped, since otherwise "arcpatch-x" is interpreted as a revset.
  - The `hg update` does not need to be escaped, since updating to a revset doesn't make sense and the command never treats its argument as a revset.
  - The `hg bookmark` does not need to be escaped, for similar reasons.

Test Plan:
  - Ran these commands in isolation and got sensible, consistent results.
  - Ran `arc patch` several times in a row and got proper bookmark names.

Reviewers: btrahan, durham, rvanvelzen

Reviewed By: rvanvelzen

Subscribers: epriestley

Maniphest Tasks: T4596

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

12 years agoStrip comments during `arc diff --verbatim` workflow before submitting to Phabricator
epriestley [Tue, 1 Apr 2014 15:21:05 +0000 (08:21 -0700)]
Strip comments during `arc diff --verbatim` workflow before submitting to Phabricator

Summary: Fixes T4649. The issue in that task is caused because we're submitting a block of text including comments. We've probably been doing this for a long time, but maybe were more liberal in parsing before. Instead, strip them.

Test Plan: Ran `arc diff --verbatim` and got "Dxxx" prefilled correctly.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4649

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

12 years agoAllow arc to parse `svnlook` diffs from moves/copies
epriestley [Tue, 1 Apr 2014 15:20:55 +0000 (08:20 -0700)]
Allow arc to parse `svnlook` diffs from moves/copies

Summary: Ref T4697. This is similar to the existing stuff, but `svnlook diff ...` can also produce a "Copied" header. Currently, we choke on it in Herald when running pre-commit rules.

Test Plan: Added and ran tests. In the next diff, used this in a real system.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4697

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

12 years agofix tab complete for out-of-workdir
Aviv Eyal [Wed, 26 Mar 2014 00:32:58 +0000 (17:32 -0700)]
fix tab complete for out-of-workdir

Summary:
see https://github.com/facebook/phabricator/issues/546 - arc complete blows up when not
in a workdir.

There's no "is ArcanistWorkingCopyIdentity object valid" method, but getVCSType() looks like the
closest match.

git grep for `getProjectRoot` didn't reveal any more problmatic call sites.

Test Plan: `arc [tab] [tab]`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

12 years agoSupport `git-format-patch` format in diff parser
epriestley [Sat, 15 Mar 2014 18:25:49 +0000 (11:25 -0700)]
Support `git-format-patch` format in diff parser

Summary:
Fixes T4063. The `git format-patch` command produces a special header
and footer which we need to detect, strip, and parse.

Test Plan:
  - Added and ran unit tests.
  - Submitted a diff with `git format-patch HEAD^ --stdout | arc diff --raw`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4063

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

12 years agoUse more modern detection of repositories in "arc close-revision"
epriestley [Fri, 14 Mar 2014 01:01:53 +0000 (18:01 -0700)]
Use more modern detection of repositories in "arc close-revision"

Summary:
Fixes T4603. We fire `arc close-revision --finalize` implicitly from `arc land`, which may close a corresponding Differential revision.

We want to close if the repository is not present in Phabricator (i.e., we'll never be able to close in response to the commit message, since we'll never see it). Historically, we used Arcanist Project -> "Tracked" to make this determination. Instead, just check if the working copy is associated with a repository. This is simpler, easier, and works better.

Test Plan: Ran `arc close-revision --finalize`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: aran, epriestley

Maniphest Tasks: T4603

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

12 years agoDon't close revisions on "arc amend"
epriestley [Fri, 14 Mar 2014 01:00:20 +0000 (18:00 -0700)]
Don't close revisions on "arc amend"

Summary:
Ref T4603. This workflow predates `arc land` and doesn't make much sense in modern Phabricator/Arcanist. It is surprising that `arc amend` will sometimes close accepted revisions, and we're better at detecting that repositories are tracked, and tracking repositories is easier.

Also fix some inaccuracies and old claims in the documenation and help.

Test Plan: Ran `arc amend`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: aran, epriestley

Maniphest Tasks: T4603

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

12 years agoUse hgsprintf() when managing bookmarks in arc patch in mercurial
epriestley [Thu, 13 Mar 2014 02:43:48 +0000 (19:43 -0700)]
Use hgsprintf() when managing bookmarks in arc patch in mercurial

Summary: Fixes T4596. I couldn't immediately reproduce this, but the `hgsprintf()` version is clearly more correct.

Test Plan: Used `arc patch --trace` to examine hg commands.

Reviewers: btrahan, durham

Reviewed By: durham

Subscribers: aran, epriestley

Maniphest Tasks: T4596

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

12 years agoLint engine seems to get null configuration manager in svn precommit hook workflow
Peng Li [Tue, 11 Mar 2014 22:26:31 +0000 (15:26 -0700)]
Lint engine seems to get null configuration manager in svn precommit hook workflow

Summary:
We recently tried to advance the arcanist HEAD in our release branch but failed, due to an exception in SVN pre-commit hook like this:

abort: Commit blocked by pre-commit hook (exit code 1) with output:
 LINT 1.3s FacebookWebJSLintLinter (1 file)
Exception
Some linters failed:
 - FacebookWebCopyrightLinter: BadMethodCallException: Call to a member function getConfigFromAnySource() on a non-object
(Run with --trace for a full exception trace.)

However `arc lint` works just fine. By searching the change history, it looks related to a few commits D7271, D7377, D7382, especially D7377, where configuration manager is added to the lint engine. Add it to the SVN precommit hook workflow too.

Test Plan: I am not quite sure how to test it out easily. Any suggestions?

Reviewers: lifeihuang, JoelB, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aran, epriestley, mikemag, Korvin

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

12 years agoArcanist - add revision data to TYPE_LAND_WILLPUSHREVISION event
Bob Trahan [Tue, 11 Mar 2014 22:21:46 +0000 (15:21 -0700)]
Arcanist - add revision data to TYPE_LAND_WILLPUSHREVISION event

Summary:
pretty straight-forward stuff here. Note that in other events we use "fields" or "specification" rather than "revision"; I think "revision" is best particularly in this context where it is in fact the revision being landed.

Fixes T4565.

Test Plan: php -l

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: aran, epriestley, Korvin

Maniphest Tasks: T4565

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

12 years agoIgnore detached git branches.
Joshua Spence [Sun, 9 Mar 2014 15:04:33 +0000 (08:04 -0700)]
Ignore detached git branches.

Summary:
Fixes T4559.

It looks like the code currently (at least partially) handles this by checking for `(no branch)`. I suspect that the behaviour of `git` has changed (I am running version 1.9.0) because I haven't figured out what state to be in to cause `git` to output `(no branch)`.

Test Plan: Ran `arc branch` when on a detached branch.

Reviewers: #blessed_reviewers, epriestley

CC: Korvin, epriestley, aran
Maniphest Tasks: T4559

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

12 years agoMake assertTrue() / assertFalse() messages more descriptive
epriestley [Sun, 9 Mar 2014 03:23:23 +0000 (19:23 -0800)]
Make assertTrue() / assertFalse() messages more descriptive

Summary: See discussion in D8460. Primarily, this prints out the failing value when a true/false assertion fails, so if it was something useful (like a function result) it's visible.

Test Plan:
Added `assertTrue("quack")`:

     FAIL  ArcanistDiffParserTestCase::testParser
  Assertion failed, expected 'true' (at ArcanistDiffParserTestCase.php:16).

  ACTUAL VALUE
  quack

Added `assertFalse("quack")`:

     FAIL  ArcanistDiffParserTestCase::testParser
  Assertion failed, expected 'false' (at ArcanistDiffParserTestCase.php:16).

  ACTUAL VALUE
  quack

Added `assertEqual("quack", "moo")`:

     FAIL  ArcanistDiffParserTestCase::testParser
  Assertion failed, expected values to be equal (at ArcanistDiffParserTestCase.php:16).
  Expected: quack
    Actual: moo

Reviewers: joshuaspence

Reviewed By: joshuaspence

CC: aran
Differential Revision: https://secure.phabricator.com/D8465

12 years agoUtilize `assertFalse` and `assertTrue` methods.
epriestley [Sun, 9 Mar 2014 02:32:32 +0000 (18:32 -0800)]
Utilize `assertFalse` and `assertTrue` methods.

Summary:
Ref D8460.

Use `$this->assertFalse(...)` and `$this->assertTrue(...)` instead of `$this->assertEqual(false, ...)` and `$this->assertEqual(true, ...)` respectively.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

CC: Korvin, epriestley, aran
Differential Revision: https://secure.phabricator.com/D8461

12 years agoAdded some additional assertion methods.
Joshua Spence [Sun, 9 Mar 2014 02:23:14 +0000 (18:23 -0800)]
Added some additional assertion methods.

Summary:
There are quite a few tests in Arcanist, libphutil and Phabricator that do something similar to `$this->assertEqual(false, ...)` or `$this->assertEqual(true, ...)`.

This is unnecessarily verbose and it would be cleaner if we had `assertFalse` and `assertTrue` methods.

Test Plan: I contemplated adding a unit test for the `getCallerInfo` method but wasn't sure if it was required / where it should live.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran
Differential Revision: https://secure.phabricator.com/D8460

12 years agoFix unit test coverage for `NoseTestEngine`.
Joshua Spence [Fri, 7 Mar 2014 18:16:27 +0000 (10:16 -0800)]
Fix unit test coverage for `NoseTestEngine`.

Summary:
I noticed that code coverage wasn't showing in Differential for
some repositories that we are using with Phabricator.

`arc unit` would should unit test coverage, but the paths were messy
(for example, `.//foo/bar.py` instead of `foo/bar.py`). As a result,
the code coverage info wasn't recognised as being for the correct
module.

I'm not sure why this logic is the way that it is... perhaps this is to
do with an older version of `nose` (I am using v1.3.0).

Test Plan:
I created a diff for an internal repository that we have, and
observed that code coverage was displayed in Differential.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, seporaitis, avive, dctrwatson, zeeg
Differential Revision: https://secure.phabricator.com/D8433

12 years agoFail Arcanist tests when they make zero assertions
epriestley [Fri, 7 Mar 2014 18:03:24 +0000 (10:03 -0800)]
Fail Arcanist tests when they make zero assertions

Summary:
Fixes T4570. When a test case doesn't make any assertions, fail it:

  - A tiny fraction of tests pass by not throwing. These tests can easily make a trivial assertion. It took about 5 minutes to fix them all (D8435, D8436).
  - In other cases, no assertions means a test construction problem, as with T4570. In these cases, failing loudly catches a severe error.
  - Fixes the no-assertion test cases in `arcanist/`
  - Makes the PHP 5.4 test pass for the moment, see discussion in T4334.

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

Reviewers: leebyron, btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T4570

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

12 years agoFail lint tests if no tests are found in the test directory
epriestley [Fri, 7 Mar 2014 18:03:17 +0000 (10:03 -0800)]
Fail lint tests if no tests are found in the test directory

Summary: Ref T4570. Testing a directory with no recognized tests currently passes, but should fail.

Test Plan:
  - Ran `arc unit`.
  - Removed tests from a test directory, ran `arc unit`, got test failure.

Reviewers: leebyron, btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T4570

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

12 years agoRemove a parameter
Peng Li [Thu, 6 Mar 2014 23:53:06 +0000 (15:53 -0800)]
Remove a parameter

Summary: D7271 added this line but the signature of function ArcanistWorkingCopyIdentity::newFromRootAndConfigFile(...) was never changed. I have no idea why it was added here and it's causing failures in facebook. I am just removing it now.

Test Plan: No idea how to test

Reviewers: wez, lifeihuang, JoelB, #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran
Differential Revision: https://secure.phabricator.com/D8432