[ENHANCEMENT] Add quickfixes for robocop rules
- [ ] disable rule for:
- [ ] line
- [ ] block
- [ ] file
- [ ] correct simple rules like:
- [ ] wrong case
- [ ] underscores in keyword
- etc... maybe the robocop team helps a little bit ;-)
I have plans for autofix for issues in new robocop. It will work bit differently than formatter, hence it will be part of the linter.
I assume that quick fixes expect to give particular node and get it fixed back? It would be good to have some examples how it could be used - so I could try to create Fixers in a way that could be reused. And that would focus on fixing only given issue in given node.
He @bhirsz, very good idea!
I wrote this enhancement last summer but haven’t had the chance to start anything on it yet :-(
In RobotCode, I currently only have an API based on Language Server Protocol CodeActions, which I think might be a bit too oversized for robocop, but it could certainly serve as inspiration. Check it out here: LSP Specification.
You receive a call for a document, a range, and a context that contains all the diagnostic messages at that location in the document. You can then react and send back CodeActions that match that location. The CodeActions contain information about which actions (QuickFixes are also actions) can be executed at that location. The simpler variant also includes all WorkspaceEdit, indicating which text sections in which documents should be changed—text-based. For longer-running operations, it can also be split (see the codeAction/resolve request) or passed to a command.
I'm not sure how far you want to go with robocop, whether it’s just file-specific QuickFixes or project-wide QuickFixes. That’s why I think a return similar to a WorkspaceEdit would be beneficial. With my QuickFixes, I also started by rewriting the model, turning it into text, and returning it. But as soon as you start making multiple edits simultaneously, it becomes problematic and creates too much overhead because text might shift. Changing text positions is easier than changing all tokens in a model.
If you'd like, we can do a Slack Huddle to discuss the details? I might have a few more ideas and requests for robocop as well, such as robot.toml, project-wide Unused Keyword/Variables, etc. Maybe we can collaborate more on this?
Thanks for the detailed response, I see now the problem is more deep and would require extra coding on robocop side for lsp. But that's fine - I will go through documentation to understand the scope better and provide something from our side.
Good idea, we can met and talk - it is better on weekdays/evenings or in work hours?
Edit - lets just pm on slack and figure out details for talk outside github issues :)