During process_line each line is loaded into JSON. As it stands it is possible
to attempt loads on lines containing single backslashes. This will fail the
load as these characters are invalid in JSON. This is particularly noticeable on
Windows, where all paths will contain these characters.
This changeset escapes any back slashes in the lines. It also adds logging to
the error case for the JSON loading, so failures aren't silently swallowed.
***
Fix issues brought up in review, silly mistakes in last changeset.
- Update log message upon encountering non JSON linter output that cannot be
handled by json.loads.
- Correct typo: formate -> format.
- Correct replace string. Was using r'\\\\', which will evaluate to 3 slashes,
now using '\\\\', which evaluates to 2. Opting not to use a raw string here
because of the confusion over the final backslash interaction (final one still
needs to be escaped even in a raw string).
MozReview-Commit-ID: Hfa0jSdnege
--HG--
extra : rebase_source : bd29d2437cf61f01df6d01a70ed651b49e33656e
This fixes a regression from bug 1258341 where the eslint binary no longer
gets run from a shell on msys. Without this, a WindowsError [Error 139] is
thrown.
MozReview-Commit-ID: FQ3LhTzd8nL
--HG--
extra : rebase_source : 33490fd9e41a2691f0b0c815916185fcf8936987
This does 3 things:
1) Moves all the long descriptions for the rules into the main index.rst
document. This just makes it simpler, and there didn't seem to be much
point in having a separate document for each rule.
2) Moves index.rst to tools/lint/docs/eslint-plugin-mozilla.rst
3) Creates a new eslint.rst landing page, and includes it.
MozReview-Commit-ID: 1e3QBkMFOBe
--HG--
rename : tools/lint/eslint/eslint-plugin-mozilla/docs/index.rst => tools/lint/docs/linters/eslint-plugin-mozilla.rst
extra : rebase_source : ab2c5c89bfa77da994f20fbecffed25e9f475ce8
This integrates 'eslint' with the mozlint framework. The old |mach eslint| command is kept around
for backwards compatibility and will simply dispatch to |mach lint|. But |mach lint| should be
preferred as the old command may eventually be removed.
The old |mach eslint| command should be mostly backwards compatible with a few exceptions:
1. Can no longer define --extensions on the command line, this is instead hardcoded into
eslint.lint.
2. No longer using eslint formatters. However, the default mozlint formatter should be
identical to the default eslint formatter, so developers should not notice a change.
This does mean that non-default eslint formatters can no longer be used unless a mozlint
copy of them is created.
3. Installs dependencies automatically without prompting the user. This was necessary due to
python multiprocessing limitations, but is actually also a better UX. Because the npm
dependencies aren't global anymore, there isn't really any reason *not* to install them
automatically.
Apart from that, any difference from the old |mach eslint| I'd consider a bug.
The main eslint implementation now lives in tools/lint/eslint.lint instead of
tools/lint/mach_commands.py.
MozReview-Commit-ID: KYhC6SEySC3
--HG--
extra : rebase_source : 36d06b1a3fced764e17154cc53091d7722919b67
This change avoids lots of false positives for Coverity's CHECKED_RETURN
warning, caused by NS_WARN_IF's current use in both statement-style and
expression-style.
In the case where the code within the NS_WARN_IF has side-effects, I made the
following change.
> NS_WARN_IF(NS_FAILED(FunctionWithSideEffects()));
> -->
> Unused << NS_WARN_IF(NS_FAILED(FunctionWithSideEffects()));
In the case where the code within the NS_WARN_IF lacks side-effects, I made the
following change.
> NS_WARN_IF(!condWithoutSideEffects);
> -->
> NS_WARNING_ASSERTION(condWithoutSideEffects, "msg");
This has two improvements.
- The condition is not evaluated in non-debug builds.
- The sense of the condition is inverted to the familiar "this condition should
be true" sense used in assertions.
A common variation on the side-effect-free case is the following.
> nsresult rv = Fn();
> NS_WARN_IF_(NS_FAILED(rv));
> -->
> DebugOnly<nsresult rv> = Fn();
> NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Fn failed");
--HG--
extra : rebase_source : 58788245021096efa8372a9dc1d597a611d45611
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
The patch is generated from following command:
rgrep -l unused.h|xargs sed -i -e s,mozilla/unused.h,mozilla/Unused.h,
MozReview-Commit-ID: AtLcWApZfES
--HG--
rename : mfbt/unused.h => mfbt/Unused.h
This fixes a bug in flake8, where if you pass in --exclude to a path with a custom .flake8 file, that
configuration will be ignored. I'm not sure why this happens.
Prior to this commit series, the 'exclude' paths weren't being passed on to the flake8 linter properly.
This is why the problems hasn't surfaced until now. This is a band-aid fix until a proper (likely
upstream) fix can be landed.
MozReview-Commit-ID: KYhC6SEySC3
--HG--
extra : rebase_source : 0dbf30dcb17c37787c2ddebbb3c7de5f3b63860b
Replace old flags in WrapForJNI usages with new flags. The calledFrom
and dispatchTo flags are set based on whether the method is native or
non-native, and how the method is used.
Also fix testEventDipatcher to respect NativeJSObject's calledFrom =
"gekco" flag, by moving a test to Gecko thread.
This patch makes the following changes on many in-class methods.
- NS_IMETHODIMP F() override; --> NS_IMETHOD F() override;
- NS_IMETHODIMP F() override {...} --> NS_IMETHOD F() override {...}
- NS_IMETHODIMP F() final; --> NS_IMETHOD F() final;
- NS_IMETHODIMP F() final {...} --> NS_IMETHOD F() final {...}
Using NS_IMETHOD is the preferred way of marking in-class virtual methods.
Although these transformations add an explicit |virtual|, they are safe --
there's an implicit |virtual| anyway because |override| and |final| only work
with virtual methods.
--HG--
extra : rebase_source : 386ee4e4ea2ecd8d5001efabc3ac87b4d6c0659f
This patch makes most Run() declarations in subclasses of nsIRunnable have the
same form: |NS_IMETHOD Run() override|.
As a result of these changes, I had to add |override| to a couple of other
functions to satisfy clang's -Winconsistent-missing-override warning.
--HG--
extra : rebase_source : 815d0018b0b13329bb5698c410f500dddcc3ee12