]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
11 years agoTest XHPAST linter rules in isolation
Joshua Spence [Wed, 18 Nov 2015 21:57:23 +0000 (08:57 +1100)]
Test XHPAST linter rules in isolation

Summary:
Separate XHPAST linter rules in isolation from other rules and formalize the concept of a "linter rule". As the number of XHPAST linter rules grows (we currently have around 80), it becomes increasingly difficult to manage all of the test cases because `ArcanistXHPASTLinterTestCase` currently tests the entire linter (i.e. //all// linter rules) rather than testing individual rules in isolation. See D13534 for a situation in which this is painful. This is particularly bad for third party development because unit tests could break at any time depending on upstream changes.

Basically, in order to facilitate the unit testing of XHPAST linter rules in isolation, I have made the following  changes:

  # Added a `setRules()` method to `ArcanistXHPASTLinter`. Currently, `ArcanistXHPASTLinter` loads all `ArcanistXHPASTLinterRule` subclasses unconditionally. The `setRules()` method provides a way to override the configured linter rules.
  # Formalize the concept of a "linter rule". The `ArcanistXHPASTLinterRule` class was introduced in D10541. I feel that the modularization of `ArcanistXHPASTLinter` has made the linter much more maintainable and easily testable and I intend to extend this concept to other linters, such as `ArcanistTextLinter`.

Test Plan: Ran unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

11 years agoFix brace formatting linter rule after XHPAST changes
Joshua Spence [Tue, 17 Nov 2015 20:20:39 +0000 (07:20 +1100)]
Fix brace formatting linter rule after XHPAST changes

Summary: Adjusts `ArcanistBraceFormattingXHPASTLinterRule` after changes to the way in which XHPAST parses namespaces. Depends on D14498.

Test Plan: Unit tests are now passing.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

11 years agoPrevent double rendering of unit test results
Joshua Spence [Tue, 17 Nov 2015 20:19:40 +0000 (07:19 +1100)]
Prevent double rendering of unit test results

Summary: D14037 had the logic slightly wrong and unit test results are now being double rendered.

Test Plan: Ran a unit test with `arc unit -- path/to/test` and saw the results rendered only once.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

11 years agoFix ArcanistCSSLintLinter issue for messages without line number
Sébastien Santoro [Tue, 17 Nov 2015 15:14:13 +0000 (07:14 -0800)]
Fix ArcanistCSSLintLinter issue for messages without line number

Summary:
csslint offers some diagnostics related to all the document without any
relevant line number.

In such case, arc lint failed, as setLine expects null or an integer,
but not an empty string.

The 'char' and 'line' attributes in XML report are now optional.

Fixes T9804.

Test Plan: test case to repro the issue added

Reviewers: chad, joshuaspence, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T9804

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

11 years agoRemove arguments from unit test engines
Joshua Spence [Sun, 15 Nov 2015 20:04:59 +0000 (20:04 +0000)]
Remove arguments from unit test engines

Summary: Ref T9131. This doesn't seem to be used... it seems like it is a relic of postponed test results.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T9131

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

11 years agoFold `ArcanistPhutilXHPASTLinter` into `ArcanistXHPASTLinter`
Joshua Spence [Thu, 12 Nov 2015 20:08:40 +0000 (07:08 +1100)]
Fold `ArcanistPhutilXHPASTLinter` into `ArcanistXHPASTLinter`

Summary: I've been thinking about this for a while... why not just fold `ArcanistPhutilXHPASTLinter` into `ArcanistXHPASTLinter`?

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

11 years agoAdd XHAST linter standards
Joshua Spence [Thu, 12 Nov 2015 20:07:52 +0000 (07:07 +1100)]
Add XHAST linter standards

Summary: Ref T8742. As mentioned in D13512. This still needs some work, but looks roughly how I expect it to. Mainly, I want to move the standards stuff to the linter itself rather than the linter rule. I wanted to push this out for some initial feedback though.

Test Plan: This still needs work.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T8742

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

11 years agoVarious translation improvements
Joshua Spence [Mon, 2 Nov 2015 10:28:15 +0000 (21:28 +1100)]
Various translation improvements

Summary: Depends on D14070.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

11 years agoRemove some unused methods from ArcanistLinter
Joshua Spence [Mon, 2 Nov 2015 10:23:01 +0000 (21:23 +1100)]
Remove some unused methods from ArcanistLinter

Summary: These methods are unused.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

11 years agoExplicitly provide "--ff" when performing squash merges in "arc land" under Git
epriestley [Wed, 28 Oct 2015 23:46:39 +0000 (16:46 -0700)]
Explicitly provide "--ff" when performing squash merges in "arc land" under Git

Summary: Ref T3855. See discussion leading up to T3855#142304.

Test Plan: See T3855#142304.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T3855

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

11 years agoAfter pushing at the end of "arc land", cascade the origin through all local tracking...
epriestley [Wed, 28 Oct 2015 19:35:13 +0000 (12:35 -0700)]
After pushing at the end of "arc land", cascade the origin through all local tracking branches

Summary:
Fixes T9661. Users can construct arbitrarily long chains from the remote, like:

  (remote) origin/master -> (local) cascade-a -> (local) cascade-b -> (local) cascade-c -> (local) cascade-d

When a user lands "cascade-d" onto "origin/master", we should pull A, B and C if they aren't ahead of the remote.

If a user lands "cascade-d" onto itself, we should pull A, B, and C if they aren't ahead of the remote, then reset D to the remote.

We also find this chain if the last component of it is connected by the local branch having the same name as the remote branch (typical for "master") instead of an actual connection through tracking brnaches.

Test Plan: See comment below.

Reviewers: chad

Reviewed By: chad

Subscribers: edibiase

Maniphest Tasks: T9661

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

11 years agoPull git upstream-path logic into a separate class
epriestley [Wed, 28 Oct 2015 18:30:57 +0000 (11:30 -0700)]
Pull git upstream-path logic into a separate class

Summary:
Ref T9661. I need to reuse this to fix the complex workflow described in T9661 where we need to follow multiple paths to the upstream and cascade updates across them.

Pull the logic into a separate class to make this easier and less copy/pastey.

This shouldn't change any behavior.

Test Plan: Ran `arc land --preview` from detached head, remote-tracking branch, non-tracking branch, local-tracking branch. Selection of target/remote seemed correct in all cases.

Reviewers: chad

Reviewed By: chad

Subscribers: edibiase

Maniphest Tasks: T9661

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

11 years agoFix a check when deciding to destroy the local branch after "arc land"
epriestley [Wed, 28 Oct 2015 17:03:51 +0000 (10:03 -0700)]
Fix a check when deciding to destroy the local branch after "arc land"

Summary: Fixes T9660. The behavior for this check wasn't quite right -- we want to check the "source ref" (what we're landing) against the "target onto" (the branch we're landing it onto).

Test Plan:
  - Landed from `master` (tracking origin/master). No delete.
  - Landed from `feature1` (tracking local/master). Delete.
  - Landed from `feature2` (tracking origin/master). Delete.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9660

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

11 years agoMake rules for guessing onto/remote more powerful and more explicit in `arc land`
epriestley [Wed, 28 Oct 2015 15:28:46 +0000 (08:28 -0700)]
Make rules for guessing onto/remote more powerful and more explicit in `arc land`

Summary:
Fixes T9543. Fixes T9658. Ref T3855.

Major functional change is that you can have a sequence of branches like:

  origin/master -> notmaster -> feature1

...where they track each other, but you named your local master something else. Currently, we resolve only one level of upstreams, so we try to land onto "notmaster" in this case, which is wrong.

Instead, keep resolving upstreams until we either hit a cycle, don't have another upstream to look at, or find someting in a remote. In this case we'll eventually find "origin/master" and select "origin" as the remote and "master" as the target.

Other minor changes:

  - Make this selection process explicit.
  - Make the help 3000x longer.

Also fix a bug where we could incorrectly try to tell Differential to update awith `--preview`.

Test Plan:
  - Landed from a tag.
  - Landed from a tracking branch.
  - Landed from an nth-degree tracking branch.
  - Tried to land from a local branch with a cycle in upstreams.
  - Landed with --remote and --onto.
  - Read `arc help land`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9658, T3855, T9543

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

11 years agoMake "arc land" great again
epriestley [Wed, 28 Oct 2015 00:49:01 +0000 (17:49 -0700)]
Make "arc land" great again

Summary:
Ref T3855. Fixes T9537. Fixes T8620. Fixes T4333.

This declares bankruptcy and replaces the entire `arc land` workflow under Git. These are the notable changes:

  - (T3855) You can now land from a branch to itself.
  - (T3855) We now try to restore the original state very aggressively after any failure, instead of dumping you into the middle of a mess.
  - (T9537) You can now land without a local branch.
  - ([not actually] T9543) We'll now ignore the local branch if it just happens to be named the same thing as the remote branch but doesn't actually track it.
  - (T8620) You can now land from a detached HEAD.
  - (T4333) We now preserve the author and author date of whatever you land.

This may need some followup work. In particular:

  - The signal handler (that tries to put you in a better place if you ^C in the middle of things) causes ^C to work awkwardly in prompts. This might not be worth it.
  - Errors/instructions on push/merge issues might need work.
  - I dropped support for `--delete-remote` and `--update-with-blah-blah` because I think these flags aren't worth their complexity.
  - I've simplified the update/merge algorithm a bit. It may need some complexity added back in.
  - I probably missed a few things because this covers like 200 unique, creative workflows.
  - Users might need more guidance on the workflows that drop them in the middle of nowhere if they manage to reach them more often than I think.

Test Plan:
  - Used `arc land` to land like at least 15,000 different kinds of changes.
  - Landed normally.
  - Landed from a branch onto itself.
  - Landed from a detached head.
  - Landed nothing.
  - Landed with no local branch.
  - Landed onto made-up branches.
  - Landed with bad targets.
  - ^C'd things in the middle.

Reviewers: chad

Reviewed By: chad

Subscribers: tycho.tatitscheff

Maniphest Tasks: T3855, T4333, T8620, T9537, T9543

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

11 years agoFix T9635 by initializing the property
Michael Krasnow [Mon, 26 Oct 2015 16:48:31 +0000 (09:48 -0700)]
Fix T9635 by initializing the property

Summary: Fix T9635 by properly initializing a property

Test Plan: run arc unit

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T9635

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

11 years agoImprove two error handling behaviors in `arc upgrade`
epriestley [Thu, 22 Oct 2015 19:55:16 +0000 (19:55 +0000)]
Improve two error handling behaviors in `arc upgrade`

Summary:
Fixes T9222. Two issues here:

  - First, we currently continue on error. Throw instead. I just swapped us from "phutil_passthru()" to "execx()" since I don't think printing out the "pulling from remote..." status messages is very important, and this makes it easier to raise a useful exception.
  - Second, if you have a dirty working copy we currently may try to do some sort of silly stuff which won't work, like prompt you to amend changes. Instead, do a slightly lower-level check and just bail.

Test Plan:
  - Ran `arc upgrade` with a dirty working copy and got a tailored, useful error.
  - Ran `arc upgrade` with an artificially bad `git pull` command, got a failure with a specific error message.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9222

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

11 years agoExternal linters can now specify a version requirement.
Jon Parise [Wed, 21 Oct 2015 16:46:20 +0000 (09:46 -0700)]
External linters can now specify a version requirement.

Summary:
Linters can now use the `version` configuration value to specify the required
version of the external binary. The version number may be prefixed with <, <=,
>, >=, or = to specify the version comparison operator (default: =).

PHP's native `version_compare()` function is used to perform the comparison.

Fixes T4954.

Test Plan: Tested against a sample of external linters.

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, joshuaspence

Projects: #lint

Maniphest Tasks: T4954

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

11 years agoAllow Script-and-Regex linter to have optional/empty capturing patterns for char...
epriestley [Mon, 19 Oct 2015 21:35:14 +0000 (14:35 -0700)]
Allow Script-and-Regex linter to have optional/empty capturing patterns for char/line

Summary:
See discussion in D13737. If you're using this linter to match messages which //sometimes// have a character, you can get `""` (empty string) matches when the expression doesn't match. We'll complain about these later.

Instead, cast the matches the expected types.

Test Plan: @csilvers confirmed fix, see D13737.

Reviewers: chad, csilvers

Reviewed By: csilvers

Subscribers: spicyj, csilvers

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

11 years agoRemove ArcanistWorkflow::setWorkingCopy
Aviv Eyal [Fri, 16 Oct 2015 16:53:01 +0000 (09:53 -0700)]
Remove  ArcanistWorkflow::setWorkingCopy

Summary: Fixes T9583. setWorkingCopy doesn't actually work, so eliminate it.

Test Plan: arc unit --everything

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T9583

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

11 years agoPass author config to `git` with "-c x=y" instead of "--author"
epriestley [Sun, 4 Oct 2015 15:49:20 +0000 (08:49 -0700)]
Pass author config to `git` with "-c x=y" instead of "--author"

Summary: See D14232. That didn't actually work. It looks like this does.

Test Plan:
  - Ran `git commit --author ...` on build server and saw the same failure.
  - Ran `git -c ... -c ... commit ...` on build server and saw it work.

Reviewers: chad

Reviewed By: chad

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

11 years agoAllow an arc test to execute without a git author configured
epriestley [Sun, 4 Oct 2015 15:41:48 +0000 (08:41 -0700)]
Allow an arc test to execute without a git author configured

Summary:
On `sbuild`, we currently get a failure on this test. Use an explicit `--author` so we can run the test even if `user.email` and `user.name` are not set in global Git config.

```
   FAIL  ArcanistBundleTestCase::testGitRepository
15 EXCEPTION (CommandException): Command failed with error #128!
16 COMMAND
17 git commit -m 'Mark koan2 +x and edit it.'
18
19 STDOUT
20 (empty)
21
22 STDERR
23
24 *** Please tell me who you are.
25
26 Run
27
28   git config --global user.email "you@example.com"
29   git config --global user.name "Your Name"
30
31 to set your account's default identity.
32 Omit --global to set the identity only in this repository.
33
34 fatal: empty ident name (for <builder@sbuild001.phacility.net>) not allowed
```

Test Plan: Ran `arc unit --everything`. Will verify in production.

Reviewers: chad

Reviewed By: chad

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

11 years agoSet path on more linters
Vihang Mehta [Fri, 2 Oct 2015 15:58:15 +0000 (08:58 -0700)]
Set path on more linters

Summary:
This is in a similar vein as D14220 and sets a name on linter
messages. This should handle issues from D14165.

Test Plan: Run as many of the changed linters as possible + existing linter tests.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

11 years agoFix ArcanistClosureLinter
Vihang Mehta [Fri, 2 Oct 2015 12:45:48 +0000 (05:45 -0700)]
Fix ArcanistClosureLinter

Summary: Fixes T9498

Test Plan: Run `arc lint` with errors that get caught and reported by `ArcanistClosureLinter`

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T9498

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

11 years agoAdd a --target flag to `arc unit` for uploading results
epriestley [Tue, 29 Sep 2015 16:51:51 +0000 (09:51 -0700)]
Add a --target flag to `arc unit` for uploading results

Summary: Ref T5821. Basic idea here is that Harbormaster can run `arc unit --everything --target ...` to get a build target updated.

Test Plan: Ran `arc unit --target ...`, saw web UI update with test results.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T5821

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

11 years agoAllow users to skip "arc:prompt" by entering no text
epriestley [Tue, 29 Sep 2015 14:09:19 +0000 (07:09 -0700)]
Allow users to skip "arc:prompt" by entering no text

Summary:
Fixes T9476. Currently, if you enter no text in "arc:prompt", we abort resolution immediately.

However, this is a bit inconsistent (other rules that fail to resolve are skipped) it is reasonable to put some default rule behind "arc:prompt" so that you can just mash enter to select it. This construction is unusual, but seems fine and sensible to me.

If you're using "arc:prompt" as the last rule, the behavior is the same as before, so this should only make the rule more useful.

Test Plan:
  - Ran `arc which --base 'arc:prompt, git:HEAD^'` with and without the patch.
  - Without the patch, entering no text at "arc:prompt" failed immediately.
  - With the patch, entering no text caused fallback to the "git:HEAD^" rule.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9476

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

11 years agoImprove validation of 'name' and 'code' parameters for lint messages
epriestley [Fri, 25 Sep 2015 18:16:04 +0000 (11:16 -0700)]
Improve validation of 'name' and 'code' parameters for lint messages

Summary: Ref T9145. Fixes T9316. We now require "name" and "code" has a maximum length (currently, this is 32, but the next diff will raise it to 128).

Test Plan:
  - Installed PHPCS.
  - Hit both the "name" and "code" issues.
  - Applied this patch.
  - Got better errors sooner.

Reviewers: chad

Reviewed By: chad

Subscribers: aik099

Maniphest Tasks: T9145, T9316

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

11 years agoImprove arc's handling of dirty submodules in Git
epriestley [Mon, 21 Sep 2015 19:40:06 +0000 (12:40 -0700)]
Improve arc's handling of dirty submodules in Git

Summary:
Fixes T9455. Depends on D14136. When you have a dirty submodule:

  $ nano submodule/file.c # save changes

...we currently ask you to make a commit when you run `arc diff`, which is meaningless and misleading.

Instead, prompt the user separately.

This behavior isn't perfect but I think it's about the best we can do within reason.

Test Plan:
  - Ran `arc diff` in a working copy with uncommitted submodule changes only, got new prompt.
  - Ran `arc diff` in a working copy with submodule base commit changes only, got old (correct) prompt.
  - Ran `arc diff` in a working copy with both, got only old prompt (which is incomplete, but reasonable/meaningful).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9455

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

11 years agoFix an issue with "arc nrabch"
epriestley [Tue, 15 Sep 2015 18:14:07 +0000 (11:14 -0700)]
Fix an issue with "arc nrabch"

Summary:
Fixes a minor issue from D14034. PHP doesn't like `clone null;`, and if you type a nonsense command like `arc nbrhch` (as I frequently do) we try to `clone null` here.

Instead, just `return null;` if no workflow matches. Clone otherwise.

Test Plan:
  - Ran `arc nbrhcanc`
  - Ran `arc branch`

Reviewers: BYK, chad

Reviewed By: chad

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

11 years agoPrevent caching of workflows
Burak Yigit Kaya [Tue, 15 Sep 2015 12:23:52 +0000 (05:23 -0700)]
Prevent caching of workflows

Summary: Fixes T9159.

Test Plan: Run `arc patch` on a code base requiring auth for a diff that has at least one dependency.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: avivey, thoughtpolice, joshuaspence, Korvin

Maniphest Tasks: T9159

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

11 years agoMore linter's short description
Aviv Eyal [Mon, 14 Sep 2015 18:45:15 +0000 (11:45 -0700)]
More linter's short description

Summary: Closes T9353. I think this makes all descriptions at least basically informative.

Test Plan: arc linters - I can now understand what each one is about.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T9353

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

11 years agoupdate linter short desc
Aviv Eyal [Tue, 8 Sep 2015 21:52:43 +0000 (14:52 -0700)]
update linter short desc

Summary: ref T9353.

Test Plan: arc linters

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: joshuaspence, Korvin

Maniphest Tasks: T9353

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

11 years agoarc linters: switch `name` and `short`
Aviv Eyal [Tue, 8 Sep 2015 17:39:26 +0000 (10:39 -0700)]
arc linters: switch `name` and `short`

Summary: I think they were wrong.

Test Plan: `arc linters nolint`. It would fail without it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, #lint

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

11 years agoAllow upgrading in branch `stable`
Aviv Eyal [Mon, 7 Sep 2015 20:44:47 +0000 (13:44 -0700)]
Allow upgrading in branch `stable`

Summary: close T9043. This still allows for one dir to be in `master` and the other in `stable`, but hopefully that's not going to be a problem.

Test Plan: Clone arc/libph, checkout `stable`, run arc upgrade.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: cburroughs, epriestley

Maniphest Tasks: T9043

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

11 years agoImprove temporary file upload API and add viewPolicy support
epriestley [Mon, 7 Sep 2015 19:44:59 +0000 (12:44 -0700)]
Improve temporary file upload API and add viewPolicy support

Summary: Ref T7148. In D14056, I let `arc upload` upload temporary files, but this is a better way to do some of the internals. Also add support for setting a `viewPolicy`.

Test Plan: Used `arc upload`, `arc upload --temporary`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7148

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

11 years agoAdd temporary file support to ArcanistFileUploader
epriestley [Fri, 4 Sep 2015 17:34:14 +0000 (10:34 -0700)]
Add temporary file support to ArcanistFileUploader

Summary: Ref T7148. Depends on D14055. Allows files to be marked as temporary when uploaded.

Test Plan: Used `arc upload --temporary` to upload temporary files.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7148

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

11 years agoFix callsites which called libphutil_console_wrap like it were _format
Alex Vandiver [Thu, 3 Sep 2015 19:01:01 +0000 (12:01 -0700)]
Fix callsites which called libphutil_console_wrap like it were _format

Summary:
7e2df9a attempted to pht() some strings; unfortunately, it assumed
that some things that were calls to phutil_console_wrap() were
actually calls to phutil_console_format().  This produces errors of
the form:

    [2015-07-17 21:17:28] ERROR 2: str_repeat() expects parameter 2 to be long, string given at [/usr/local/libphutil/src/console/format.php:162]
    #0 str_repeat(string, string) called at [<phutil>/src/console/format.php:162]
    #1 phutil_console_wrap(string, string, string) called at [<arcanist>/scripts/arcanist.php:620]
    #2 arcanist_load_libraries(array, boolean, string, ArcanistWorkingCopyIdentity) called at [<arcanist>/scripts/arcanist.php:154]
    %s: %s

Provide an additional call to phutil_console_format() when necessary,
or simply append the relevant characters if possible.

Test Plan: Caused a library load error

Reviewers: #blessed_reviewers, epriestley

Subscribers: Korvin

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

11 years agostaging repo compatibility for older git versions
cburroughs [Wed, 2 Sep 2015 13:52:11 +0000 (06:52 -0700)]
staging repo compatibility for older git versions

Summary:
The `--no-verify` flag was not added until git 1.8.2.  This
flag is used to avoid running local pre-push hooks.  This is likely a
rare configuration and is safe to omit the flag on older versions.
Users with local pre-push hooks **and** older git version may need to
adjust their workfow.

fixes T9310

Test Plan:
 * Ran `arc diff` with my real git 1.7.10.4 and succeeded with `STAGING
   PUSHED`.
 * Edited `getGitVersion` to be > 1.8.2 and pushed again.  Got
   `STAGING FAILED` because `error: unknown option`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T9310

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

11 years agoDelete another problematic XML test file
Joshua Spence [Wed, 2 Sep 2015 08:34:55 +0000 (18:34 +1000)]
Delete another problematic XML test file

Summary: Ref T7215. This test is occasionally failing for me locally. Remove it as per D13992.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T7215

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

11 years agoRemove errant in arcanist.php
Mike Riley [Tue, 1 Sep 2015 15:46:17 +0000 (08:46 -0700)]
Remove errant  in arcanist.php

Summary: This causes `49` to be printed out preceding the start of my next terminal line every time there is an exception thrown.

Test Plan: did not see `49` printed out when exceptions were thrown

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

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

11 years agoAdd a linter rule for detecting empty files
Joshua Spence [Tue, 1 Sep 2015 09:20:11 +0000 (19:20 +1000)]
Add a linter rule for detecting empty files

Summary: Adds two different linter rules (one general purpose and another PHP specific) to prevent empty files from being added to a repository. For some unknown reason, people seem to like to do this.

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: avivey, cburroughs, Korvin

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

11 years agoAdd a linter rule for newlines after PHP open tags
Joshua Spence [Sun, 30 Aug 2015 20:49:29 +0000 (06:49 +1000)]
Add a linter rule for newlines after PHP open tags

Summary: `<?php\n\n...` is much easier to read than `<?php\n...`. Depends on D13889 and D13890.

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

11 years agoRemove leftover code for "postponed" lint and unit status
Joshua Spence [Sun, 30 Aug 2015 11:52:34 +0000 (21:52 +1000)]
Remove leftover code for "postponed" lint and unit status

Summary: Ref T9134. It looks like this functionality was removed in D13848. Depends on D13869.

Test Plan: Ran `arc diff`, `arc lint` and `arc unit`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T9134

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

11 years agoarc linters: Filter by name, make display one-line
Aviv Eyal [Fri, 28 Aug 2015 10:26:29 +0000 (03:26 -0700)]
arc linters: Filter by name, make display one-line

Summary: allow searching/filtering linters displayed by name.

Test Plan:
`$ arc linters --verbose --search JSon --search ruby` (Lots of text about many linters)
`$ arc linters --search JSon ruby` (error message)
`$ arc linters python` (no results, "try --search").
`$ arc linters ruby` (Verbose text about the "ruby" linter).

Reviewers: joshuaspence, #blessed_reviewers, epriestley

Reviewed By: joshuaspence, #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

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

11 years agoFix linter rule after XHPAST change
Joshua Spence [Thu, 27 Aug 2015 12:08:49 +0000 (22:08 +1000)]
Fix linter rule after XHPAST change

Summary: Depends on D13959.

Test Plan: Ran unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

11 years agoUse 'remote.origin.url' fallback for git < 1.7.5
Javier Arteaga [Wed, 26 Aug 2015 22:59:03 +0000 (15:59 -0700)]
Use 'remote.origin.url' fallback for git < 1.7.5

Summary:
'git ls-remote --get-url' is more correct, but younger and less
supported. This commit tempers previous optimism about its availability,
improving support for users of older git packages.

Test Plan:
* Set `git config url.xttps.insteadOf https` rewrite rule.
* Ran `arc which` with git 1.7.5 in `$PATH`, saw rewritten configured remote.
* Ran `arc which` with git 1.7.4 in `$PATH`, saw configured remote.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

11 years agoUse 'git blame --porcelain' for git blame info
Javier Arteaga [Tue, 25 Aug 2015 16:36:15 +0000 (09:36 -0700)]
Use 'git blame --porcelain' for git blame info

Summary:
This guards against stability issues with the output format of 'git
blame' (such as git config, localization (ref T5554) or future changes).

For example, `git config blame.blankboundary true` breaks `arc cover`
before this patch.

Test Plan:
* Set `git config blame.blankboundary true` on a test repo.
* Ran `arc cover`. It failed with an exception ("Bad blame?").
* Applied this patch.
* `arc cover` works.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T5554

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

11 years agoRecover from PyLint raising messages at character "-1"
epriestley [Tue, 25 Aug 2015 04:11:54 +0000 (21:11 -0700)]
Recover from PyLint raising messages at character "-1"

Summary: Fixes T9257. For some messages, PyLint can raise at "character -1", which we don't allow since we don't consider it to make sense.

Test Plan:
  - Added failing unit test from T9257.
  - Applied patch.
  - Test now passes.

Reviewers: joshuaspence, chad

Reviewed By: joshuaspence, chad

Maniphest Tasks: T9257

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

11 years agoRemove two problematic XML linter unit tests
epriestley [Tue, 25 Aug 2015 04:07:28 +0000 (21:07 -0700)]
Remove two problematic XML linter unit tests

Summary:
Fixes T7215. See D13991. These test cases have been failing intermittently for a while.

I think the XML stuff (which we don't control) changed where it raises these warnings: an old version raised them at the end of the attribute, while the new version raises them at the beginning of the attribute. Not totally 100% sure about this since installing multiple versions is fairly inconvenient, but as far as I know both versions raise the warnings, just at different character offsets.

We could do various things to fix these tests (allow the warning to raise at any character, skip the tests based on versions, etc) but I think it's easier to just remove the tests. They don't seem valuable.

Test Plan: Tests failed prior to change; now pass.

Reviewers: chad, joshuaspence

Reviewed By: joshuaspence

Maniphest Tasks: T7215

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

11 years agoMinimize reliance on 'git branch' output format
Javier Arteaga [Tue, 25 Aug 2015 00:57:41 +0000 (17:57 -0700)]
Minimize reliance on 'git branch' output format

Summary:
Ref T5554. Both the current branch name (if on a branch), as well as the
list of all local branches, can be retrieved without having to parse the
output from "git branch".

Unfortunately, there seems to be no git plumbing for "get list of
branches containing this commit" yet.
(see http://marc.info/?l=git&m=141408477614635&w=2)

For that case, this commit whitelists the output from "git branch" using
the known valid branch names from "git for-each-ref".

Test Plan:
Set up a test repo with this structure:
```
|   *  Commit B1, on branch "subfeature"
|  /
| *    Commit A1, on branch "feature"
|/
*      Commit M1, on branch "master"
|
```

In `subfeature`, I tried:
* `arc which --base 'git:branch-unique(master)'`
* `arc feature`
After that, I detached my HEAD (don't worry, I got better) and tried again.

Nothing looked broken.

(Tested with git 1.7.2.5 and 2.5.0.)

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T5554

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

11 years agoAvoid parsing git "remote show" using "ls-remote"
Javier Arteaga [Mon, 24 Aug 2015 11:51:03 +0000 (04:51 -0700)]
Avoid parsing git "remote show" using "ls-remote"

Summary:
Ref T5554. This makes git remote URL detection locale-agnostic.

The previously suggested `git config remote.origin.url` command does
almost the same, but does not support the URL rewriting features in
git-config (`url.<base>.insteadOf`).

This one does, although it has the unintuitive behavior of just printing
the passed remote name when the remote does not exist, or even when
called outside a git repo.

Test Plan:
* Switched to non-english locale in which git has a translation.
* Ran `arc which` on the Arcanist repo. It could not determine the remote URI.
* Applied patch, `arc which` found the URI.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: johnny-bit, Korvin

Maniphest Tasks: T5554

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

11 years agoExclude variables used in strings inside closures when checking for undeclared variables
Joshua Spence [Thu, 20 Aug 2015 21:26:52 +0000 (07:26 +1000)]
Exclude variables used in strings inside closures when checking for undeclared variables

Summary:
Improves upon D13795 to correctly handle variables within strings. Specifically, the  following code currently (incorrectly) warns about `$x` being undeclared:

```lang=php
function some_func() {
  return function ($x) {
    echo "$x";
  };
}
```

It's worth noting that the situation would be improved if XHPAST properly parsed strings (see T8049).

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

11 years agoAdd a call to `assert_instances_of`
Joshua Spence [Thu, 20 Aug 2015 12:44:52 +0000 (22:44 +1000)]
Add a call to `assert_instances_of`

Summary: This was taken from D13569.

Test Plan: `arc lint` still works.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

11 years agoFix wrong plural of an `arc land` message
Javier Arteaga [Thu, 20 Aug 2015 11:19:22 +0000 (04:19 -0700)]
Fix wrong plural of an `arc land` message

Summary:
"Branch" was pluralized as "branchs".

Fixes T9225.

Test Plan:
* Created test repo with two revisions on a feature branch.
* Saw old message, frowned a little.
* Applied patch.
* No longer frowning.

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: avivey, Korvin

Maniphest Tasks: T9225

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

11 years agoArcanistPyLintLinter fix to getMandatoryFlags msg-template
ealbright [Wed, 19 Aug 2015 12:45:46 +0000 (05:45 -0700)]
ArcanistPyLintLinter fix to getMandatoryFlags msg-template

Summary: Removed excess quotations on the `--msg-template` option as it was interfering with the string-int coercion

Test Plan: Unsure

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: joshuaspence, epriestley, #blessed_reviewers

Subscribers: joshuaspence, e-m-albright, Korvin

Maniphest Tasks: T9214

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

11 years agoAdd a Composer linter
Joshua Spence [Wed, 19 Aug 2015 11:39:11 +0000 (21:39 +1000)]
Add a Composer linter

Summary: Adds a basic linter for ensuring that `composer.lock` files are up-to-date.

Test Plan: We have been using this in a private project for around a month.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: johnny-bit, Korvin

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

11 years agoImprove linter handling of short array syntax
Joshua Spence [Wed, 19 Aug 2015 05:35:16 +0000 (15:35 +1000)]
Improve linter handling of short array syntax

Summary: Currently, linting PHP short array syntax (i.e. `[...]`) throws an exception ("Expected open parentheses"). This diff relaxes some restrictions which prevent short array syntax from linting with `ArcanistParenthesesSpacingXHPASTLinterRule`.

Test Plan: Modified test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: agenticarus, Korvin

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

11 years agoImprove the "inline HTML" linter rule
Joshua Spence [Wed, 19 Aug 2015 05:34:43 +0000 (15:34 +1000)]
Improve the "inline HTML" linter rule

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

Test Plan: Unit tests now pass.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

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

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

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T9140, T7409

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

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

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

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T7409

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

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

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

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

Summary:
Fixes T9029

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

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

Reviewers: joshuaspence, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T9029

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

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

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

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

Summary: This was broken in D13573.

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

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

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

Summary: Self explanatory.

Test Plan: `arc lint`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

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

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

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

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

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

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

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

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

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8096

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

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

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

Test Plan:
Ran through the following scenarios:

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

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T5568

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

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

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

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

Test Plan: Added another test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

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

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

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

Maniphest Tasks: T5568

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

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

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

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

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

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

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

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

Depends on D13819.

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T8674

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

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

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

```lang=php

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

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

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T8674

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

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

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

Test Plan: Modified existing test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T8742

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

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

Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

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

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

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

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

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

Test Plan: Added test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

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

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

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

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: johnny-bit, Korvin

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

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

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

Test Plan: Updated unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T8742

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

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

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

Test Plan:
In next diff:

{F688894}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7419

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

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

Summary: I somehow missed these.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

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

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

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

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

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

Test Plan: `arc unit --everything`

Reviewers: btrahan

Subscribers: epriestley

Maniphest Tasks: T8921

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

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

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

Test Plan: `arc unit --everything`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: kparal, epriestley, Korvin

Maniphest Tasks: T8912

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

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

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

Test Plan: `arc unit --everything`

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T8921

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

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

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

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

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

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

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

Test Plan: Added test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

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

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

Test Plan: Wait 30 seconds.

Reviewers: joshuaspence, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8915

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

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

Summary: Fixes T8847.

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

```lang=php
<?php

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

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8847

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

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

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

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

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, aurelijus

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

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

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

Test Plan: Ran unit tests.

Reviewers: btrahan, joshuaspence, chad

Reviewed By: chad

Subscribers: jsotuyod, champo, epriestley

Maniphest Tasks: T8805

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

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

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

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

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

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8332

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

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

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

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

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

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

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

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

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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