This question is not so much technical than looking for advise to find the proper approach that will not hurt.
Assuming the following:
- We have a big application developed in Perl.
- We want to start using perltidy on the commandline to impose uniform style/rules for formatting
- We have many branches that we do not know exactly when will be merged to the master branch. They should be tidied too somehow before or after the merge
- We want to avoid any conflicts in commits caused by formating.
I thought about starting to format on subroutine level, but I do not find such feature in perltidy. There is another feature "Skipping Selected Sections of Code", but now I may want the opposite -- format only selected sections of code. The idea is that when a developer touches part of the code he/she will tidy only the modified part.
The best would be to find a way to format the whole project once without disrupting the development cycle and making sure we do not break any part of the code (during merging). We have unit tests, but some parts of the code may still be uncovered.
Let me also clarify that everybody in the team uses potentially different editor. For example I use Sublime Text 3 with SublimePerlTidy. Other people use Kate or Atom or VIM. A proper approach seem to be to format only pieces of code that we touch as pointed by @xxfelixxx (Thank you!)
As for my own perltidy usage, using emacs, I tend to tidy up small chunks of code at a time by highlighting a region ( creating a mark with
C-space
, navigating to highlight a region, and then runningM-p
which I have mapped toperltidy-region
. To get this to work, installperltidy
and add the following to your.emacs
file: