Ruby opinionated formatter - rufo

I’ve stumbled upon

and I am wondering what people think about it. Haven’t tried it yet tho, unsure how Foreman codebase would look like and I realize that we are probably way too big now. But the idea of super-fast formatter that can be hooked on editor save action is very tempting.

I think we need to enforce convention and we have a RuboCop for that.
I like to automate formatting, but I think it is a developer choice how to achieve it.

While I appreciate the project itself, RuboCop is IMHO very slow and not opinionated at all. I see most of these endless discussions on what’s better a waste of time. Rufy seems to be 10x faster, you can easily hook it up to Save event of your editor and it works great. With RuboCop, it does not work that way (it’s slow).

I briefly tried it and it’s not for us. For example it ditches all single quote strings for double quotes. While I totally like that and I think it’s a bad decision for a language to have two quoting styles, this is way too intrusive for Foreman codebase.

I really do like automatic formatting, it’s nice to never have to worry about how to format something and you don’t have to worry about the format of code during code reviews, just let the reviews focus on the logic. I’ve used tools like prettier for JS before and really enjoyed them. I know many teams speak very positively of implementing an automatic formatter

I think it would take some effort to adopt a tool like this for a large codebase like Foreman, and there would have to be ways to ensure everyone is formatting their code with the tool to avoid someone formatting unformatted code and creating unnecessarily confusing diffs. I haven’t tried rufo yet so can’t say anything in particular about the tool itself.

It would be good to keep something like this in mind for the future. Even just running once on Katello and being able to tighten up some eslint rules (200 char lines currently cough cough) could be a good way to test out a formatter. I also know there has been some talk of adding prettier on the JS side of things so that also could be a way to see how a automatic formatting workflow would fit in our project.

1 Like

rubocop rules :upside_down_face:

I wish the tool supported some kind of “only reformat what was changed by the last diff or unstaged changes” feature.