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

40 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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