8.4 Code not in Google Style

You will occasionally encounter files in your codebase that are not in properGoogle Style. These may have come from an acquisition, or may have been writtenbefore Google Style took a position on some issue, or may be in non-Google Stylefor any other reason.

8.4.1 Reformatting existing code

When updating the style of existing code, follow these guidelines.

  • It is not required to change all existing code to meet current styleguidelines. Reformatting existing code is a trade-off between code churnand consistency. Style rules evolve over time and these kinds of tweaks tomaintain compliance would create unnecessary churn. However, if significantchanges are being made to a file it is expected that the file will be inGoogle Style.
  • Be careful not to allow opportunistic style fixes to muddle the focus of aCL. If you find yourself making a lot of style changes that aren’t criticalto the central focus of a CL, promote those changes to a separate CL.

8.4.2 Newly added code: use Google Style

Brand new files use Google Style, regardless of the style choices of other filesin the same package.

When adding new code to a file that is not in Google Style, reformatting theexisting code first is recommended, subject to the advice in??.

If this reformatting is not done, then new code should be as consistent aspossible with existing code in the same file, but must not violate the styleguide.