Page MenuHomePhabricator

Implement setOriginalText() and setReplacementText() in RuboCop driver
Open, Needs TriagePublic


According to Q339, arc lint patches don't work with RuboCop because the RuboCop driver doesn't implement it:

To implement, you need to call setOriginalText() and setReplacementText() on the message object with the appropriate patch.

This is a request to implement these methods in the RuboCop driver.

I know very little about RuboCop, but maybe someone who worked on D10738 could help out?

Event Timeline

Does RuboCop actually have a mode where it emits errors and replacement text?

RuboCop needs to have some set of flags that work like this for us to offer patching from arc:

$ rubocop --suggest-replacement-text something.rb
This text is bad: aaaa
Replace it with this: bbbb

I don't see such a mode from looking at the Readme on GitHub:

It appears to support autocorrect, but not a mode where it prints the autocorrections without applying them. We can't deduce the corrections from a pre-corrected and post-corrected file because two or more correction ranges may overlap.

Am I just missing this mode?

Assuming this mode does not exist, the clearest pathway forward is for you or someone else to:

  1. Get the Rubocop maintainers to add such a mode.
  2. Wait for us to build an arc packaging system (T10038 / T5055), which may happen this year. See that task for discussion of why we want to get linter maintenance out of the upstream.
  3. Volunteer to maintain the arc/Rubocop driver. Pull it out of arc and publish it as a package.
  4. Implement this behavior in the arc/Rubocop driver.

If such a mode already exists, you can skip step 1.

I don't know RuboCop well enough to definitively answer the question about whether that mode exists, or to volunteer to maintain the driver. But I opened a parallel issue in the RuboCop repo, so hopefully we'll find out whether RuboCop has this mode soon enough.