Tag Archives for " ReSharper "

Christmas Holidays and Automatic Code Formatting

How often do you talk about code formatting during code reviews?

Probably too often...

Have you considered to define rules for your team to automate code formatting?

I am sure you did.

You probably came to the conclusion that it is going to take too much time to  find an agreement between all members of your team. You are also aware that doing a massive clean up of your legacy code base is likely going to touch all the files inside your solution and will cause crazy and complicated merge conflicts to resolve. It's just too much pain to even think about it, isn't it?

I attempted this few times in past projects unsuccessfully... 

So let me explain the process I decided to follow this time...

It turns out that the week between Christmas and the New Year is a perfect time for cleaning 馃檪

There are usually very few pull requests left open and most of your colleagues are out of the office.

For the first time in my career, I finally managed to complete a full clean-up of the code base I am currently working on (Redgate ReadyRoll) and put an end to any discussions about code formatting. More importantly, we can now clean-up any code with a single keyboard shortcut. 

This is awesome and a massive time saver for the team!

Andrea, this is cool, but how did you do it?
Who approved your changes if nobody was in the office?

Few weeks before Christmas, I ran a full R# clean-up of our solution and created a pull request for it. 

Full Cleanup to agree on code formatting rules

As you can read from the text of the pull request, the main goal was to identify formatting options we didn't like and try to come up with a list of all the changes we wanted to make.

The entire team agreed that consistency is more important than achieving 100% agreement.

I was pleased to see that we managed to get an acceptable level of agreement fairly quickly.

The main point of discussions were:

Finally, during Christmas I made the changes...

Pull Requests to implement Code Formatting rules

Overall it took me about 3 days of work to make all the changes.

Yes, it takes a bit of patience but I believe it's worth.

My recommendation would be to starting using code clean-up tools immediately when you start a new project so that you can avoid this pain in the future.

If you are not in this position, you now know what to do next Christmas 馃檪

You can learn more about code cleanup with R# at the following address:
Code Style and Cleanup

Happy formatting!

>