Commit Graph

28 Commits

Author SHA1 Message Date
James Graham
bba975bca2 Bug 1302796 - Add integration between structured logging and lints, r=ahal
MozReview-Commit-ID: K3tu0Zdg5go

--HG--
extra : rebase_source : 2b78059908c3a297b8ce7d134af20733fc082df5
2016-09-13 14:18:41 +01:00
Andrew Halberstadt
98a0fd6336 Bug 1302172 - [mozlint] Convert unittest tests to use pytest instead, r=maja_zf
MozReview-Commit-ID: D4bN62QbkKm

--HG--
extra : rebase_source : 22ffe05ca78095fc469520b9f85d93585251cd1c
2016-09-09 16:20:09 -04:00
Andrew Halberstadt
0f35e014fa Bug 1300779 - [mozlint] Redirect stderr when detecting version control root, r=smacleod
This avoids printing harmless (but confusing) errors to the log. For instance, git users
will see a '.hg not found!' error in the output even though not finding an hg repo is
expected in that case.

MozReview-Commit-ID: DBPOabcV7PA

--HG--
extra : rebase_source : a40de185cd4bf0c58917065d1331e0e663b92b94
2016-09-06 10:36:45 -04:00
Andrew Halberstadt
1ec1f86a90 Bug 1299618 - [mozlint] Encode results to utf-8 before printing to stdout, r=smacleod
MozReview-Commit-ID: 93RAqIRKAHc

--HG--
extra : rebase_source : d1973e52e72baab13ba9c8f1b07df5a7ddda7d49
2016-08-31 17:18:52 -04:00
Mike Hommey
411867285a Bug 1299661 - Use hg --template flag instead of -T. r=gps
Versions of mercurial older than 3.0 don't support the -T shorthand for
the --template option. While most people should be using something
newer, it can still happen that some run an older version, and it's
still trivial to support them by using the long option.

--HG--
extra : rebase_source : 1507aea436779495045df48b044a58f4af1382be
2016-09-01 07:43:38 +09:00
Andrew Halberstadt
c88eb083d8 Bug 1258341 - [mozlint] Add ability to forward miscellaneous command line arguments to the underlying linter, r=smacleod
This is mostly to maintain backwards compatibility with the |mach eslint| command. But it's also going to be used in
automation. The 'mozlint-eslint' task will need to pass in --quiet to eslint.

Maybe in the future we should remove this ability and only allow well-defined arguments in mozlint. But for now it's
convenient and allows us to land the eslint->mozlint patch series quicker.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : ad7f0cdeb57ed8a99becb90d761d73ef45ce853a
2016-08-25 09:52:50 -04:00
Andrew Halberstadt
ae1bcceeda Bug 1297699 - Mozlint tests should run with test directory as the "project root", r=smacleod
MozReview-Commit-ID: 9sbhlc11YF5

--HG--
extra : rebase_source : dee2bc4820374ca833f8351de72743f8d5a95aec
2016-08-24 09:55:04 -04:00
Andrew Halberstadt
ed73940aa9 Bug 1288425 - Make sure we skip invalid extensions when linting with --rev or --workdir, r=smacleod
Some linters, such as flake8, will lint invalid file extensions if you explicitly pass them in. E.g,
|flake8 foobar.js| will result in flake8 attempting to lint a JS file. This is a problem because passing
in files explicitly is exactly what the --rev/--workdir options do. If a developer modifies a JS file
then runs |mach lint -l flake8 -w|, that JS file will get linted.

To prevent this, mozlint needs to handle file extensions instead of relying on the underlying linter to
do it. This patch adds an "extensions" config option to the LINTER dict, and will filter these files out
as part of the 'filterpaths' steps.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 6fea2942b2db1bea7deca1d6738546362b6ebd65
2016-08-09 16:24:04 -04:00
Andrew Halberstadt
797aa910b7 Bug 1294802 - Improve color handling in mozlint stylish formatter, r=jgraham
This will make specifying terminal colours cleaner and provide fallbacks for terminals
with only 8 colours. It also tweaks the 'grey' color to match an update to the eslint
stylish formatter.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 8d3242edc54bf6505aa2e60cdb08cb0dd9743dd3
2016-07-19 11:54:04 -04:00
Andrew Halberstadt
8c3bcff5a6 Bug 1289805 - Properly normalize all paths so they are absolute, r=smacleod
It's important to use absolute paths so lint errors for the same files don't show up in two
different places. For example, eslint will absolutize a relative path, whereas flake8 will
not.

This patch also makes sure all include/exclude paths are joined to the mozlint 'root' that
was previously calculated from vcs.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 9b88ee70a997d3f7b6cc0eb849e47931d5726f20
2016-07-19 13:09:38 -04:00
Andrew Halberstadt
560ce6a254 Bug 1289805 - Resolve vcs arguments directly in LintRoller class, r=smacleod
Previously, vcs related stuff was resolved in the cli.py module. But it's possible
for consumers to bypass the cli and instantiate a LintRoller directly. In fact this
is what the mozlint tests do.

Now that we always try to find the vcs root, calling into vcs is no longer optional.
This patch moves the VCSFiles class to a new vcs.py module and makes LintRoller
responsible for instantiating it instead of cli.py.

MozReview-Commit-ID: 5yA3gDZ1UGM

--HG--
extra : rebase_source : 96adc0ca01e8220b0432b64c96c478fc526db756
extra : source : 709c1e521ad3eb466c3434000aed7f71ebf37365
2016-08-10 10:21:43 -04:00
Andrew Halberstadt
ce3f82ffbe Bug 1289805 - Ensure the VCSFiles class returns paths that have been absolutized to the repository root, r=smacleod
This makes sure we return absolute paths from the VCSFiles class. This is done so we don't accidentally normalize
the relative paths onto $CWD in the event the relative path is valid in both places.

MozReview-Commit-ID: 2QIuR2YqFos

--HG--
extra : rebase_source : 2e82b4a5cf9a18856bbcb8d04fdc916ff7e72deb
2016-08-09 14:49:41 -04:00
Andrew Halberstadt
64bfc88f52 Bug 1289805 - Refactor filterpaths to accept all lintargs, r=smacleod
This makes it easier to pass configuration to the filterpaths method. In
the future, 'root' and 'extensions' will both be used here.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 19ddf511ebd24a1a6c21f7c06b67ab64e78e7903
2016-08-09 15:29:49 -04:00
Iris Hsiao
bb2d612158 Backed out changeset 2141360b4137 (bug 1288425) for build bustage 2016-07-27 10:59:10 +08:00
Andrew Halberstadt
18f9c226a5 Bug 1288425 - Make sure we skip invalid extensions when linting with --rev or --workdir, r=smacleod
Some linters, such as flake8, will lint invalid file extensions if you explicitly pass them in. E.g,
|flake8 foobar.js| will result in flake8 attempting to lint a JS file. This is a problem because passing
in files explicitly is exactly what the --rev/--workdir options do. If a developer modifies a JS file
then runs |mach lint -l flake8 -w|, that JS file will get linted.

To prevent this, mozlint needs to handle file extensions instead of relying on the underlying linter to
do it. This patch adds an "extensions" config option to the LINTER dict, and will filter these files out
as part of the 'filterpaths' steps.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 46807a4913660f33e691b864c2c59c448902dfa5
2016-07-19 13:50:25 -04:00
Tom Tromey
5538d692d3 Bug 1286877 - do not set c-basic-offset for python-mode; r=gps
This removes the unnecessary setting of c-basic-offset from all
python-mode files.

This was automatically generated using

    perl -pi -e 's/; *c-basic-offset: *[0-9]+//'

... on the affected files.

The bulk of these files are moz.build files but there a few others as
well.

MozReview-Commit-ID: 2pPf3DEiZqx

--HG--
extra : rebase_source : 0a7dcac80b924174a2c429b093791148ea6ac204
2016-07-14 10:16:42 -06:00
Andrew Halberstadt
d5b1ff9f2e Bug 1287834 - [mozlint] Fix regression preventing specific linters from being run, r=smacleod
MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : bce3e321f407b89d65f1491be74384c0ae171431
2016-07-19 11:50:33 -04:00
Andrew Halberstadt
3c8be23f37 Bug 1281899 - [mozlint] Add ability to lint files touched by revisions and/or the working directory, r=smacleod
This adds two parameters, --rev and --workdir. Each works both with mercurial and git (though the syntax for
specifying revisions is different between them). The value is simply forwarded to either |hg log| or |git diff|
so syntax like |mach lint -r .~4::.| or |mach lint -r "HEAD~4 HEAD"| will work as expected.

MozReview-Commit-ID: aOGp2Yrncs

--HG--
extra : rebase_source : d2cb834d4cc1a083171a3551af4e72c8a7d14021
2016-06-24 14:09:58 -04:00
Andrew Halberstadt
482f8a956c Bug 1281899 - [mozlint] Create cli module and move logic from tools/lint/mach_commands.py there, r=smacleod
There is currently no built-in user interface to mozlint. The only existing interface is the
external cli provided by |mach lint|. However, in the future mozlint may need to be used in a
context where mach isn't readily available (i.e version-control-tools). This patch basically
just moves the cli logic out of mach_commands.py, and into mozlint core. That way it can be
re-used in other places without needing to be re-implemented.

The |mach lint setup| subcommand was removed because apparently subcommands don't work with
the parser attribute. Nothing was using it yet anyway, so I removed it for now. It may get
re-added in some form in the future.

MozReview-Commit-ID: aOGp2Yrncs

--HG--
extra : rebase_source : 8f7530de96e5c131d2ed5bfcdd7a159329401e5b
2016-06-24 14:06:22 -04:00
James Graham
3ca7bb37ed Bug 1279811 - Make output of column number optional in mozlint, r=ahal
MozReview-Commit-ID: 7eGTJKPMMAc
2016-06-23 10:36:47 +01:00
Andrew Halberstadt
13a551f7f9 Bug 1277641 - [mozlint] Add --no-filter option to make experimenting locally easier, r=smacleod
This makes it easier to lint a path that otherwise wouldn't have been linted due to the include/exclude
directives. Now, you can pass in -n/--no-filter instead of needing to modify the linter configuration file.

MozReview-Commit-ID: GMJuE2C1NyY

--HG--
extra : rebase_source : 03627e930f76903ad629cb01b58c4ae7372e4bb1
2016-06-02 15:14:07 -04:00
Andrew Halberstadt
031698ae90 Bug 1273634 - [mozlint] Add a treeherder formatter, r=jgraham
This is a really simple and ugly formatter that is compatible with
treeherder's error highlighting mechanism. It is designed to be identical
to the current eslint output on treeherder:
https://dxr.mozilla.org/mozilla-central/rev/4d63dde701b47b8661ab7990f197b6b60e543839/tools/lint/eslint-formatter.js

Eventually eslint will also use this and we can remove that file. Once
bug 1276486 is fixed, we can make this look a little nicer. But for now
it gets the job done.

MozReview-Commit-ID: CwfWPcwWFxF

--HG--
extra : transplant_source : %F3PJ%CB%27%A5%82U%D2%CF%B3%9E%A7%9F%0F%A4%F4%E9%5D%BB
2016-05-28 23:38:30 -04:00
Carsten "Tomcat" Book
c30c6ba10e Backed out changeset c48f3b04c9de (bug 1273634) 2016-06-02 15:05:01 +02:00
Andrew Halberstadt
df97806e5f Bug 1273634 - [mozlint] Add a treeherder formatter, r=jgraham
This is a really simple and ugly formatter that is compatible with
treeherder's error highlighting mechanism. It is designed to be identical
to the current eslint output on treeherder:
https://dxr.mozilla.org/mozilla-central/rev/4d63dde701b47b8661ab7990f197b6b60e543839/tools/lint/eslint-formatter.js

Eventually eslint will also use this and we can remove that file. Once
bug 1276486 is fixed, we can make this look a little nicer. But for now
it gets the job done.

MozReview-Commit-ID: CwfWPcwWFxF

--HG--
extra : rebase_source : 8dd39aefec1064e0836c847c6d223db43df4755b
2016-05-28 23:38:30 -04:00
Andrew Halberstadt
464b3a9f2e Bug 1273556 - [mozlint] Better SIGINT handling, return partial results on Ctrl-C, r=jgraham
Currently a bug in python (https://bugs.python.org/issue8296) is preventing a KeyboardInterrupt from
reaching the parent process, meaning we can't kill the process with SIGINT. There is a workaround to
this bug, but instead I decided to ignore SIGINT in the parent process completely. Now, each child
process is responsible for handling SIGINT on its own. Since child processes should all shutdown
relatively quickly anyway, this effectively also ends the parent process.

The benefit of doing it this way is that each child process can return the results they have collected
to date. So when a developer hits Ctrl-C, they'll still see some (but not all) formatted lint output.
The downside is that a poorly implemented external linter could block the parent process from exiting
quickly, but if this happens we should just fix the linter.

MozReview-Commit-ID: 2tRJgtmoPYP

--HG--
extra : rebase_source : e72282bcc29c9b22690168dc973a817236cdf8ca
2016-05-17 12:24:42 -04:00
Andrew Halberstadt
b1445349ea Bug 1270506 - [mozlint] Add python flake8 linter, r=smacleod
For now, only the following two directories will be linted:
python/mozlint
tools/lint

New directories can be added by adding them to the 'include'
directive in tools/lint/flake8.lint. They all default to the
configuration specified in topsrcdir/.flake8. Subdirectories
can override this configuration by creating their own .flake8
file.

MozReview-Commit-ID: Eag48Lnkp3l

--HG--
extra : rebase_source : 6d98c9fef80055a48cc2622848aa04c3045b747e
2016-05-05 17:21:12 -04:00
Andrew Halberstadt
5f616862e3 Bug 1270506 - [mozlint] Refactor the include/exclude path filtering algorithm, r=smacleod
The current algorithm for filtering down tests is too naive. For example, given the following
directory structured:

parent
  - foo
    - bar
    - baz

And the following include/exclude directives:
include = ['foo']
exclude = ['foo/bar']

Then running ./mach lint parent and ./mach lint foo/baz should both lint all files in baz but
no files in bar. This provides a nice way to include/exclude directories, while allowing the
underlying linters to find appropriate files to lint *within* those directories.

tl;dr - Straight file paths (no globs) will be passed straight to the underlying linter as is.
While paths with globs will first be resolved to a list of matching file paths.

MozReview-Commit-ID: Eag48Lnkp3l

--HG--
extra : rebase_source : 18ce2231bc4198b1e811d39f9803f0d5e03d982e
2016-05-05 17:20:33 -04:00
Andrew Halberstadt
bb96d51342 Bug 1230962 - Add python/mozlint for running several linters at once, r=smacleod
Mozlint provides two main benefits:
1. A common system for defining lints across multiple languages
2. A common interface and result format for running them

This commit only adds the core library, it does not add any consumers of mozlint just yet.

MozReview-Commit-ID: CSQzq5del5k

--HG--
extra : rebase_source : b520b96177281a1b1770edf53a01cbc2196f494f
2016-03-16 14:55:21 -04:00