This Is AuburnElectronic Theses and Dissertations

An Automated Rename Refactoring for Go

Date

2015-05-12

Author

Burgula, Venkatesh Reddy

Type of Degree

Master's Thesis

Department

Computer Science

Abstract

Our work focuses on building an automated Rename refactoring for Go. We show that the tool is effective by testing with a suite of 75 manually written unit test cases and running it on 50 large, open source Go projects from GitHub, which constitute 4 million lines of code. Our initial implementation used a simple, overly conservative precondition check, where conflicting identifiers in any ancestor or descendent scope flag an error. More robust alternatives have been proposed in the literature. We modified the refactoring tool to use one such alternative, which compares the references of all identifiers before and after refactoring. While this approach is more robust, it is also likely to be more time-consuming. Since refactoring is mostly used by experienced programmers who write clean code, we hypothesize that the more robust solution is unnecessary. To evaluate this hypothesis, we (1) compared the time and space requirements of the original solution and the more robust solution, (2) characterized the conditions under which the original solution produced false positives that were remedied by the more robust solution, and (3) performed an automated analysis of the identifier structure of the 4 million lines of code from GitHub to identify the frequency with which these false positives are likely to occur in practice. Our results show that the precondition-based approach has better performance than the reference-based approach. Our research also found that Go programmers rarely shadow variables, and most shadowing is due to only two variables names: ok and err