epriestley [Tue, 20 May 2014 18:34:28 +0000 (11:34 -0700)]
Improve 'arc get-config', 'arc set-config' and show more config info with --trace
Summary:
Fixes T4952. Several issues:
- You review configuration values with `arc set-config --show`. This makes no sense and never has, I think it just predated `arc get-config` or was easier or something.
- Instead, review values with `arc get-config` and review details with `arc get-config --verbose`.
- Show better and more detailed information about all config sources.
- Establish and show default values from a new "default" source.
- With `--trace` include more information about attempts to read configuration files.
Test Plan:
Ran `arc get-config --trace --verbose` in various working directories and received sensible-looking output.
Joshua Spence [Mon, 19 May 2014 14:52:07 +0000 (07:52 -0700)]
Remove the `ExampleLintEngine` class.
Summary: Ref T2039. Now that the `ArcanistConfigurationDrivenLintEngine` has gained more widespread use, we do no longer expect users to need to write their own lint engine. The documentation has already been updated to reflect this.
Joshua Spence [Mon, 19 May 2014 14:49:51 +0000 (07:49 -0700)]
Improve autofixing of double quotes in XHPAST linter.
Summary: The XHPAST double quotes rule autofixes strings which use double quotes where single quotes would suffice. In the case in which the double-quoted string contained an escaped double quote, the autofix string can be improved by removing the escape symbol.
Test Plan: Modified existing unit tests to cover this case.
Joshua Spence [Mon, 19 May 2014 14:48:58 +0000 (07:48 -0700)]
Add a rule to the XHPAST linter to check for whitespace before a semicolon.
Summary: This rule is based on a rule from [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php | PHP_CodeSniffer]].
Joshua Spence [Mon, 19 May 2014 13:33:22 +0000 (06:33 -0700)]
Add a rule to the XHPAST linter for detecting `elseif` usage.
Summary: This rule is adapted from [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php | PHP_CodeSniffer]] and is used to enforce the consistent use of `else if`.
Joshua Spence [Sun, 18 May 2014 13:47:37 +0000 (06:47 -0700)]
Fix the `ArcanistXHPASTLinter` single quote rule.
Summary: Previously, the `ArcanistXHPASTLinter` was suggesting that `"\1"` be written as `'\1'`, which is incorrect. Therefore, I ensured that all of the cases listed in the [[http://www.php.net/manual/en/language.types.string.php | PHP documentation]] were handled correctly.
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.
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.
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.
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`.
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.
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.
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).
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.
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.
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.
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.
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?).
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.
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.
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`.
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.
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`.
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.
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.
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.
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,
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.
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
```
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`.
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`.
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).
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`.
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.
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.
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
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.
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.
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.
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.
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)
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.
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.
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.
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
```
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.
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.
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.