Are machine programming systems using right source-code measures to select code repositories?

Niranjan Hasabnis

Abstract

Machine Programming (MP) systems rely on large-scale open-source repositories to learn patterns for code completion, bug detection, and optimization. Currently, researchers frequently use GitHub stars as a primary filter for data quality, assuming popularity correlates with technical excellence. This paper introduces GitRank, a framework that evaluates repositories using traditional software engineering metrics such as cyclomatic complexity, style error density, and security vulnerabilities. Through experiments with the ControlFlag MP system, the study demonstrates that popularity is an unreliable proxy for code quality and that selecting training data based on rigorous quality metrics significantly improves the performance of MP models.

Introduction

Machine Programming (MP) systems—including tools like GitHub Copilot and Intel’s ControlFlag—have the potential to revolutionize software development by automating debugging and code generation. However, these systems are susceptible to the "Garbage In, Garbage Out" principle: if the training data contains bugs, poor coding style, or security flaws, the AI will likely learn and propagate these defects.

To mitigate this, the research community often employs a "star filter," assuming that repositories with a high number of GitHub stars represent high-quality code. This paper challenges that assumption, investigating whether actual software quality metrics (e.g., maintainability and error density) serve as better predictors for MP system performance than mere popularity.

The GitRank Framework

To systematically evaluate repository quality, the author developed GitRank. This framework categorizes repository health into three distinct dimensions:

  1. Quality: This includes average cyclomatic complexity (measuring code logical density), style error density, and the density of security vulnerabilities (categorized by severity levels).
  2. Maintainability: This is calculated using the "Maintainability Index"—a composite metric involving Halstead volume and lines of code—alongside activity metrics like the frequency of closed issues, pull requests, and commits.
  3. Popularity: The traditional metrics of stars, forks, and subscribers.

By decoupling these factors, GitRank allows researchers to identify repositories that are technically sound, regardless of their social media-like popularity.

Experimental Methodology

The study utilized ControlFlag, an MP system designed to detect typographical errors and anomalies in C++ code. The evaluation involved two primary experiments:

  • Experiment 1 (Quality Impact): 500 C++ repositories with at least 100 stars were ranked via GitRank. These were split into "high-quality" ($D_{t1}$) and "low-quality" ($D_{b1}$) groups to observe if technical metrics influenced ControlFlag’s error-detection capabilities.
  • Experiment 2 (Popularity Impact): High-starred repositories were compared against a set of 250 low-starred repositories (fewer than 100 stars) to determine if the "star filter" actually improved model performance.

The models were tested against the microsoft/DirectXTex repository, which served as a ground truth for measuring pattern coverage and anomaly detection.

Key Insights and Results

The "Star Trap"

The research found that high popularity does not guarantee high-quality code. Qualitative analysis revealed that even top-ranked, highly-starred repositories contained "bad" patterns, such as assignments inside conditional statements (e.g., if (x = 5)), which can lead to logical errors.

GitRank vs. Stars

GitRank’s quality measures showed a clear positive correlation with MP system performance. In Experiment 1, the high-quality dataset ($D_{t1}$) outperformed the lower-ranked dataset ($D_{b1}$) in coverage tests and successfully identified 4 genuine anomalies in the evaluation repository, whereas the lower-quality set identified none.

Conversely, Experiment 2 showed no clear advantage for high-starred repositories. In several tests, the low-starred repositories provided better results, reinforcing the conclusion that stars are an unreliable metric for training data selection.

Security and Style

Despite being popular, "low-quality" GitRank repositories exhibited significantly higher densities of security warnings and style errors compared to "high-quality" ones. This suggests that popular repositories often prioritize feature velocity or community engagement over rigorous code standards, making them potentially dangerous for training AI models.

Discussion and Limitations

The paper suggests that "peer-reviewed" patterns—those that appear consistently across diverse, high-quality repositories—are the most reliable for training. While ControlFlag showed some robustness to noise (such as compilation issues), its core anomaly detection logic was significantly swayed by the structural quality of the training data.

Limitations: * The study focused on a single MP system (ControlFlag) and one language (C++). * The metrics in GitRank, while based on common software engineering practices, have not yet been optimized specifically for the needs of Large Language Models (LLMs). * The data was limited to GitHub, and dynamics might differ on other platforms.

Conclusion

This research highlights a critical oversight in current MP data collection strategies. By demonstrating that popularity is not a substitute for quality, the author advocates for a shift toward more rigorous, metric-based data selection. Future work will involve investigating which specific quality metrics most influence different types of MP systems and expanding the GitRank framework to support the next generation of AI-driven coding tools.

Summary updated

BibTeX
@inproceedings{hasabnis2022are,
  author = {Niranjan Hasabnis},
  title = {{Are machine programming systems using right source-code measures to select code repositories?}},
  booktitle = {MaLTeSQuE@ESEC/SIGSOFT FSE},
  year = {2022},
  doi = {10.1145/3549034.3561176},
}
Figure