barbazoo
7 months ago
> I’ve recently come across a discussion where a new developer joined a team and faced over 300 PR comments on their first contribution. Most of it was stylistic nitpicking. This isn’t just unproductive, it’s outright toxic.
For me this says more about the company culture than any inherent flaws with the code review process.
OptionOfT
7 months ago
This is why I love things like cargo fmt / go fmt / eslint / etc.
No discussions of whether
if (foo) return;
is valid, or we should do if (foo) {
return;
}
chipdart
7 months ago
> This is why I love things like cargo fmt / go fmt / eslint / etc.
I agree. Once I had the displeasure of working with a junior dev who was very prolific in posting comments on style and if a space should be at the left or at the right of a symbol. It took me a few days of dealing with that noise to onboard a linter.
Even so the junior dev felt entitled to manifest how high their standards were by posting a torrent of comments in the PR that onboarded the team's official linter config.
But once the PR was approved and merged, surprise surprise: the junior dev's PR comment metrics dropped from dozens per PR to zero. The style guide didn't even had to be enforced.
The last I've heard about the junior dev was throwing a tantrum when one of their PRs received a comment from another team member asking to run the linter because it failed to adhere to the team's official style guide. Apparently the high standards and this attention to detail only went one way.
plasticchris
7 months ago
That’s why you hook the linter up so it runs on every commit / push. No need to ask, it always runs. And no need to quibble over style. Don’t like it? Change the linter.
move-on-by
7 months ago
I agree that it should be hooked up to run as a precommit hook, but unfortunately that doesn’t always solve things. People can- and do- bypass precommit hooks. It happens all the time at my company with certain teams, but I’ve been unable to figure out why. Any precommit hook that should run- needs a correlating required PR action to verify any precommit expectations are met. Otherwise, people reviewing the PRs just assume it ran and the people bypassing it get away with it.
cced
7 months ago
Create a linting step that fails if running the linter creates a git diff delta.
Aeolun
7 months ago
I very much dislike any process modifying my commit after I submit it. Rebasing becomes hell.
plasticchris
7 months ago
run it in a hook that runs before the commit is made
cempaka
7 months ago
Yeah we just have any linter failures fail the CI build, but it's left up to submitters to decide how to resolve the violations.
plasticchris
7 months ago
Yeah, that’s what I meant in the first comment :)
rurban
7 months ago
Install pre-commit with various linters for all the languages and data files out there, and the problem is solved. I do it even for Makefile's and cmake.
Add it to your CI also, make lint and a make fmt.
theshrike79
7 months ago
Just having a valid .editorconfig for the project will do a lot for languages without gofmt.
hibikir
7 months ago
That's also why I dislike it: The mind that will go apeshit over trivial style nonsense will still provide unhelpful feedback on other topics... but it will become far less obvious that their comments should be downgraded.
Formatters also do a poor job if your language is flexible and expressive. Great for go, but if your language is the kind that easily supports internal DSLs, formatters are not even helpful at making the code regular
chipdart
7 months ago
> over trivial style nonsense
What's your definition of "trivial style nonsense"? Is it "something I personally don't understand or care"?
Things like tabs vs spaces is important, and so is how many spaces an indentation level should take. This affects how editors reformat code, how other people's editors present the code, and even how many lines a commit has and is blamed for a change.
That's why linters are of critical importance to a team, and so is adopting a shared standard and editor config.
The only people who don't understand the importance of a style guide and how to make it a non-issue by enforcing tools to enforce it are those with little to no experience working with software.
avidiax
7 months ago
I have lots of experience working with software.
Linting and style guides are not of "critical importance". No business objective will go unachieved because some checkins use tabs and others use spaces.
Whatever problem style issues might cause can be resolved before lunch by running a formatter and committing the result.
chipdart
7 months ago
> Linting and style guides are not of "critical importance".
This is simply false, as attested by the huge volume of comments in this thread by those with actual professional experience working on real-world software projects.
You're also oblivious to the problem domain, because otherwise you'd understand that the critical problems are not whether a space should be at the left or at the right of a symbol, but all the churn that is required to manually address style problems in PRs.
Try to think about the problem. You post a PR that screws up all formatting. It takes time for a team member to review a PR. Once you start to get reviews,you notice comments pointing out failures in complying with a specific style. Whether you go the passive-aggressive path of waiting for any other team member to review your code or you do the right thing and fix the problems you introduced, that requires another round of PR reviews. The time that you take with each iteration is the time your work is delayed to be merged. Now think about how many hours per month you waste just because you can't manage to format your code properly.
devjab
7 months ago
I’m not sure if I’m understanding you correctly, but how on earth would a pull request even make it to the review state if it fails to lint in the pipeline?
I sort of agree with GP in that the discussions are a waste of time. I also agree with you that you should simply automate it through tools. Styling doesn’t have to be a democracy or about personal preference, all styles work, it’s all about picking one and then forcing everyone to use it. Of course you do it in a much more involving process than what I make it sound like here, but ultimately someone with decision making powers is going to have to lock down the process so no further time is wasted on it.
emptiestplace
7 months ago
> resolved before lunch
blame.ignoreRevsFile
chiph
7 months ago
Only one place I have worked at had the goal of writing code as if it were from just one person and it was pretty nice, honestly. The diff tool output was easy to understand (not a lot of noise). What made it work was everyone was pretty mature and understood that this was a group effort, and not everyone was going to get their personal itch scratched around brace style, etc.
We did have some outside contractors who didn't get it at first, but after several of their submissions were rejected (with potential financial penalties) they got onboard and followed the guidelines we had sent them. "These people mean it."
Jare
7 months ago
> it will become far less obvious that their comments should be downgraded.
I'm curious why you think this would happen... I would imagine that their comments will now have be to about things that matter, and if they are unhelpful they will stand out more.
Brian_K_White
7 months ago
It is obvious that a style comment is of no significance, and that the person who made it chose to spend time and personal capital on something of no significance.
It is not obvious that an actual code change is of poor quality.
To show that takes infinitely more experience, work to analyse all the direct and indirect ramifications of both the original and proposed approaches, capacity to push back and decide that your own engineering judgement is equal or better than whoever is purporting to correct you, willingness to suffer everyone else accusing you of arrogance for that on top.
Even with all of that, it's a lot harder to prove the valueless comment is valueless because the more you know, the more you know that practically every single line of code could be done 30 other ways with some valid argument for each one.
It's completely insidious both for the junior and the senior.
The junior has no way to know the junk comment is junk. So they internalize the comment and everyone is worse for it.
The senior has it almost worse. They know enough to know they don't know everything and the comment might be valid, so they put in all kinds of work to try to figure out if they actually missed something, did they have point etc. Maybe in the end the code doesn't end up as bad as the junior just rolling over, but it sucked for everyone and the challenge was not really an intentional productive crucible, it was just a douche that everyone had to waste time and energy taking seriously.
Only someone who actually is arrogant (whatever level, whichever side of the pr) has it easy. Again bad for everyone except them maybe.
1123581321
7 months ago
If the seniors are too passive to say no faster and faster, and management is absent, the junior’s going to end up being the tech lead. I’ve seen this. :)
It’s not necessarily even bad if there is no meaningful leadership above or alongside the junior. The fast-rising junior may end up hiring developers who are more assertive and still capable.
philwelch
7 months ago
Can you give an example of what you mean by a language supporting “internal DSL’s”?
Jare
7 months ago
Scala would be my immediate thought. Probably also C/C++ with macros.
mihaaly
7 months ago
Who cares?!
pavel_lishin
7 months ago
I care.
I don't particularly care which one you choose - although I admit to having a preference - but I want that style consistently applied throughout the project, so I'm not stumbling over stylistic differences as I'm scrolling through code trying to investigate something.
And keep in mind that this particular example, that some people can read clearly, is just five lines. When you're looking at a 3k line file, one of the dozen you're digging through during an outage, that shit matters.
majkinetor
7 months ago
Its not only that. Style may signify more than just a cosmetics, it can lead to vastly different code understanding.
mihaaly
7 months ago
You need to work with code from multitude of sources, then you will learn how to read code efficiently. And how futile are your dreams about styles. We are not supermodels and fasion designers, far from it, get over it!
meowfly
7 months ago
I agree. I can read both of them clearly. I'm not sure what value we are maximizing for in this example. It's definitely not readability.
Mawr
7 months ago
Of course you can, it's a tiny, isolated example consisting of 5 or so tokens. That's not how real programs look like so you cannot take the example so literally.
The second form is superior for at least three reasons:
1. Enables a property corollary to the happy path rule, which is that every return statement of a function is at the beginning of a line. This property is crucially important for readability, it makes it reliably possible to determine every exit point of a function by merely scanning the left hand vertical slice of it as opposed to needing our eyes to jump around erratically searching for arbitrarily placed returns.
2. Uniformity: mixing different if statement styles in a single codebase interferes with our ability to match visual patterns. Since we can no longer rely on every if statement looking the same, we cannot quickly skim over code anymore.
3. Refactorability: it's easier to add another line of code to the if statement if there's no need to also add brackets.
climb_stealth
7 months ago
Bugs. Subtle horrible bugs that can take forever to find. Not having the braces makes it so easy to accidentally break in later changes or refactoring. Sure on its own it's super obvious, but next to other changes or refactoring it is really easy to miss that suddenly logic falls out of the condition or doesn't make sense anymore.
I don't remember the details but I've had some typo in a one-line-if-condition once and it took me days to find it. Might have been an accidental semicolon in C. A linter enforced the braces and line-breaks and made it obvious.
Anyways, running a linter also helps because all anger or frustration can be directed towards the machine.
Timwi
7 months ago
> Not having the braces makes it so easy to accidentally break in later changes or refactoring.
Did you mean “not having a linter”? Because once you have a linter you no longer need the braces because the autoformatting will always fix the indentation.
climb_stealth
7 months ago
I was thinking of a case like this:
if (foo)
return;
Perfectly valid and people do it. But then later on someone might put a debug statement above the return to check something. Or add some other logic. if (foo)
doSomething();
return;
And suddenly the logic is broken and the return falls out of the if-condition. It looks fairly contrived with an example like this but easy to do when code is a bit more complicated or people are tired or rushed. It's a good habit to always enforce braces for if-conditions as it defeats that whole category of mistakes. Fairly innocent but can be so hard to find because of that.A linter would enforce having braces and solve the issue. And for codebases without a linter it is a good habit to just go with the braces.
Timwi
7 months ago
I think you misread what I wrote. Your example could be fixed by braces, but it can equally well be fixed by just automatically fixing the incorrect indentation. Visual Studio has been doing this for a decade already. It's really not rocket science.
mihaaly
7 months ago
The trouble is with those rush code out without really looking what they are doing. They make those mistakes, very easily, indeed.
No style could save us from those devils!
People should take the necessary attention to make quality work (and use proper techniques, where proper does not entail style or other visuals or appearances, not at all. That's for superficious persons). This is true for any part of life not just coding.
user
7 months ago
chipdart
7 months ago
> Most of it was stylistic nitpicking.
One man's "stylistic nitpicking" is another man's violation of the company's official coding guidelines.
Does the company adopted a linter? If so,why has the new hire not applied it before posting the PR?
Imagine a new hire throwing a hissy fit because even though the whole company writes code in PascalCase he feels that snake_case is better.
Imagine a new hire decided that tabs are better than spaces, and proceeded to reformat 30% of a source file leaving behind wonky indentation.
Shall we tolerate code that has both just so that random internet people in a random online forum can rail against PRs?
Or shall we post a comment in a PR pointing why the code should be reformatted?
Larrikin
7 months ago
Using snake_case everywhere when you should be using camelCase should have been one or two comments at most. It's toxic to go through every use and comment
thiht
7 months ago
Toxic is a strong word. It’s useless, but not toxic, some people might think they’re making the reviewee’s work easier by flagging all the occurrences of an issue. Maybe they like that on their own PR. Maybe they never thought about it and think thoroughness is expected. If someone’s code review practice is bothering you, just mention it instead of labeling it as toxic.
PhilipRoman
7 months ago
IMO the best way to handle stylistic choices (if at all) is to have the reviewer just adjust it themselves. Ping-pong with comments like "add empty line" is a waste of time for everyone.
yjftsjthsd-h
7 months ago
Not just stylistic choices - I absolutely love the way ex. gitlab lets you do a suggested change in a comment, precisely because it lets me do all the work and the MR owner just has to click to accept if they agree. That lowers the bar for what I'm willing to bring up in the first place (though I personally still don't like to comment on matters of style or taste) while making it less work for everyone, which makes it much easier to give useful suggestions:)
mixmastamyk
7 months ago
Is that new? I don’t remember that feature, working with gitlab a few months back.
chipdart
7 months ago
> Is that new?
It's neither new nor novel. Even GitHub allows anyone to post a commit on a feature branch, regardless of who created it.
It's not a GitLab or GitHub feature. It's a Git feature: the ability to post a commit to a branch.
Anon1096
7 months ago
I'm not sure about gitlab, but on github this is a distinct feature where you post a comment wrapped in three backticks and the language as suggestion. It'll format it as a diff that the author can one-click create a commit from.
https://github.blog/news-insights/product-news/suggested-cha...
bdangubic
7 months ago
create alias dont-fuck-with-my-branch
git reset --hard HEAD~1
git push -f
:)
chipdart
7 months ago
Services like GitHub and GitLab support preventing changes that overwrite a repo's history, in addition to tracking history even when you force update a branch.
bdangubic
7 months ago
I was just joking but surely I can revert a commit on a feature branch, no?
chipdart
7 months ago
You can revert and even force-update the branch to rewrite it's history, but GitHub still tracks the old commits and even lists in the PR the events that rewrote the branch history.
bdangubic
7 months ago
sorry for misunderstanding, I am NOT trying to hide the fact I reverted, hence the alias dont-fuck-with-my-branch :) and I was overall just joking…
mdaniel
7 months ago
I like GitLab's feature of "suggested change" whereby the submitter can offer the change as a one-click "accept change" but importantly the change is still under the original author, because in any sane(?) review process, authors are not able to approve their own merge request. In your workflow if the reviewer checked out the branch, did the needful, committed, and then resumed reviewing they'd have locked themselves out of approving (err, assuming the aforementioned "authors cannot approve their own merges")
https://docs.gitlab.com/ee/user/project/merge_requests/revie...
https://docs.gitlab.com/ee/user/project/merge_requests/appro... and https://docs.gitlab.com/ee/user/project/merge_requests/appro...
paiute
7 months ago
I like this idea, it has the bonus of revealing how much the reviewer actually cares. I bet half the things they wouldn’t take the time to fix themselves.
chipdart
7 months ago
> I like this idea, it has the bonus of revealing how much the reviewer actually cares.
And now you contributed to turn your team culture into shit, with a toxic mix of PR creators purposely shitting on the team's style guide and PR reviewers who have to constantly post follow-up commits to your work because you can't even put together and acceptable PR or clean up after yourself.
What if anyone who posts a PR addresses feedback anyone posts on their work and addresses them until you get the necessary and sufficient approvals?
chipdart
7 months ago
> IMO the best way to handle stylistic choices (if at all) is to have the reviewer just adjust it themselves.
How does that inform the PR author that they failed to pay attention to a relevant detail, and more importantly contribute to not make it again?
If there is no feedback, problems will persist.
Nit comments add noise and failures to comply with a style guide is always a distraction on a PR, but that does not mean style guide violations should be ignored. It means that your team must work their way into making them a non-issue.
This means establishing an objective and usable set of rules and guidelines, and enforce them programmatically with a linter, not turning a blind eye to style violations.
grecy
7 months ago
> Ping-pong with comments like "add empty line" is a waste of time for everyone.
And any manager that lets it happen without severe reprimands to the time-waster isn't worth working for.
We've all got way more important things to be spending our time on.
chipdart
7 months ago
> And any manager that lets it happen without severe reprimands to the time-waster isn't worth working for.
That would be something only a terribly incompetent manager would ever do.
A manager who is not terribly incompetent would either not take sides until explicitly asked to weigh in, and if and only if he was dragged into the discussion then the manager's only acceptable input would be to eliminate the problem for good by adopting a linter.
Everything else is a mistake and a complete waste of time.
EliRivers
7 months ago
have the reviewer just adjust it themselves
Passive-aggressive minefield. Someone will see a change done to THEIR code, without the changer even asking, and it will feel like the person who did it is a passive aggressive dickhead. Resentment will brew, tempers will be lost. It will only get worse from there. Software engineers already aren't exactly known for their humbleness and ability to swallow their ego.
BeFlatXIII
7 months ago
Sounds like a team of overvalued prima donnas.
EliRivers
7 months ago
Oh, so you've met software engineers? :)
watwut
7 months ago
IMO, the best way is to have automatic formatter shared by team.
thiht
7 months ago
Isn’t that a given in 2024? I find it amazing that it still seems to be an issue in some places. Using a linter/formatter is a no-brainer at this point, and it’s been for years.
a96
7 months ago
There's probaly a ton of projects that don't even have version control in 2024, let alone a linter.
onion2k
7 months ago
It says PR comments benefit the reviewer in some way, and they're not always left to improve the code or to help the person who opened the PR. For example, if you work in a culture where being seen to leave PR comments is seen as positive regardless of the quality of them, or even that code review is a tracked metric that contributes to your performance review.
That culture will turn even the most conscientious dev into a monster.
herpdyderp
7 months ago
This kind of feedback has largely been solved, for me / my team at least, with linters and formatters (as mentioned in the article). So I'd say it is still a reflection on the code review process being broken.
johannes1234321
7 months ago
There is a lot of stuff a linter can't do, which however are stylistic choices some people care a lot about. Naming being a big one. Which terms to abbreviate how etc. Also there are a lot of things where automatic highlighting is possible, but any rule needs exceptions which a re subjective (nesting, usage of "raw" looos, early exit, ...)
Trying to get some consistency there can be good. And teaching new team members the "habits and traditions" may simplify long term maintenance.
However could review tools aren't a good place for distinguishing between "hey, this is good, but I'd like this slightly different" from "there is an actual issue" but that has to be solved somehow by communication. Which often isn't the best skill for engineers.
chipdart
7 months ago
> There is a lot of stuff a linter can't do (...)
Whatever a linter can't do, it's not worth doing.
> Naming being a big one.
You're confusing personal opinions over how to name things with concrete style issues.
greatgib
7 months ago
In lots of case linters might be harmful also. It is one thing to have a style guide people follow in most cases, it is another one to rigidly force everywhere the style that the linter enforce.
Especially because most linters will impose that everyone on the team will use them.
For example, if we take Python, there is black that is bat shit and makes your code less readable but adopted by so many teams as cargo cult because doing that signal that you are a cool, hype, best practice following team...
In the end with "black", people are forced to abide by the style of the random guy that created it, that is not exactly following the PEP8 or the zen of python, and is just itself created in cargo cult inspired by go and rust, and Python creator even advised against using it for readability except in special cases like very very big teams.
jessekv
7 months ago
> not exactly following the [...] zen of python
Blacks's stance that "there should be one obvious way to format things" seems consistent with the zen, even if you disagree with the actual rules.
greatgib
7 months ago
For me it is not respecting the zen of python by pushing you to bad formatting sometimes just because the tool requires you to.
And just for reminder, the following is one important point at the beginning of the pep8:
Foolish Consistency is the Hobgoblin of Little Minds
roland35
7 months ago
Yes exactly! Reviews should not waste time with format - I would take the hour to set that up in CI and never worry about it again.
Or if that is too much (no shame!), just accept style differences.
chipdart
7 months ago
> Reviews should not waste time with format - I would take the hour to set that up in CI and never worry about it again.
What if you post a PR and forgot to run a linter or configure your editor? Should that not justify a comment over style violations?
The problem will only go away if everyone is on the same page.
philwelch
7 months ago
CI should reject the feature branch if the linter fails. Never waste an engineer’s time doing work a program can do.
It’s also often handy to configure linters and autoformatters as precommit hooks.
chipdart
7 months ago
> CI should reject the feature branch if the linter fails.
Your CI pipeline is broken if it refuses to run because of style issues. Linting is either applied as a pre commit hook or manually by the developer. Anything else is a mistake you are making without any concrete tradeoff.
The same goes for other mistakes such as handling warnings as errors.
Imagine going into a meeting with a senior manager and explain that you cannot release a hot fix because your pipeline is broken due to the last commit having 5 spaces instead of 4.
thiht
7 months ago
> Your CI pipeline is broken if it refuses to run because of style issues.
Strong disagree. If it’s not in the CI, it’s optional. Respecting the formatting standards of the project is NOT optional.
It should definitely be applied as a pre-commit or pre-push hook too to make sure the CI step is just a formality, but it’s not enough.
philwelch
7 months ago
> Your CI pipeline is broken if it refuses to run because of style issues.
The whole point of CI is to automatically verify the code. Linters are a method of doing that, the same as tests.
> Imagine going into a meeting with a senior manager and explain that you cannot release a hot fix because your pipeline is broken due to the last commit having 5 spaces instead of 4.
Sounds like an easy fix to me. And if your CI is set up properly, the misformatted branch wouldn’t have been merged to master in the first place.
nemetroid
7 months ago
Just make sure that the pipeline is fast, or allow an override, and there is no issue.
chipdart
7 months ago
Requiring manual intervention to handle a blocked pipeline over a non-issue defeats the whole purpose of continuous integration, not to mention that you are suggesting adding twice the complexity as an alternative to not adding any complexity at all.
And should I stress again that there is absolutely zero positive tradeoffs?
philwelch
7 months ago
Who’s blocking any pipelines here? If you’re running a PR process at all, these changes are being pushed to a feature branch and reviewed before getting merged to master. If you have a feature branch that’s failing CI, that doesn’t block me from merging my feature branch once my PR is approved.
As I specifically said, the CI should fail on the feature branch. If you’re only running CI on master, you’re going to run into the exact same problem if your unit tests fail. The way to avoid that problem is to run the unit tests on your feature branch, and if you’re doing that you might as well run the linters too.
nemetroid
7 months ago
> And should I stress again that there is absolutely zero positive tradeoffs?
Just because you don't value or acknowledge them doesn't mean they don't exist.
SketchySeaBeast
7 months ago
Yeah, if you care about it enough to stop a PR because of something and that something can be automated, automate it.
znpy
7 months ago
on a different side: it also tell you (a lot) about specific people.
I've seen good/great people call out the nitpicks (in my case it was often mis-spelling, due to not being a native speaker of english) but will approve the PR anyway (implicitly expecting another revision to be sent, trusting the submitter).
On the other hand bad/toxic people will drown you with stylistic nitpicks and won't approve (and trust) you to do your best work. You will be essentially blocked pending their approval (so that nitpicks are changed according to their likings).
The weird thing is that all this traceability leaves traces for management to see who's doing a good pr review job and who's not... But I've learned that management usually does not care much.
to11mtm
7 months ago
It's tough with spelling sometimes.
In my current role I review a lot of PRs, they tend to be large due to the waterfall way things work... If I don't ask to fix the spelling now, It might not happen for a year or two. That said if it can be fixed in separate PR before release, that's fine.
Really, it's best to have some terms or explicitness.
For example, with my teams 'Nitpick' means I'm just being nitpicky, Doesn't have to change unless it's on the edge (and I'm explicit as to why it should change, i.e. I know the next thing will need the change anyway). "Consider" means It doesn't have to happen, but here's some food for thought. "PLZ FIX" is fairly self explanatory.
Also, making sure management (especially for contract houses) knows that PRs are a 'judgement free zone' and should not be held against people for perf reviews etc; that should be collected by other peer feedback channels instead.
barbazoo
7 months ago
Agree. Why did the junior developer feel like their changes were ready to be reviewed. Looks like they had little guidance. Why didn't a senior developer suggest to close the PR, apply the formatting or whatever and then re-open the PR or something like that. 300 comments, that's either a lot of developers commenting or just a lot of back and forth. I don't get how anyone would let it come to that point. Makes me feel grateful for the places I worked at and the experience I have now.
dec0dedab0de
7 months ago
* I've seen good/great people call out the nitpicks (in my case it was often mis-spelling, due to not being a native speaker of english) but will approve the PR anyway (implicitly expecting another revision to be sent, trusting the submitter).*
I always thought this was the best way.
I wish these systems had a way to assign severity to comments, and urgency to the commit.
If you have a jr developer it is your job to give them stylistic feedback, the problem comes from mixing it in with security holes or sneaky bugs. And when the process doesn’t identify when we need to ship it yesterday, vs in the next few months.
yjftsjthsd-h
7 months ago
Depending on your company culture, you can also just explicitly write something like "This is not a blocker, but I would suggest...". Of course if your culture uses explicit "press the button to unblock" then that's probably redundant.
erik_seaberg
7 months ago
Half of my comments were "nit: consider blah blah" where I want it on his radar, but I approved anyway and if he declines I'm fine with it.
to11mtm
7 months ago
Yeah I do similar and encourage colleagues/orgs to do the same.
fmbb
7 months ago
rileymat2
7 months ago
In many dynamic languages, depending on scope, spelling is not a nitpick, it has long term mental costs and very well can cause bugs.
znpy
7 months ago
I should have been less ambiguous: i meant spelling of words on the English language, in comments.
Good pr systems will perform a build of the code and run tests, so if the mis-spelling is in the code the build will fail anyway.
Aeolun
7 months ago
Sorta, but it’s almost never worth blocking the PR over. Just ask to fix and approve. If it doesn’t happen and you come across it later just fix it.
vips7L
7 months ago
Spelling automatically should be highlighted by the ide too. Spelling mistakes means you’re blatantly ignoring warnings from the ide.
znpy
7 months ago
Please see my other comment. I meant misspelling of English words in the comments. Misspelled code will not compile and/or pass the tests so the pr won’t be accepted anyway.
prh8
7 months ago
"will approve after nitpicks" is the most asinine behavior
js8
7 months ago
I think a good general advice when training somebody is - focus them only on the biggest flaw at the time. That's how I would proceed with a "bad" PR.
I would even accepts smaller issues (style) when there is a bigger issue to fix. People might eventually outgrow it.
eddd-ddde
7 months ago
For me it's the opposite. If I'm making a PR, please point out ALL of the nits you can even think about. My next PR is bound to have at most 25% of that since by now I get more about what the team values and considers important.
collingreen
7 months ago
This highlights something very important to me that sometimes gets lost when thinking about the tooling and that is the human element and the importance of communication, existing relationships, and rapport. The PR feedback I give and receive is extremely influenced by the relationship I have with the person - for some PRs any nit pick feels frustrating but I have other coworkers that can slam my code and even pepper in insults but our relationship lets me read it in the jocular and secretly constructive way it is intended.
The code is the same way and there was a great comment higher up about an ignored lint rule being an indicator of someone thinking about it and making a judgement call that this time the rule shouldn't apply. I have SOME peers where that my reading of that line of code and others where my assumption is the opposite and they were just lazy or didn't know how to do it "the right way". It's the same line of code!
I don't know how tooling will ever replace this part so I think it's important to keep it as the bedrock of any collaboration process.
chipdart
7 months ago
> The PR feedback I give and receive is extremely influenced by the relationship I have with the person - for some PRs any nit pick feels frustrating (...)
Posting PR comments doesn't prevent you from accepting the PR. You can post a torrent of nit comments and still approve it so that minor issues don't turn into blockers.
bluefirebrand
7 months ago
Honestly for me it tells me they need to hook up a code auto formatter into their workflow
Forget stylistic nitpicking. Enforce a code quality standard with a linter and formatter and be done with it
InvaderFizz
7 months ago
I agree. Even within my own org there is some nitpicking, but it's almost always about style consistency for our shared codebase, which is valid.
If your PR doesn't pass lint checks, it doesn't get merged. And the only reason it would fail the lint checks is if your pre-commit hooks didn't fire.
There is no argument of 2,4,8 space vs tabs, because the code you commit is run through the linter.
Write however you want for the things that don't matter, the formatter always wins.
arp242
7 months ago
It's impossible for any code formatter to be 100%. Where to put a blank line? Where to break a line? How to name a variable/function? etc. etc. Some try (e.g. prettier), and what you end up is frankly just bizarre code that's just ugly. Never mind tons of other small things that often don't really matter.
The solution is to just not be too anal about it. It really is a cultural problem.
For example a few weeks ago I reviewed a PR from a new team member; there were some seriously structural problems with his approach, so I commented on that and ignored all the small stuff for now. Another programmer on my team also reviewed at the same time, and only commented on the small stuff that, IMHO, don't really matter, and didn't look at the general approach at all (which really was just all wrong, and also quite obviously wrong).
Not to be too arrogant about it, but I feel this sort of stuff is what distinguishes a "good engineer" from a "mid engineer".
bluefirebrand
7 months ago
> The solution is to just not be too anal about it. It really is a cultural problem
"Any proposal that requires everyone to just is not a solution, because everyone will not just"
People are anal. You aren't going to get them to stop being anal
A real solution is to have the team agree on a shared style guide, then enforce it with a linter and formatter. If anyone cannot come to an agreement with the rest of the team, or continues to be anal about things that do not appear in the style guide after this, then that person has singled themselves out and the company will need to find a way to deal with the behavior
I agree that good engineers focus more on the actual structure and problems instead of nitpicky things like formatting
That said, code cleanliness and consistency is important too. It makes codebases much easier to maintain and understand if everything is formatter consistently. It's a pretty mid engineer take to think it's not important at all
arp242
7 months ago
You can't "enforce" all of these things. That was my main point.
And you absolutely can stop people from doing that. Simply accepting dickish asshole toxic behaviour as "well, people are like that shrug" and never telling people off is exactly the problem.
bluefirebrand
7 months ago
If you start telling people off at work, there is a good chance that you will be perceived as being the problem
If you go to management to complain about a coworkers behavior you may just be told that you have to adjust your expectations to get along with them
If there's a team agreement and someone continues to violate it then you actually have a complaint you can make to management that has some bite to it
chipdart
7 months ago
> If you start telling people off at work, there is a good chance that you will be perceived as being the problem
The whole concept of a PR is to review the changes you ask your team to pull into the repository.
What do you think PR comments are intended to be? Pats on the back and public announcements on how awesome you are?
No, the whole point of a PR is to allow others to review the changes you proposed so that the mistakes you are trying to introduce are easier to spot and prevent.
What do you call comments that flag a problem with your code changes? Do you call it "being the problem"?
> If there's a team agreement and someone continues to violate it (...)
How will they tell if you do not point out those violations in the PRs? That's precisely why they exist.
chipdart
7 months ago
> I agree that good engineers focus more on the actual structure and problems instead of nitpicky things like formatting
I don't think you understand that formatting is of critical importance.
Sure, your code won't break if you add a space at the right or at the left of a symbol.
But your code will be reformatted the next time someone like you works on that file and takes the same naive approach to that code that you took.
That leads to PRs having a larger code footprint for no reason other than fixing the previous PR's failure to comply with a style guide.
This means tools like Git blame start to flag parts of the code as having changed recently just because you failed to pay attention to the style guide.
Now that regression that was introduced by an unrelated commit becomes slightly harder to track because it's buried between commits that add and remove white spaces around the problem, and the last change is just nitpicking around something you should have gotten right in the very moment you posted your PR if only you ran a linter or paid attention to the comments posted in your PR.
em-bee
7 months ago
style fixes should always be separate commits. if they fix a PR, they should be part of that PR or an independent PR, but ideally not included in the next code changing PR
chipdart
7 months ago
> style fixes should always be separate commits.
Not really. If you're already changing the code and running linters afterwards introduces changes over your change, this means you are the one introducing the problems. Separate commits just add noise.
Your comment is like saying that bug fixes should be separate commits when arguing about how not to add bugs to begin with.
em-bee
7 months ago
ok, yes, you should not introduce style problems to begin with. but if the problem is already there from an older PR, it should be fixed separately.
The_Colonel
7 months ago
This:
> "Any proposal that requires everyone to just is not a solution, because everyone will not just"
invalidates this:
> A real solution is to have the team agree on a shared style guide, then enforce it with a linter and formatter.
... since the "team" is everyone. It's basically the same problem.
The other issue is that linters/formatters don't "solve" all formatting/stylistic choices. Most formatters, fortunately, still allow you to choose where you do line breaks for example, since they do matter and shouldn't be arbitrary.
bluefirebrand
7 months ago
They aren't the same at all
A shared style guide is an external impetus to adjust behavior. It comes with external accountability, and also an implicit understanding that violating the shared expectation may bring consequences
"Everyone should just be less anal" is expecting an internal impetus to adjust behavior. There no external accountability, and there's no expectation that failing to do so has consequences
> The other issue is that linters/formatters don't "solve" all formatting/stylistic choices.
80% of a solution is better than 0%
The_Colonel
7 months ago
The point where this is the same is "everyone just needs to agree on a common style".
> 80% of a solution is better than 0%
I'm not sure if it's 80% or rather 20%, I guess it's a POV / arbitrary number.
In any case, this is far from a solved problem, while I often see in these type of discussions the idea that auto-formatters solve formatting/code style problem. "Just use black" while dismissing the idea that the rest has to be tackled informally / culturally.
wnoise
7 months ago
You're not wrong.
But in theory, agreement and buy-in is a one-time thing, while actually writing the code and reviewing the PRs are constant things.
The_Colonel
7 months ago
Yes, but aligning the team culture is in theory also a one-time thing. And this is IMHO necessary in any case, no matter if you decide to enforce this alignment using auto-formatters or not.
chipdart
7 months ago
> It's impossible for any code formatter to be 100%. Where to put a blank line? Where to break a line?
Not true. Those are objectively covered by any linter.
> How to name a variable/function?
Unless the issue is things like snake_case vs PascalCase, that's not the job of a linter. That's exactly what PR comments are about.
> Some try (e.g. prettier), and what you end up is frankly just bizarre code that's just ugly.
Not true. Without Prettier you always get bizarre code that's just ugly. You don't notice because you paid no attention to the code you wrote, it followed your personal subjective opinion you happened to have at that moment, and you didn't felt strongly enough to verify it.
Without a linter, others would certainly point out the problems they saw in your PR as that would certainly not comply with their personal subjective opinion they might hold at that moment and not before or after.
The importance of Prettier is that it objectively enforces a set of rules. If it's ugly it's because you configured it to be ugly, but it's less of a problem because it will be objectively, systematically and reproducibly ugly.
barbazoo
7 months ago
Oh 100%. Discussing style within a PR unrelated to changing the styling rules seems like a waste of time.
chipdart
7 months ago
> Enforce a code quality standard with a linter and formatter and be done with it
Adopting a linter does not eliminate style issues. It just eliminates the number of possible comments a PR can get over style issues by replacing all detailed feedback with just one comment with a very clear actionable request that's trivial to satisfy: "It seems X doesn't look right. Could you please run the linter?"
edflsafoiewq
7 months ago
Style also involves things like "renaming variables", to take the article's example, which can't be automated away.
AlotOfReading
7 months ago
There are formatters that will enforce the basic case/underscore rules of naming conventions. I haven't seen one for the actual text, but I can see how that might be nice if it worked reliably.
marcosdumay
7 months ago
This. You either don't care about style or push the style automatically without any interaction. Every other option is bad to some extent.
But only use a linter if you will add your rules over the empty set. If you get a pre-built set and are expected to remove the ones you don't need, you are making a toxic environment.
DanHulton
7 months ago
This literally what the article says.
chuckhend
7 months ago
Automating this with linter and formatter is great. It moves the argument over style and format to a one liner change to a lint config instead of mingling it with the with the main code change.
bluefirebrand
7 months ago
It also hopefully only happens once.
If you continue to have people bringing up arguments over the linter and formatter after an initial agreement is made, then you can talk to those people
user
7 months ago