prontolabs / pronto-rubocop

Pronto runner for Rubocop, ruby code analyzer
MIT License
80 stars 74 forks source link

Add configuration for only posting warnings to added/modified lines #89

Open Phillita opened 5 months ago

Phillita commented 5 months ago

First off, thank you for your work on Pronto/Pronto Rubocop!

Problem:

I'm looking to add functionality to this gem that hides the external Rubocop warnings for unchanged lines of code. This is to help control the intake of warnings that are generated by new code without having to resolve warnings around it.

Example:

The file in question has a "Class has too many lines" Rubocop warning. Updating a method within this class that didn't cause this warning directly, is now receiving a Github Review comment with this warning.

Solution:

Caveats:

If new code generates a warning that starts outside of the patched lines, and no range has been provided, it will be ignored. The range option has been added to capture some of these but not all will be caught.

Getting a delta of warnings added before the new code would be the best outcome here, but that seemed non-trivial.

UPDATE - April 18, 2024

We've been running into issues with confusing offences showing up on lines that they are not directly connected to. To handle this, I've added in some messaging to show the line that the message/suggestion applies to. I've also made it so that suggestions will only be given to lines where the offence directly maps to the code line.