Update Rubocop for new tool support and improved parsing.

Review Request #11578 — Created April 6, 2021 and submitted — Latest diff uploaded

Information

ReviewBot
release-3.0.x

Reviewers

This updates RubocopTool to subclass the newer BaseTool, and to use
the newer features it offers (dependencies, improved file extension
handling, centralized base command building, and new comment options).

The parsing has been redone to use the Rubocop JSON output, which
constains details such as line/column ranges and error codes. It also
tells Rubocode to provide URLs to any relevant docs when reporting
errors, and forces it not to comment on filenames (which can fail
depending on the temp filename that's created).

If we're unable to parse the JSON payload, we split the lines and use
the first line as an error. This seems to be the most reliable option,
as subsequent lines can end up with stack traces or "successful" JSON
payloads.

Unit tests pass on Python 2.7 and 3.x.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

orig
1
2

Commits

First Last Summary ID Author
Update Rubocop for new tool support and improved parsing.
This updates `RubocopTool` to subclass the newer `BaseTool`, and to use the newer features it offers (dependencies, improved file extension handling, centralized base command building, and new comment options). The parsing has been redone to use the Rubocop JSON output, which constains details such as line/column ranges and error codes. It also tells Rubocode to provide URLs to any relevant docs when reporting errors, and forces it not to comment on filenames (which can fail depending on the temp filename that's created). If we're unable to parse the JSON payload, we split the lines and use the first line as an error. This seems to be the most reliable option, as subsequent lines can end up with stack traces or "successful" JSON payloads.
acc8f173ea5d2e9194315cba3a5e7ad8f38e5865 Christian Hammond
bot/reviewbot/tools/rubocop.py
bot/reviewbot/tools/tests/test_rubocop.py
Loading...