Formatting and formatting versions

I am currently participating in a team implementing a new version control system (Subversion) in my organization. There was a bit of debate about how to handle code formatting, and I would like to get other people's opinions and experiences on this topic.

Currently, we have ~ 10 developers who use different tools (due to licensing and preference). Some of these tools have automatic code formatting, while others do not.

If we allow blind checks, the code will look radically different every time someone checks. This will make things like diffs and merging difficult.

I spoke with several people and they mentioned the following solutions:

  • Use the same developer program with the same code formatting (in fact, this is not an option due to licensing)
  • Take a hook (client or server) that will automatically format the code before entering the repository
  • Manually format the code.

Regarding point 3, the concept is to never format the code and not have any standards. Now it is similar to what we are inclined to. I have little doubt about this approach, as this can lead to the fact that developers will spend a lot of time manually formatting the code.

If someone can provide some of their thoughts and experiences, that would be great.

Thanks,

Martin

+4
source share
4 answers

Do not allow tools / developers to automatically / manually reformat the code for aesthetic reasons only. The difference between the versions becomes a nightmare. Have a coding standard and try a toolbox to get new modules to match as much as possible. People modifying an existing module must adhere to the conventions used in this module, whether they like it or not.

+9
source

If # 1 is not a viable option, # 3 is probably your best bet. # 2 would make it quite difficult for individual developers to make the difference between a working copy and an existing file after they have checked it and run their own formatter on it at least once.

Option number 3 is mainly related to making people accustomed to habits - formatting the code is actually not so troublesome if everyone can get used to the same habit. The only code you need to format is what you create / touch; the rest will be formatted from verification.

+3
source

If you run a script that formats the code in the accepted format (and nightly builds that test this code every night), you can have a pre-commit hook for SVN checks that can enforce this standard.

However, option No. 3 is best, since it is easier to set formatting rules during development when developing rules.

+1
source

I do not know if this is a technology problem or a cultural problem.

Even if they all use the same tool, most tools let you change the standard formatting rules that apply to text.

Define some standards, enforce them through peer review and a cultural understanding of why this is important.

0
source

Source: https://habr.com/ru/post/1306180/


All Articles