Skip to main content
QUICK REVIEW

[Paper Review] The Remarkable Role of Similarity in Redundancy-based Program Repair

Zimin Chen, Martin Monperrus|arXiv (Cornell University)|Nov 14, 2018
Software Engineering ResearchComputer Science40 references18 citations
TL;DR

This paper investigates the role of code similarity in redundancy-based program repair by systematically analyzing four similarity metrics—character, token, semantic, and structural—across 15 million code components. It demonstrates that similarity analysis can eliminate at least 90% of the search space, with TFIDF reducing it by up to 99.56%, and ranks the correct repair ingredient first in 4–33% of cases, especially when context is included.

ABSTRACT

Recently, there have been original attempts to use the concept of "code similarity" in program repair, suggesting that similarity analysis has an important role in the repair process. However, there is no dedicated work to characterize and quantify the role of similarity in redundancy-based program repair, where the patch is composed from source code taken from somewhere else. This is where our paper makes a major contribution: we perform a deep and systematic analysis of the role of code similarity during the exploration of the repair search space. We define and set up a large-scale experiment based on four code similarity metrics that capture different similarities: character, token, semantic and structure similarity. Overall, we have computed 56 million similarity score over 15 million source code components. We show that with similarity analysis, at least 90% of search space can be ignored to find the correct patch. Code similarity is capable of ranking the correct repair ingredient first in 4 - 33 % of the considered cases.

Motivation & Objective

  • To systematically characterize and quantify the role of code similarity in redundancy-based program repair.
  • To evaluate how different similarity metrics—character, token, semantic, and structural—impact repair search space reduction.
  • To investigate the effect of including contextual information (around the buggy statement) on similarity-based repair effectiveness.
  • To provide a principled, controlled analysis of similarity's role, isolating it from other repair factors like fault localization or patch validation.
  • To offer empirical evidence on the feasibility of using similarity to prioritize repair ingredients and avoid overfitting to plausible but incorrect patches.

Proposed method

  • Isolate similarity analysis as the sole component in a simplified redundancy-based repair process, removing randomness, fault localization, and validation to focus purely on similarity.
  • Define four similarity metrics: character (n-gram), token (AST-based), semantic (embedding-based), and structural (AST tree similarity) to capture diverse code similarities.
  • Construct 214 real-world repair tasks from actual commits, framing each as a ranking problem: rank candidate repair ingredients by likelihood of correctness.
  • Measure similarity between the removed buggy statement and candidate repair statements, and between their surrounding contexts.
  • Use TF-IDF, token, semantic, and structural similarity scores to rank repair candidates and evaluate their performance in placing the correct patch at the top.
  • Perform large-scale computation of 56 million similarity scores across 15 million code components to ensure statistical robustness.

Experimental results

Research questions

  • RQ1To what extent can code similarity reduce the search space in redundancy-based program repair?
  • RQ2How effective are different similarity metrics (character, token, semantic, structural) in ranking the correct repair ingredient?
  • RQ3Does incorporating the context around the buggy statement improve the effectiveness of similarity-based repair?
  • RQ4What is the impact of context-aware similarity on search space reduction and ranking accuracy?
  • RQ5How do the four similarity metrics correlate with each other and with repair effectiveness?

Key findings

  • Similarity analysis can reduce the repair search space by at least 91.87%, with a maximum reduction of 99.56% using the TFIDF metric.
  • The correct repair ingredient is ranked first in 4–33% of cases depending on the similarity metric, with TFIDF achieving the best performance at 30%.
  • Incorporating the method-level context around the buggy statement improves similarity-based ranking, reducing the search space by an additional 24% compared to context-less analysis.
  • TFIDF achieves the highest effectiveness, ranking the correct repair ingredient and its donor context in the top 1% of candidates in many cases.
  • The study confirms a strong correlation between purely syntactic similarity (e.g., token and character-level) and repair effectiveness, suggesting potential for hybrid similarity approaches.
  • Similarity-based ranking effectively avoids overfitting to plausible but incorrect patches by prioritizing semantically and structurally relevant code snippets.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.