1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-10-24 17:48:50 +02:00
Commit graph

164 commits

Author SHA1 Message Date
adonohue
72ee0ced4f Don't output "OKAY" for arc lint --output json.
Summary: --output json will be used for scripts, so support script writers a
little better.

Test Plan:
arc lint [--output {json, summary}]
arc lint --output json {--apply-patches, --never-apply-patches}

Reviewers: epriestley

Reviewed By: epriestley

CC: jack, aran, epriestley

Maniphest Tasks: T675

Differential Revision: 1220
2011-12-15 11:03:17 -08:00
Jack Lindamood
02ed14e31e Add description to json output
Summary:
Adds a 'desc' field to json output so I can use that inside my vim
plugin.

Test Plan:
Lint a few things.  Description text shows up in vim

Reviewers: epriestley

Reviewed By: epriestley

Differential Revision: 1210
2011-12-14 15:30:36 -08:00
Jason Ge
3629308f2f Enable override ArcanistXHPASTLinter
Summary:
add method setXHPASTTreeForPath() so that a child class of
ArcanistXHPASTLinter can set the tree easily.

Test Plan: wrote a subclass of ArcanistXHPASTLinter and it worked.

Reviewers: pad, epriestley

Reviewed By: pad

CC: aran, pad, jungejason

Differential Revision: 1134
2011-11-29 16:23:14 -08:00
Chris Piro
0f35d03d29 don't stopAllLinters() for disabled error
Summary: if we don't care and don't expect it to break all other linters then
continue

Test Plan: ##arc lint --trace## on a commit with non-ascii characters, saw other
linters continue

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, cpiro

Differential Revision: 1122
2011-11-17 14:06:49 -08:00
epriestley
d57ea379c6 Fix "arc lint" exploding on new directories
Summary:
D1061 introduced a 'text file' check, but it fails under SVN for new
directories.

  - Revert D1061 (This reverts commit b2cd18252701be2093b52652fb3d1d94c5df571e.)
  - Make getChangedLines() return null to indicate that the operation doesn't
make sense. I think this was the intent of the code in the lint engine.
  - Fix a bug where running "arc lint" on a change in an SVN working copy from a
subdirectory would fail.
  - Fix a bug where warnings with no line information were incorrectly
discarded.

Test Plan:
  - Ran "arc lint" in an SVN working copy with a new directory (no failure).
  - Forced FilenameLinter to always raise a warning. Added a binary file and ran
"arc lint". The warning was reported for the new binary file, a new text file,
and a new directory.

Reviewers: jungejason, andrewjcg, nh, tuomaspelkonen, aran

Reviewed By: andrewjcg

CC: aran, andrewjcg, epriestley

Differential Revision: 1076
2011-11-03 14:28:04 -07:00
Chris Piro
c0007ffd44 support newer PyLint column numbers
Summary: newer PyLint includes commas and a column number for every message
after the line number. ignore that if it's present.

Test Plan: ##arc lint --trace --lintall## a file with messages with the old and
new pylint (2.5), works fine with both

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: 1062
2011-10-31 13:53:09 -07:00
Andrew Gallagher
b2cd182527 Show lint warnings for non-"line-able" files
Summary:
Currently, lint messages are only included if they are errors or
if they affect lines which the diff changed.  The implementation
of this caused issues for non-text files (e.g. binaries), as line
change information is not available, and the corresponding lint
messages were dropped (for non-errors).

In this diff, only lint messages concerning text files are dropped
based on this line filtering.

Test Plan: arc lint with binary file

Reviewers: jungejason, epriestley

Reviewed By: epriestley

CC: aran, aravindn, andrewjcg, liat, epriestley

Differential Revision: 1061
2011-10-28 13:49:58 -07:00
Chris Piro
311449bcf8 add lint.pylint.pythonpath option for ArcanistPyLintLinter
Summary: allow adding PYTHONPATHs directly in addition to the hardcoded few
already allowed.

Test Plan: ##arc lint## successfully picks up the paths listed in my .arcconfig,
and no longer errors on modules not found from those directories

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: 1050
2011-10-26 21:29:55 -07:00
Chris Piro
930b32a6b4 add 'lint.pylint.rcfile' option for ArcanistPyLintLinter
Summary: add the ability to specify an rcfile path either absolute or relative
to the project root.

Test Plan: added one for a project, ran ##arc lint --trace## to see the expected
result

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: 1046
2011-10-25 13:47:03 -07:00
Chris Piro
00e5ba7ddc fix bugs and documentation for ArcanistPyLintLinter
Summary:
- The top documentation is more readable, and the details about the severity
mapping regexps is moved to the top from inline -- they're important.
- array_merge() is used when appending command line args from
##lint.pylint.options## instead of '+'. The latter merges by key instead of
appending the two lists as intended.
- rely on the exit code instead of magic text that may or may not be there
depending on how ##pylint## is invoked.

These bugs were introduced in d762311a9d.

Test Plan: ##arc lint --trace##'d a bunch of Python source files in a project,
with and without PyLint messages. Added some ##lint.pylint.options## to see
proper appending behavior.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, cpiro

Differential Revision: 1045
2011-10-25 13:46:33 -07:00
epriestley
0c11b5c70c Allow XHPAST lint name rules to be overridden through configuration
Summary:
See T326. Allow lint rules to be selectively overridden, e.g. for Conduit
methods.

Since FB has a long history of suggesting crazy patches for this stuff I think
we're safer just adding a hook class than trying to do some kind of regexp
magic.

Test Plan: Wrote a hook for Phabricator and linted some Conduit files without
issues. Ran unit tests.

Reviewers: nh, jungejason, tuomaspelkonen, aran

Reviewed By: nh

CC: aran, nh

Differential Revision: 874
2011-08-31 11:54:24 -07:00
epriestley
39e4656278 Fix an obscure dependency issue in Arcanist + libphutil
Summary:
The module analyzer reads "phutil_require_module" in the source of a module as a
dependency, and tries to regenerate __init__.php if symbols from that module
aren't actually used. This creates patches which don't actually resolve the
problem, since changing __init__.php won't change the dependency.

Instead, trust that anyone using phutil_require_module in the source of a module
knows what they're doing and don't mark it as a dependency.

We currently have an issue with this in phabricator's Setup process since I load
some other libraries' modules just to test if they can be loaded

@lesha, this might be the issue you reported a while ago.

Test Plan: Ran "arc lint" on a module which pulls in another module explicitly
in the source, didn't get a no-op lint error.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran, lesha
CC: aran, epriestley, jungejason
Differential Revision: 770
2011-08-03 12:17:49 -07:00
epriestley
17c82ff03c Add an XHPAST lint rule for brace formatting
Summary: See D753. Let's just have lint fix this. Depends on D754 (it fails to
detect all the blocks without that patch, but doesn't do anything bad).
Test Plan: Ran unit tests.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran
CC: hunterbridges, aran, epriestley, jungejason
Differential Revision: 755
2011-08-02 10:14:58 -07:00
Jason Ge
b3a9ee3d84 Setting default minimumSeverity to zero from null
Summary:
In hphp's version of idx, it uses debug_rlog() which is not
available in phabricator's code. It will be executed if null is passed
as the second value to idx.

Test Plan:
ran arc lint which still report error message, and php
./scripts/arcanist.php unit src/lint/linter/xhpast/__test__ doesn't
throw.

Reviewed By: epriestley
Reviewers: tuomaspelkonen, epriestley
CC: aran, jungejason, epriestley
Differential Revision: 666
2011-07-20 11:47:17 -07:00
epriestley
8234dd8088 Provide better documentation for lint engines, linters, and the PyLint linter
Summary:
Document the relationship between lint engines and linters. Provide an example
linter. Improve the documentation of PyLintLinter, which has a bunch of
configuration stuff which you had to dig into the code to get.

Test Plan:
Ran "arc lint --engine ExampleLintEngine --lintall derp.py" on a file with a
Python syntax error in it. Read documentation.

Reviewed By: j3kuntz
Reviewers: j3kuntz, andrewjcg
CC: aran, j3kuntz
Differential Revision: 557
2011-06-29 21:53:48 -07:00
grglr
80da1354da Ignore redundant PEP8 lint rule: W293
Summary:
W293 reports a lint warning for the same problem that TXT6 reports a
lint error for.  This isn't so terrible in and of itself.

However, when you are then prompted to apply a patch to fix TXT6, lint
doesn't realize that the W293 warning was also handled, and still
prompts you about ignoring unresolved warnings.  This is misleading.

Test Plan:
> python pep8.py hasBlankLineWS.py
hasBlankLineWS.py:3:1: W293 blank line contains whitespace
> python pep8.py --ignore=W293 hasBlankLineWS.py
(no output)

Reviewed By: epriestley
Reviewers: jungejason, epriestley
CC: epriestley, aran
Differential Revision: 525
2011-06-24 17:42:07 -07:00
epriestley
7efe723ff5 Detect iterator reuse in for() and foreach() loops
Summary:
cpojer fixed a JS instance of this in D481, but we can catch it in PHP with
XHPAST. Add a lint rule to fail if nested loops use the same iterator.

Test Plan:
Ran unit test.

Reviewed By: tomo
Reviewers: aran, pad, cpojer, jungejason, tuomaspelkonen, tomo
Commenters: cpojer
CC: aran, cpojer, epriestley, tomo
Differential Revision: 489
2011-06-23 13:15:57 -07:00
epriestley
1c865c7827 Recognize "@nolint" and "@generated" in C++ files in PhutilLintEngine
Summary:
We have some "@generated" files of these types now, hit them with the text
linters

Test Plan:
Ran 'arc lint' on D444

Reviewed By: aran
Reviewers: aran
CC: aran
Differential Revision: 451
2011-06-14 20:44:40 -07:00
epriestley
65c0d07935 Add PHP lint check for expressions which can be statically evaluated
Summary:
This is pretty coarse and could be refined, but I often do this when testing:

  lang=diff
  - if (some_complicated_condition())
  + if (true || some_complicated_condition())

aran has caught me not only doing it but sending out diffs with it like 30
times. Catch it in lint instead.

Test Plan:
Unit test, added a "true || $junk" to the code and linted it.

Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen, pad
CC: aran
Differential Revision: 447
2011-06-13 10:17:43 -07:00
Lovro Puzar
4b041b8f84 Lint rule for duplicate keys in array literals
Summary:
Raise an error if an array is initialized with the same key present more than
once.

Test Plan:
bin/arc unit
Also added some duplicates to ArcanistXHPASTLinter.php and verified the output
of bin/arc lint.

Reviewed By: epriestley
Reviewers: jungejason, epriestley, aran
CC: aran, epriestley
Revert Plan:
Tags:

Differential Revision: 346
2011-05-25 16:26:33 -07:00
Andrew Gallagher
d762311a9d arc lint: add support for PyLint
Summary:
Provides a lint class as a wrapper around the external project PyLint.
This exposes some arc config variables to control the behavior:

lint.pylint.prefix - non-standard installation location of pylint
lint.pylint.logilab_astng.prefix - non-standard installation location
  of logilab-astng, a dependency of pylint
lint.pylint.logilab_common.prefix - non-standard installation location
  of logilab-common, a dependency of pylint
lint.pylint.codes.{error,warning,advice} - regexes matching against
  PyLint message codes which should trigger arc errors/warnings/advice
lint.pylint.options - options to pass PyLint

Test Plan:
used to lint python code

Reviewed By: epriestley
Reviewers: epriestley, jungejason
CC: aran, epriestley
Differential Revision: 343
2011-05-25 14:14:51 -07:00
Andrew Gallagher
f8c3a5d555 arc lint: add support for PyFlakes
Summary:
Provide a simple linter wrapper around pyflakes.  This relies on finding
pyflakes via:
- lint.pyflakes.path - arcconfig setting of absolute path to pyflakes
- lint.pyflakes.prefix - arcconfig setting of the prefix that pyflakes
  was installed under
- users path

Test Plan:
linted python code with PyFlakes warnings

Reviewed By: epriestley
Reviewers: jungejason, epriestley
Commenters: jungejason
CC: aran, epriestley, andrewjcg, jungejason
Differential Revision: 310
2011-05-19 16:48:05 -07:00
Andrew Gallagher
ce06ec00cc arc lint: fix typo in PEP8 linter
Test Plan:
linted!

Reviewed By: jungejason
Reviewers: epriestley, jungejason
CC: aran, jungejason
Differential Revision: 314
2011-05-19 13:41:18 -07:00
Andrew Gallagher
399c505f1a arc lint: fix/enable PEP8 linter
Summary:
This diff:
- Adds the PEP8 linter to the externals directory
- Changes the path for finding pep8.py
- Removes use of execx since pep8.py return an errors code
  when it finds PEP8 violations

Test Plan:
tested linting python code

Reviewed By: epriestley
Reviewers: epriestley, jungejason
CC: aran, epriestley
Differential Revision: 309
2011-05-18 16:47:23 -07:00
epriestley
3a559ddd13 'arc liberate', convenience wrapper for various libphutil operations
Summary:
The story for creating and maintaining libphutil libraries and modules
is pretty terrible right now: you need to know a bunch of secret scripts and
dark magic. Provide 'arc liberate' which endeavors to always do the right thing
and put a library in the correct state.

Test Plan:
Ran liberate on libphutil, arcanist, phabricator; created new
libphutil libraries, added classes to them, liberated everything, introduced
errors etc and liberated that stuff, nothing was obviously broken in a terrible
way..?

Reviewed By: aran
Reviewers: jungejason, tuomaspelkonen, aran
CC: aran, epriestley
Differential Revision: 269
2011-05-17 09:53:19 -07:00
epriestley
3edd525f83 Stop undeclared variable warning for $obj->{$prop} syntax
Summary:
This isn't necessarily a root-cause solution but this syntax is really really
bad. If we want to fix the root cause, I'd recommend making its use a lint
error?

Test Plan:
Unit tests failed before patch, passed afterward.

Reviewed By: aran
Reviewers: jungejason, tuomaspelkonen, aran
CC: aran
Differential Revision: 270
2011-05-11 22:06:03 -07:00
epriestley
23afdb99f0 Allow ArcanistLinter to load files not directly affected by lint
Summary:
This is necessary for the Javelin linters. The libphutil and flib linters do it
implicitly, so there's no real tradeoff here.

Test Plan:
Ran javelin linters.

Reviewed By: tuomaspelkonen
Reviewers: tomo, aran, jungejason, tuomaspelkonen
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 238
2011-05-08 01:43:49 -07:00
epriestley
8ffba323ea Stop this from failing on directories, etc.; u-u-u-u-ultra clown. 2011-04-11 16:13:22 -07:00
epriestley
c00da5bf4f Load more context for lint only if the files actually exist. 2011-04-11 14:54:17 -07:00
epriestley
2cf1393219 Load files which we don't directly examine, since there are some common cases
where we either generate an entire file or an external script examines it.
2011-04-10 16:05:44 -07:00
adonohue
0472a5ff95 Improve lint rendering
Summary:
Declare victory like it's the United States.

Test Plan:
www copyright, apache copyright, control keyword whitespace and trailing
whitespace lint warnings

Reviewed By: epriestley
Reviewers: epriestley
CC: epriestley
Differential Revision: 117
2011-04-08 19:18:34 -07:00
Aran Donohue
76c45a74f3 JSON output for Lint
Summary:
Refactor ArcanistLintRenderer into three independent classes, and let
the Workflow select between them based on its 'output' parameter.

Test Plan:
Introduce a Lint warning and lint with no --output, with --output summary and
with --output JSON.

Reviewed By: epriestley
Reviewers: epriestley
CC: aran, epriestley
Differential Revision: 96
2011-04-04 10:07:06 -07:00
epriestley
11e25f5840 Add an empty file lint test. 2011-03-22 20:51:45 -07:00
epriestley
b8e7e9017a Special case ArcanistTextLinter for completely empty files. 2011-03-22 11:09:28 -07:00
epriestley
fd19dfaebc Detect use of "+" on a string literal in PHP.
Summary:
This is realistically always wrong and the author means "."

Test Plan:
lint / unit

Reviewed By: crackerjack
Reviewers: crackerjack, aran
CC: crackerjack
Differential Revision: 68
2011-03-10 15:15:45 -08:00
epriestley
4b30319747 Make XHPAST parse-depth warning an actual warning.
Summary:
XHPAST encounters a parse-depth problem on some files because PHP
5.2 has an un-overridable parse depth limit for JSON. The text of this error
says it is a "warning" but we currently raise an error. Make it a warning
instead.

The JSON depth is 20 until PHP 5.2.3, where it becomes 128. After PHP 5.3
it defaults to 512 and is user-configurable, which will allow us to resolve
this issue in nearly all cases.

Since I made if/else express as a list in the AST, this only actually arises
in long binary chains, most commonly string concatenation, like:

  $out = 'a'.'a'.'a'.'a'...

...where each string is a variable or HTML tag and the program is constructing
a complicated document.

At some point I'll add some PHP 5.3 massaging to the XHPAST decoder itself to
raise this limit to something more huge.

Test Plan:
Ran "arc lint --lintall" on a file with a very deep binary
expression tree ("1 + 1 + 1 ...") and received a warning instead of an error.

Reviewed By: aran
Reviewers: pad, aran
CC: epriestley, aran
Differential Revision: 54
2011-03-07 11:44:11 -08:00
adonohue
cc8c7d4997 Respect @nolint
Summary:
Respect @nolint annotations

Test Plan:
New "test case"

Differential Revision: 41
Reviewed By: epriestley
Reviewers: epriestley
CC: epriestley
2011-02-26 20:54:06 -08:00
epriestley
c13147cf53 Stop arc from destroying files under HPHPi.
Summary:

Test Plan:

Reviewers:

CC:
2011-02-24 14:08:49 -08:00
epriestley
5099b005cf Some documentation.
Summary:

Test Plan:

Reviewers:

CC:
2011-02-19 11:36:08 -08:00
epriestley
ba6091f945 Add @nocommit and tests to Text linter.
Summary:

Test Plan:

Reviewers:

CC:
2011-02-16 17:26:51 -08:00
epriestley
2354d544e3 Restore hook configuration in lint unit tests. Make working copy setup an
external.

Summary:

Test Plan:

Reviewers:

CC:
2011-02-16 11:53:34 -08:00
epriestley
ca98fc175f Add lint support to 'arc svn-hook-pre-commit'.
Summary: The biggest blocker on getting rid of arc in trunk is that the lint
rules in the commit hooks are still running the old version. Push arc
commit hook support toward some reasonable state of approximately working.

Test Plan:

Reviewers:

CC:
2011-02-15 14:57:24 -08:00
epriestley
d2b5d9108b Provide coverage for the xhpast $a->b->c parsing bug exposed by tautolinting the
codebase.

Summary:

Test Plan:

Reviewers:

CC:
2011-02-13 16:43:32 -08:00
epriestley
b3b2da4608 Fix greediness in Apache License linter.
Summary: The multi-line comment regexp was potentially too greedy. See
"greedy.lint-test".
	- Made it less greedy.
	- Added test coverage.
	- Fixed an issue with the Apache license getting applied with too much
	  whitespace against C files.

Test Plan: Ran unit tests.

Reviewers: aran

CC:

Differential Revision: 36
2011-02-13 16:03:05 -08:00
adonohue
e0bc910dda Tweak license linter to support licenses on line immediately after <?php
Summary:
Tweak license linter to support licenses on line immediately after <?php

Test Plan:
Corrupt an apache license and re-lint twice.

Differential Revision: 34
Reviewed By: epriestley
Reviewers: epriestley
2011-02-11 17:51:55 -08:00
adonohue
f22d74f88d Refactor Apache license linter to parameterize the license itself.
Summary:
Refactor Apache license linter to parameterize the license itself.

Test Plan:
meta

- begin *PUBLIC* platform impact section -
Bugzilla: #
- end platform impact -

Differential Revision: 33
Reviewed By: epriestley
Reviewers: epriestley
2011-02-11 16:36:09 -08:00
epriestley
4b51720ba1 Tautological expression lint. 2011-02-06 13:04:01 -08:00
epriestley
9affcb0db2 Expose XHPAST parse tree down the line to other parsers.
Summary:

Test Plan:

Reviewers:

CC:
2011-01-28 15:18:19 -08:00
epriestley
072833dcb4 Merge branch 'master' of github.com:facebook/arcanist 2011-01-26 17:47:00 -08:00
epriestley
777c69699b Don't apply apache license lint rules if there is no copyright holder. 2011-01-26 17:46:17 -08:00
adonohue
c896d3814f [easy] remove no-op from ArcanistLinter#raiseLintAtPath
Summary:
Remove extra call to getActivePath

Test Plan:
Inspection

Differential Revision: 205579
Reviewed By: epriestley
Reviewers: epriestley
CC: epriestley
Revert Plan:
OK
2011-01-26 17:33:35 -08:00
epriestley
d933f20005 Blanket exclude 'externals/' directory from linting in the PhutilLintEngine. 2011-01-26 09:58:16 -08:00
epriestley
d46a138eb0 Don't issue lint about strangely named classes just because they have some
word character in them.
2011-01-26 07:03:52 -08:00
epriestley
210b4fe07d Include CSS and JS in PhutilLintEngine. 2011-01-25 11:32:57 -08:00
epriestley
746768e779 Enable PhutilModuleLinter to recover more gracefully from broken modules.
Summary:

Test Plan:

Reviewers:

CC:
2011-01-17 20:18:42 -08:00
adonohue
026a322dd2 Implement lint check that filename matches only declared interface/class.
Differential Revision: 201593
Reviewed By: epriestley
2011-01-14 15:30:11 -08:00
adonohue
59f48f7901 Disable phutil filename check. To be implemented as a more pervasive check.
Differential Revision: 201587
Reviewed By: epriestley
2011-01-14 15:21:39 -08:00
epriestley
3f13e36182 Update arcanist to use the PhutilSymbolLoader.
Summary: This should also fix the bug with double help for certain commands

Test Plan:

Reviewers:

CC:
2011-01-12 16:02:28 -08:00
epriestley
bb7e649fa5 Ship lint warnings to Differential.
Summary: Send skipped lint warnings to Differential. This also fixes a nasty
bug with lint excluding too many warnings based on line changes.

Test Plan: meta

Reviewers:

CC:

Differential Revision: 200387
2011-01-11 20:45:36 -08:00
epriestley
10b0a553b4 Improve phutil module linter behavior for vanished modules and missing or
broken __init__.php.

Summary: This allows phutilmodulelinter to generate missing __init__.php and
recover from missing modules without horrible fataltown.

Test Plan:

Reviewers:

CC:
2011-01-10 00:07:58 -08:00
epriestley
12f1ba1d77 Remove XHPAST from arcanist.
Summary: see corresponding commit in libphutil

Test Plan: linted and analyzed both libraries, got more sensible build behavior

Reviewers:

CC:
2011-01-09 22:13:30 -08:00
epriestley
efb8219196 Fix some problems with the module linter that would cause various conflicting
warnings raised in __init__.php to overwrite eachother in uncomfortable ways.
2011-01-09 20:40:31 -08:00
epriestley
2c235bdf38 Fix a couple of lint issues, and update to version 2 (github). 2011-01-09 15:51:04 -08:00
epriestley
2e73916fa2 Initial commit. 2011-01-09 15:22:25 -08:00