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

92 commits

Author SHA1 Message Date
Nick Harper
e462f2e84e [arcanist] respect severity disabled in PEP8 linter
Summary:
This allows for disabling certain PEP8 linter errors by calling
setCustomSeverityMap on an ArcanistPEP8Linter. However, any custom severities
besides disabled will be ignored.

Test Plan: arc lint

Reviewers: epriestley, andrewjcg

Reviewed By: epriestley

CC: jungejason, aran, epriestley

Differential Revision: https://secure.phabricator.com/D1839
2012-03-09 11:19:17 -08:00
epriestley
fba87a5b6a Fix implicit fallthrough in arc
Summary: Raised by new linter.

Test Plan: Lint/inspection.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1831
2012-03-09 08:57:03 -08:00
epriestley
8088b4cdac Improve performance of XHPASTLinter
Summary:
  - XHPASTLinter + coverage is ass-slow.
  - Use caching/perf options introduced by D1828.

Test Plan:
  - Ran profiling for unit tests with new --xprofile command line flag.
  - Old profile: https://secure.phabricator.com/xhprof/profile/PHID-FILE-uiuwsqa5wulj7eyfkjy2/
  - New profile: https://secure.phabricator.com/xhprof/profile/PHID-FILE-nl635t3jcp2sfo2spzwu/
  - Overall runtime decreased from 18.2s to 3.7s (4.9x performance increase) with coverage enabled.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1829
2012-03-08 12:20:46 -08:00
epriestley
465ad3fa44 Add a lint warning for implicit fallthrough in switch statements
Summary: If a case does not end with break, continue, throw, exit or return and does not have a "fallthrough" comment, raise a warning.

Test Plan: Ran test case; ran linter against all of Phabricator (no hits).

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1824
2012-03-08 12:20:19 -08:00
epriestley
49b83927b8 When a file doesn't begin "<?php", raise one warning, not one for each line
Summary: Linter flipped out on D1817; reign it in.

Test Plan: Ran "arc lint" on D1817, got one message.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1818
2012-03-07 17:52:46 -08:00
epriestley
b3a70ac206 Use string operations, not idx(), for string indexing.
Summary: Missed this in review (D1715), idx() does not operate on strings (maybe
it does in HPHP/i?).

Test Plan: Faked an editable lint warning, ran "arc lint".

Reviewers: Koolvin, andrewjcg, btrahan

Reviewed By: Koolvin

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1728
2012-02-29 08:39:25 -08:00
Andrew Gallagher
bd3ce3631a Patch rendering fixes
Summary:
Not too familiar with the patch rendering code, but diff should fix
a few issues:
1) The current didn't seem to handle the case of an insertion only
diff (where the original text is empty).  Specifically, it would
still print a replacement line and would merge the line immediately
after the patch location into the patch application.
2) Patches with trailing newlines were rendered with an additional
newline.  This appears to be due to using ##explode## to break the
patch into lines.

Test Plan:
1) Verified that this fixed apache license linting for files that had
no license.
2) Checked that this didn't affect trailing-whitespace patch application.

Reviewers: epriestley, aran

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1715
2012-02-27 21:39:12 -08:00
vrana
e8ca66ead4 Allow arc lint --output json --apply-patches
Summary:
I want to use JSON which allows me to automatically open the files in editor.
I also want to apply patches, especially those modifying __init__.php.
I see no reason why these options should be mutually exclusive.

Also output nothing for okay result which is more standard and better parsable.

Test Plan:
arc lint --output json
arc lint --output json --never-apply-patches # same as above
arc lint --output json --apply-patches

Reviewers: aran, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1599
2012-02-11 08:49:01 -08:00
vrana
35837a39d2 Use readable path in lint messages
Summary:
Some linters return absolute path.
It causes separate lint messages for the same file.
Also lint messages aren't properly bound in Phabricator.

I've preferred changing addLintMessage() to fixing all linters because it is
more robust.

Test Plan: arc lint of a file with lint problem from linter using absolute paths

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1589
2012-02-07 10:22:50 -08:00
epriestley
4f07c3c8fd Add coverage support to Arcanist
Summary:
Add "--coverage" and "--no-coverage" flags, mechanisms for reporting
coverage information, xdebug coverage support, and CLI coverage reports.

Test Plan: Ran coverage locally.

Reviewers: tuomaspelkonen, btrahan, jungejason

Reviewed By: btrahan

CC: zeeg, aran, epriestley

Maniphest Tasks: T140

Differential Revision: https://secure.phabricator.com/D1526
2012-01-31 12:07:19 -08:00
epriestley
8fe38f8b6d Finalize Arcanist Classes
Summary:
Mark all applicable Arcanist classes as "final", except PhutilLintEngine, which
needs a little finesse.

@jungejason / @nh, does this break any Facebook stuff?

Test Plan: Linter no longer raises warnings. Ran "testEverythingImplemented" in
Phabricator.

Reviewers: btrahan, jungejason, nh

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T795

Differential Revision: https://secure.phabricator.com/D1519
2012-01-31 12:07:05 -08:00
epriestley
f70afcd705 Raise a lint warning for classes not marked "abstract", "final" or
"@concrete-extensible"

Summary:
See T795. I think ~all classes in the classtree should be "abstract" or "final",
but I provided "@concrete-extensible" if you really have "Rectangle extends
Square extends Shape" or something.

I'm not totally sure this should be enabled globally by default, maybe I should
default it to DISABLED and then enable it for libphutil/arcanist/Phabricator? It
feels like it might be a little overbearing to push on everyone by defualt.

Test Plan: See unit tests.

Reviewers: btrahan, aran, nh, arudolph, jungejason

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T795

Differential Revision: https://secure.phabricator.com/D1510
2012-01-28 11:29:30 -08:00
epriestley
0781554a22 Improve Arcanist symbol name linter
Summary:
  - Move name helper functions to ArcanistXHPASTLintNamingHook to make it easier
to write custom linters.
  - Add test coverage for name functions.
  - Add 'variable' and 'global' naming convention tests.
  - Expand test cases.
  - Improve lint message error when an unexpected message is raised during a
test.
  - Remove a defunct XHP lint message.

Test Plan:
  - Ran unit tests.
  - Ran "arc lint --lintall" on arcanist/.

Reviewers: btrahan, nh, jungejason

Reviewed By: btrahan

CC: johnduhart, aran, epriestley, arudolph

Differential Revision: https://secure.phabricator.com/D1506
2012-01-28 11:17:45 -08:00
John Du Hart
08a1219d11 Split ArcanistXHPASTLinter::LINT_FORMATTING_CONVENTIONS into seperate lint names
Summary:
Split ArcanistXHPASTLinter::LINT_FORMATTING_CONVENTIONS into seperate
lint names so that each linting rule can be controled sperately

Test Plan:
This shouldn't break anything, if it does we'll know soon enough.
<epriestley> Better things break loudly/obviously I think.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1495
2012-01-25 19:06:01 -08:00
adonohue
2c4eb00a12 Add ArcanistConduitLinter, a linter that delegates through Conduit
Summary:
Julien built a really cool static analysis database of our codebase. One
capability is that it can suggest typehints that are not in the code. The
analysis to do this is very expensive, so it can't reasonably be run locally.
But it can remain indexed on a server.

The idea here is to provide a familiar interface to it through arc lint, via a
generic Conduit service call.

In our lint engine, this will probably be gated on --advice for performance.
This will introduce a slight awkwardness in that running with --advice can add
new non-advice lint if the server chooses, but this isn't likely to cause a
practical problem.

Test Plan:
Construct a fake Conduit lint endpoint, attach this linter to it, and see bogus
lint
appear with --advice.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D1462
2012-01-20 11:17:12 -08:00
Evan Priestley
3299f1fc73 Merge pull request #16 from disqus/improve-pep8-linter
Improve PEP8 Linter
2012-01-19 21:07:19 -08:00
David Cramer
2fa80bbd44 Add canRun to linters.
Summary:
This allows engines to check the canRun method on linters,
which should determine if a linter is configured and can
be run in the current environment.

Test Plan:
Implement a linter with canRun as false, and ensure
it doesnt run.

Ensure all existing linters still run by default.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D1445
2012-01-17 17:15:21 -08:00
David Cramer
06334a69b4 Improve PEP8 Linter
Summary:
This cleans up the PEP8 linter to bring it inline
with the new JSHint Linter's level of quality.

It adds a getPEP8Path method which gives the ability
for users to override the pep8 binary with two new
options in .arcconfig:

* lint.pep8.prefix
* lint.pep8.bin
* lint.pep8.options

Test Plan:
Adjust your engine to use the 'ArcanistPEP8Linter' and run
arc lint against Python files.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D1440
2012-01-17 15:39:52 -08:00
David Cramer
5cd2eec6f1 Implement Comprehensive Lint Engine
Summary:
This adds a new lint engine, ComprehensiveLintEngine, which
includes sane defaults for some generic languages.

Ideally this would include *all* available language linters,
but that can be enhanced at a later point. Right now it's mostly
the base linter with additional JavaScript and Python linters.

Test Plan:
Adjust the lint_engine to be "ComprehensiveLinterEngine". You'll
also need jshint, pyflakes, and pep8 to all be available on PATH.

Run arc lint against files which contain .php, .py, and .js.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D1439
2012-01-17 12:46:06 -08:00
Jack Lindamood
c5dfa34f10 Add spell check linter
Summary:
Inspired by http://news.ycombinator.com/item?id=3464671 and a lot of
diffs I've seen @ FB, I've added a spell checking linter.  To reduce
false positives, it's only a blacklist.  Still, it catches a large
number of 'issues'.

Test Plan:
Unit tests.  Ran on FB's codebase.  No false positives
noticed but a lot of cases caught.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, jack

Differential Revision: https://secure.phabricator.com/D1409
2012-01-16 05:46:26 -08:00
Anton Kovalyov
e5bda05200 Adds ArcanistJSHintLinter to check JS files for errors and potential problems.
This patch adds ArcanistJSHintLinter class and three new .arcconfig options:

 * lint.jshint.prefix - directory where JSHint binary resides
 * lint.jshint.bin - JSHint binary name (if different from 'jshint')
 * lint.jshint.config - a JSON file with JSHint project-wide options

By default, this linter assumes that JSHint is installed on user's system
as an NPM package.

Test Plan:

(1)

Run `npm install jshint -g` to install JSHint and add
ArcanistJSHintLinter to your Lint Engine (I didn't see PEP8 or
PyFlakes in the PhutilLintEngine so I decided to not to put
JSHint in there). After that you can do `arc lint my.js`.

(2)

Create a new file, config.json, and add `{ "white": true }` in it.
Add `"lint.jshint.config": "/path/to/config.json"` to your .arcconfig and
run `arc lint my.js`. After that, unless your name is Douglas Crockford,
you'll see tons of JSHint warnings about minor PEP8-like things (spacing, etc.)
2012-01-13 19:17:34 -08:00
Kiyoto Tamura
6dfa45a8b3 Stop XHPASTLinter from eating a newline after else
Summary:
If the else clause does not have braces (one-liner), XHPASTLinter eats the
newline and brings the body statement of the else clause to the same line.

Test Plan: added a new test to space-after-control-keywords.lint-test

Reviewers: epriestley

CC: aran, epriestley, kiyoto

Differential Revision: https://secure.phabricator.com/D1367
2012-01-11 18:03:56 -08:00
epriestley
f3eccfbe81 Unify arguments for 'arc lint', 'arc unit'
Summary: See T645. These commands take inconsistent and overly-magical arguments
right now. Instead, make them behave consistently and allow them both to operate
on "arc <workflow> path path2 path3 ...", which is a generally useful workflow.

Test Plan: Ran "arc lint <path>", "arc unit <path>", "arc lint --rev
HEAD^^^^^^", "arc unit --rev HEAD^^^^^^^^^^^^", etc. Ran "arc diff --trace" and
verified --rev argument to child workflows.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, epriestley, btrahan

Maniphest Tasks: T645

Differential Revision: https://secure.phabricator.com/D1348
2012-01-10 10:42:22 -08:00
epriestley
6f27c9e693 Remove all XHP lint tests from Arcanist
Summary:
  - Remove XHP tests so I can remove XHP support from XHPAST.
  - Update license tests so they don't break every year.

Test Plan:   - Ran all unit tests.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, pad, jungejason, btrahan

Maniphest Tasks: T635

Differential Revision: https://secure.phabricator.com/D1318
2012-01-05 12:58:59 -08:00
epriestley
9cdaa6dc7a Make XHPASTLinter correct too little space before opening braces
Summary: Previously, we would not correct missing space before "{".

Test Plan: Ran unit tests.

Reviewers: btrahan, jungejason, kiyoto

Reviewed By: jungejason

CC: aran, jungejason

Differential Revision: https://secure.phabricator.com/D1313
2012-01-04 14:14:47 -08:00
epriestley
6b22184712 Make XHPAST linter correct too much space after control keywords like "if"
Summary: Previously, we would not correct excessive space after "if", etc.

Test Plan: Ran test case.

Reviewers: btrahan, jungejason, kiyoto

Reviewed By: jungejason

CC: aran, jungejason, epriestley

Differential Revision: https://secure.phabricator.com/D1311
2012-01-04 14:14:40 -08:00
Kunal Bhalla
62e527482b [arc svn-hook-pre-commit] Access working copy
Summary:
Creates a new hook API that can be used to interface with
SVN/Git/Mercurial in the context of a commit hook. Currently only adds a
function to read the modified file data in a Subversion commit hook.

An object of this API is created in the SvnHookPreCommitWorkflow and
passed on the Lint Engine which then uses it to access current file
data, of the way the APIs seem to be structured); linters use the
getData function which is essentially a wrapper around the engine's
call, with another layer of caching.

Task ID: #770556

Blame Rev:

Test Plan:
- Create a local svn repository and add a minimal hook to run the local
  version of arc to test commits

(http://phabricator.com/docs/arcanist/article/Installing_Arcanist_SVN_Hooks.html)
- Create a temporary repository that can trigger any of the linters
  available, and test against a temporary linter by committing against
  the test repository: the linter should be able to access all required
  files by using loadData/getData in the LintEngine and Linter.

Revert Plan:

Tags: lint, svn-hook-pre-commit

Reviewers: jungejason, asukhachev, epriestley, aran

Reviewed By: epriestley

CC: aran, jungejason, epriestley, kunalb, asukhachev

Differential Revision: https://secure.phabricator.com/D1256
2011-12-29 14:28:50 -08:00
Jakub Vrana
7af16f42cd Replace preg_quote() lint error by warning
Summary: See http://php.net/regexp.reference.delimiters

Test Plan: arc lint on a file with preg_quote() with one parameter

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, vrana

Differential Revision: https://secure.phabricator.com/D1163
2011-12-28 13:09:42 -08:00
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