REFACTORINSIGHT: Enhancing IDE Representation of Changes in Git with Refactorings Information Zarina Kurbatova,∗ Vladimir Kovalenko,∗y Ioana Savu,z Bob Brockbernd,z Dan Andreescu,z Matei Anton,z Roman Venediktov,x Elena Tikhomirova,∗ Timofey Bryksin∗x ∗JetBrains Research, yJetBrains N.V., zDelft University of Technology, xHigher School of Economics fzarina.kurbatova, vladimir.kovalenko, elena.tikhomirova, [email protected], fa.i.savu-1, B.J.Brockbernd, D.Andreescu, [email protected], [email protected] Abstract—Inspection of code changes is a time-consuming task However, currently IDEs do not provide much insight into that constitutes a big part of everyday work of software engineers. the semantics of changes, and developers still need to put effort Existing IDEs provide little information about the semantics of into figuring out whether and how the changes influence the code changes within the file editor view. Therefore developers have to track changes across multiple files, which is a hard task behavior of code and whether changes across multiple files are with large codebases. connected to each other. Visualizing information related to the In this paper, we present REFACTORINSIGHT, a plugin for semantics of code changes is a promising way to augment the IntelliJ IDEA that introduces a smart diff for code changes in presentation of changes in an IDE. One way of doing it is Java and Kotlin where refactorings are auto-folded and provided to separate the changes that represent refactorings from such with their description, thus allowing users to focus on changes that modify the code behavior like bug fixes and new features. changes that modify the behavior of code. Refactoring is a REFACTORINSIGHT supports three usage scenarios: viewing fundamental practice in software development and consists in smart diffs with auto-folded refactorings and hints, inspecting changing code without affecting its behavior [4]. Leppanen refactorings in pull requests and in any specific commit in the et al. interviewed software developers about the role and im- project change history, and exploring the refactoring history portance of refactoring [5]. The authors show that developers of methods and classes. The evaluation shows that commit processing time is acceptable: on median it is less than 0.2 are cautious of introducing new defects during refactoring and seconds, which delay does not disrupt developers’ IDE workflows. emphasize the importance of careful checking of such kind of REFACTORINSIGHT is available at https://github.com/ changes. These findings suggest that separating refactorings JetBrains-Research/RefactorInsight. The demonstration video is from other changes could be a promising developer assistance available at https://youtu.be/-6L2AKQ66nA. technique. Several refactoring-aware tools have been proposed to help I. INTRODUCTION developers during the inspection of code changes. Some of Inspecting code changes is a daily routine for software the tools are implemented as plugins for the Eclipse IDE and, engineers. Improving this procedure and its efficiency has been sadly, are limited in the number of refactorings they are able a focus of many efforts [1], [2], [3]. For example, developers to detect [6], [7]. Other tools are implemented as plugins to examine changes made by their colleagues to search for the Google Chrome browser and provide information about possible defects, check if the code follows project conventions, performed refactorings in changes on GitHub. RAID [8] can suggest better solutions and share the knowledge with the detect only 13 refactoring types in commits and pull requests, team [3]. Manual inspection of a large number of changes may while Refactoring Aware Commit Review works [9] only with be challenging. To reduce the cognitive load on developers, it commits. could be useful to simplify the process of inspecting changes We present REFACTORINSIGHT, a plugin for IntelliJ arXiv:2108.11202v1 [cs.SE] 25 Aug 2021 by presenting them in a more structured and compact way. IDEA [10] that auto folds refactorings in code diffs in Java A lot of features in modern IDEs are designed to boost and Kotlin and shows hints with their short descriptions. developers’ productivity. For example, code completion helps Also the plugin allows users to view a list of performed developers to write code faster and make fewer errors through refactorings in any specific commit or pull request as well reduced typing, while code folding1 helps developers to main- as the refactoring history for methods and classes. To detect tain focus by collapsing irrelevant code elements. Some of refactorings, our tool relies on RefactoringMiner [11], which such productivity-enhancing features are related to the process demonstrates the highest accuracy among existing approaches of reviewing code changes. For example, IntelliJ IDEA allows as shown in [11]. REFACTORINSIGHT is published in the its users to explore the change history of files or pieces of JetBrains plugin repository3. Its source code is available on code2. GitHub4. 1Code folding in IntelliJ IDEA: https://www.jetbrains.com/help/idea/ 3REFACTORINSIGHT in the plugin repository: https://plugins.jetbrains.com/ working-with-source-code.html#code folding plugin/14704-refactorinsight 2Explore change history in IntelliJ IDEA: https://www.jetbrains.com/help/ 4REFACTORINSIGHT on GitHub: https://github.com/JetBrains- idea/viewing-changes-information.html#changes history Research/RefactorInsight II. BACKGROUND TABLE I REFACTORING TYPES SUPPORTED BY REFACTORINSIGHT. Existing research suggests that developers benefit from refactoring-aware tool support in code review. Kim et al. [12] Java, Kotlin Java interviewed developers from Microsoft about the challenges Rename Variable/Method/Class Merge Variable/Parameter/Field and benefits of refactorings. One of the findings of the study Rename Parameter/Field Change Package Extract Variable/Method/Class Parameterize Variable is that refactoring may entail merge conflicts, regression bugs, Extract Interface/Superclass Extract Subclass impeded code review, and other risks. Besides, the developers Extract And Move Method Replace Variable/Field with Field reported that changes that contain refactorings are more diffi- Move Method/Class Split Variable/Parameter/Field Move And Rename Method Move And Rename Field cult to review. Thus, the authors conclude that development Pull Up Method/Field Pull Up Field of tools that make inspection of refactorings isolated from Push Down Method/Field Push Down Field other changes can be a promising direction for future research. Inline Method Move And Inline Method Alomar et al. [13] conducted an industrial case study involving Change Variable/Parameter developers from Xerox to investigate the mechanisms of Change Field Type refactoring-aware code review. The results show that one of Add/Remove/Reorder Parameter the main challenges is that refactoring changes are interleaved with bug fixes and new features. The reviewers need to make an effort to separate the changes in code logic and behavior- GitHub with information about performed refactorings. To preserving changes. detect refactorings in code changes, RAID relies on RefD- iff [14] that currently supports the detection of 13 refactor- There have been proposed several tools for automatic detec- ing types in code changes in Java, C, JavaScript, and Go. tion of refactorings in code changes [11], [14]. Tsantalis et al. The tool does not detect low-level refactorings that relate presented a standalone library called RefactoringMiner [11]. to variables. Another extension for Google Chrome called It demonstrates 99.6% precision and 94% recall, which are Refactoring Aware Commit Review [9] relies on the above- the highest results among other approaches, as shown in its mentioned RefactoringMiner library [11] to detect refactorings evaluation. The tool supports the detection of 40 refactoring and highlights them in commits on GitHub. The extension types. It analyzes the commit history using a statement match- works only with commits and as well as RAID works only in ing algorithm and refactoring detection rules, and provides a the Google Chrome browser. list of refactorings with descriptions for each commit. Each description contains information about code elements involved III. IMPLEMENTATION in the refactoring and their code ranges before and after the Some users prefer to review pull requests from GitHub refactoring. RefactoringMiner’s output is programmatic, but, within their IDE because it minimizes the context switches be- if integrated into existing tools that support working with Git, tween the IDE and the browser and therefore saves time [17]. can augment diffs and history, significantly saving developers’ Our solution is implemented as an IntelliJ IDEA plugin code inspection time. RefactoringMiner is also limited to that processes pull requests and the project Git history and working with Java projects only. We reduced both usability integrates refactoring reports in file diffs. REFACTORINSIGHT limitations, as we show in Section III. detects 40 types of refactorings in Java code changes and There is a number of working plugins for Eclipse IDE [7], 19 types of refactorings in Kotlin code changes. To save [15], [16], [6] and extensions for Chrome which visualize processing time, all information about refactorings detected refactoring information in Git diffs. Let’s have a brief overview in a project is stored locally. of their functionality. Ge et al. presented
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-