Skip to main content
Luxian's Notes

Main navigation

  • Home
User account menu
  • Log in

Breadcrumb

  1. Home

coding

By luxian, 25 July, 2017

How to commit whitespace and coding standard changes in legacy code

The project I'm working on has inconsistency issues when it comes to coding style. Even though it's a Drupal project, it doesn't follow Drupal's coding standards and on top of that the .php files are saved using various character encoding and line endings. This forced me to develop a workflow that I use before changing legacy files which helped me to keep changes history readable.

Committing together a file encoding change, white-space conversion and a bug-fix will be a source of regret if you ever have to look at that diff again. Most likely you will pull your hair out trying to figure out what is a code change and what's only a code style fix. That's why I separate the coding standard fixes in a single commit before doing anything else. This commits will be easy to ignore when checking history and can provide a cleaner diff for the changes that follow.

The steps I follow are:

Tags

  • coding
  • git
coding

Pages

  • Contact
  • My tech
  • Wishlist
RSS feed
Powered by Drupal