{'fraction_non_alphanumeric': 0.017994858611825194, 'fraction_numerical': 0.002570694087403599, 'mean_word_length': 5.569620253164557, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Unsupervised Learning For Refactoring Pattern Detection

Software refactoring changes the structure of a program without modifying its external behavior, generally intending to improve software quality attributes. However, refactoring is a complex activity and, many times, a composition of refactorings is necessary. Besides, some code elements are refactored similarly, considering the kind and frequency of refactorings applied. Works in the refactoring literature usually investigate the impact and understanding of an individual refactoring, neglecting that developers have to apply more than one refactoring operation to reach their goals. There is a lack of studies to identify and characterize refactoring patterns. To fulfill this gap, this work explores the use of unsupervised learning, particularly cluster analysis, to group elements (Java classes) that are refactored similarly in software repositories. We used a total of 1435 projects and applied the K-Means algorithm to group classes that received the same refactoring with the same frequency. We obtained a set of seven clusters. Then, the main refactoring compositions associated with each cluster are analyzed to identify the corresponding pattern. Each pattern is described and also characterized using a set of metrics. The great majority of refactoring compositions include only one kind of refactoring, applied with low frequency. If we consider compositions including more than one type of refactorings, combinations of Extract Superclass and Pull Up Method are the most frequent.