Augmenting Bug Localization with Part-of-Speech and Invocation

Yu Zhou, Yanxiang Tong, Taolue Chen, Jin HanInt. J. Softw. Eng. Knowl. Eng 2017

TL;DR

This paper tackles the challenge of efficiently locating buggy source code files within large software projects. The authors propose a novel approach that combines linguistic analysis of bug reports (specifically, part-of-speech tagging) with the structural relationships between code files (invocation relationships) to significantly improve bug localization accuracy. This work is important because it offers a more intelligent and effective way to help developers pinpoint bugs, reducing the time and effort spent on software maintenance.

What Problem Does This Paper Address?

Software maintenance, particularly fixing bugs, is a major bottleneck in the software development lifecycle. When a bug is reported, developers need to find the exact source code files responsible for the defect. This process, known as bug localization, can be incredibly time-consuming and tedious, especially in large codebases with thousands of files. Existing approaches often rely on simple text similarity between bug reports and source code, which can miss crucial contextual information. This paper aims to improve bug localization by leveraging richer information from both the bug report's language and the code's structure, going beyond basic keyword matching.

Methods

The proposed approach consists of two main modules and an adaptive strategy:

  • Module 1: Part-of-Speech (POS) Tagging and Weighted Similarity: This module enhances the traditional Vector Space Model (VSM) for information retrieval.
  • POS Tagging: Bug reports are processed to identify the part of speech (noun, verb, adjective, etc.) of each word. The authors hypothesize that certain POS tags, particularly nouns, are more indicative of buggy code.
  • Weighted Terms: Based on POS tags, terms in the bug report are assigned different weights. Nouns are given higher importance, reflecting their potential to directly name classes or methods. The summary of a bug report is also given more weight than its description.
  • Source Code Filtering: An adaptive parameter opt allows for filtering source code files. When opt is true, only class and method names are considered, aiming for Top 1 recommendation accuracy. When opt is false, more elements are retained for broader recommendations.
  • Similarity Calculation: The weighted bug report (query) is compared against source files (documents) using cosine similarity. File length is also incorporated as a factor to adjust similarity scores.
  • Module 2: Invocation-Based Calibration: This module further refines the ranking from Module 1 by considering how code files interact.
  • Invocation Corpus: A pre-generated corpus of method invocation relationships (callers and callees) is used.
  • Boosting Scores: If a bug report contains class names that map to "hitting files" (files ranked highly in Module 1), the scores of files invoked by these hitting files are boosted. This leverages the idea that related code components are often involved in the same bug.
  • Adaptive Strategy: The opt parameter allows users to choose between prioritizing a single, most accurate recommendation (Top 1) or a list of N recommendations. This caters to different developer needs.

Datasets

The authors evaluated their approach on six large-scale open-source projects:

  • AspectJ
  • Eclipse
  • SWT
  • ZXing
  • Birt
  • Tomcat

These datasets were previously used in related work [37], ensuring a fair comparison.

Key Insights and Ideas

  • Linguistic Nuance Matters: Not all words in a bug report are created equal. Identifying the grammatical role of words (like nouns) can significantly improve the precision of bug localization.
  • Code Structure is Key: Simply looking at text similarity is insufficient. The way code files call or depend on each other (invocation relationships) provides crucial context that can help uncover hidden bugs.
  • Adaptive Recommendations: Developers have different needs. Providing an option to prioritize a single best guess (Top 1) versus a list of potential candidates makes the tool more practical.
  • Summary vs. Description: The summary of a bug report is often more critical for initial localization than the detailed description, and this difference in importance can be leveraged.

Key Results

The proposed approach demonstrated significant improvements across all six projects compared to a baseline (rVSM model of BugLocator with a=0).

  • Top 1 Accuracy:
    • AspectJ: Improved from 22.73% to 39.86% (opt=true).
  • Eclipse: Improved from 24.36% to 30.76% (opt=true).
  • SWT: Improved from 31.63% to 46.94% (opt=true).
  • ZXing: Improved from 40% to 55% (opt=true).
  • Birt: Improved from 7.97% to 21.99% (opt=true).
  • Tomcat: Improved from 33.37% to 38.90% (opt=true).
  • Overall Performance: The MRR and MAP metrics generally showed improvements when opt was set to true, indicating better overall ranking quality.
  • Efficiency: While Module 2 adds some overhead, the overall approach, particularly Module 1, showed competitive or improved execution times compared to the baseline, especially for larger projects. The invocation corpus can be reused, making Module 2 more efficient over time.

Limitations and Future Work

  • Data Validity: The study primarily used Java projects and bug reports where keywords were often class or method names. The authors acknowledge that this heuristic might not hold for all programming languages or types of bug reports, and further studies are needed.
  • Invocation Corpus Completeness: While the invocation corpus is generated using tools like Eclipse JDT's Call Hierarchy, it's acknowledged that it might not capture all possible invocation files.
  • Future Work: The authors plan to integrate more features such as similar bugs, version history, and dynamic information. They also aim to refine Module 2 to reduce noisy files and expand the approach to datasets from commercial projects and unresolved bug reports to assess broader applicability.

Summary updated

BibTeX
@article{zhou2017augmenting,
  author = {Yu Zhou and Yanxiang Tong and Taolue Chen and Jin Han},
  title = {{Augmenting Bug Localization with Part-of-Speech and Invocation}},
  journal = {Int. J. Softw. Eng. Knowl. Eng.},
  year = {2017},
  doi = {10.1142/s0218194017500346},
}
Figure