3 ms·
When you can look at some code in a repo and immediately know who wrote it, that is usually a problem. I've worked in code bases where the devs could not agree
by mrinterweb 3y ago
When you can look at some code in a repo and immediately know who wrote it, that is usually a problem. I've worked in code bases where the devs could not agree on style and they each did their own thing. It quickly became an unmaintainable mess. Having a homogeneous code style is a good step towards long term maintainability. It has been many years since I've worked on a rails repo that didn't have rubocop. Glad to hear rails will ship with rubocop.
- leecommamichael 3y agoI can't quite imagine what you mean by this, asking for clarification sorry if I come off wrong. Why is it a problem that you know who wrote the code by looking at it? Do you mean that their style is distracting?
- kevinmchugh 3y agoRuby has "reduce" and "inject" aliased. Most developers pick one or the other. A codebase that mixes them adds cognitive load. It's not hard, but it adds a speed bump to understanding.
- ysavir 3y agoDoes it really, though? How much time do you actually lose to having to sometimes read "reduce" and sometimes read "inject"? I've heard these arguments a hundred times, and not once did I feel like the underlying sentiment was more than "I like/dislike X, therefor I want to limit how much other people can use X".
- kevinmchugh 3y agoI worked on a small team for years and the other person who was there that whole time was an inject guy. I'm a reduce guy. It's fine, we never tried to change each other, but I never got over the mental hump of "what does inject do? Oh right". This is for the smallest possible style difference. I agree that a lot of folks get hung up on their personal preferences and want to fight about. Linters reduce those fights, and encourage everybody to just deal with it.
- mrinterweb 3y agoI mean if someone has a particular style that others disagree on, the repo ends up with inconsistently styled code. There are benefits to consistently styled code especially when there are a lot of hands in the repo. I think teams should strive to have a mostly homogeneous code style for consistency sake. It makes reading code easier and ultimately maintaining code easier. Having a linter enforce style rules is really helpful so code reviews don't need to be consumed with tedious style discussions. I like rubocop because it can be configured to be as flexible or strict as the team wants. Let the team establish what the level of consistency they want is.
- djur 3y agoHey, a true code stylist will stand out even after the autoformatter does its work. ;) It's good to have Rubocop included by default, but I wonder how many teams are using the "omakase" Rails at this point? I don't think I've done a plain `rails new` at work in a decade.
- romafirst3 3y agobeen coding in rails since about 2009 and only just hearing about "omakase" Rails now
- djur 3y agoI pretty much only ever see DHH saying it.
- mrinterweb 3y ago( * ^ *) ノシ , dejur. No doubt it a nice and rare luxury to start a new rails project. I wonder if the rubocop defaults will be included in rails upgrades or just new rails projects. Like when people upgrade to rails 7.2, maybe rubocop will come along for the ride.