Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Does your organization enforce a code style/formatting standard?
4 points by BitwiseFool on Jan 27, 2021 | hide | past | favorite | 8 comments
There's a discussion going around in management about creating a common style guide for our source code. Currently the only style that is enforced is that we use spaces instead of tabs and the length is two spaces per indentation level. Everything else is informal convention and there's a lot of subtle variation across the codebase.

We primarily use C# and SQL. I'm curious if you have to abide by a style guide and if you've encountered any pitfalls when enforcing a standard like that.




Yes, I'm the one pushing for a very annoying linter. Some coworkers don't like it but I think the majority likes it.

We use eslint with a set of airbnb and unicorn rules. We went from the recommended rules and changed a few settings. Most of the rules will reformat or fix the code automatically so it's not a huge problem during development. If it's not automatically fixed, you will still have a link to the documentation explaining why the rule exists. You also cannot merge to the main branch if the linter is not happy.

And I recently started to write custom eslint rules too, it's not very difficult and it's fun.


I'd recommend installing a linter to avoid wasting time discussing, reviewing and questioning standards. Opinions will vary, but I think we waste an enormous amount of mental energy on standards where I work.


Yes, we have a style guide and enforced auto-formatting tools (a la gofmt or clang-format). We didn't in the past, and I like the present much better: it frees me up while writing and reviewing code to not have to think about formatting. Almost everyone I talk to feels the same way.

It's a bit uncomfortable at first when you can't use your favorite style anymore, but the advantage of not having to think about style for me vastly outweighs the advantage of being able to code in my personal favorite style.


I think in 2021 the only sensible thing to do is use an autoformatter and force it to run before merging changes. Just don't have the discussion.


Agree. I don’t want to waste a second of my time thinking about whether I mis aligned something or my lines or too long or I didn’t follow some syntax preference. Automate it or don’t stress about it.


I shudder when I look back 10 years to when I worked somewhere that didn't have strict lint rules to codify style practices.


My day job uses clang-format for a larger C++ codebase. Our tech leads were for it to "automate" discussions on code style. Before it was integrated, it wasn't uncommon to have code style be a larger part of a code review.


Of course! And we're super anal during code reviews about people who won't follow it. You won't even get a review while the bot complains you messed the coding style.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: