GitRank: A Framework to Rank GitHub Repositories

Niranjan Hasabnis

Introduction

The rapid advancement of Artificial Intelligence for Software Engineering (AI4SE) has led to an increased reliance on open-source repositories for training models capable of code generation, bug fixing, and documentation. However, GitHub remains a "wild west" regarding code quality. High popularity, often measured by "stars," does not necessarily correlate with code that is secure, maintainable, or well-structured. To address this, we present GitRank, an open-source framework designed to objectively rank GitHub repositories by aggregating metrics across three key pillars: code quality, maintainability, and popularity.

Problem Statement

Currently, GitHub lacks a native, objective quality score. While individual metrics like cyclomatic complexity or the Maintainability Index (MI) are standard in software engineering, there is no publicly available, automated framework that aggregates these into a comparative ranking system. This gap makes it difficult for researchers to filter out low-quality noise from datasets, potentially leading to AI models trained on buggy or insecure code.

Methodology

GitRank operates through a two-phase pipeline designed for scalability and objectivity.

Phase 1: Metric Extraction

The framework utilizes a suite of established static analysis tools to gather data for every repository in a target list:

  • Quality: Evaluated using lizard for cyclomatic complexity, cpplint for style adherence, and FlawFinder for identifying security vulnerabilities categorized by severity.
  • Maintainability: Calculated using the Maintainability Index (MI) and repository activity metrics, such as commits per day and the rate of closed issues and pull requests (PRs).
  • Popularity: Aggregated via GitHub metadata, including subscribers, stargazers, and forks, using the GrimoireLab toolkit and GitHub’s REST APIs.

Phase 2: Scoring and Ranking

To ensure fair comparison across repositories of varying sizes, GitRank normalizes all values to a 0–100% range.

  • Normalization: Metrics like style errors are divided by the Lines of Source Code (SLoC) to calculate "error density," ensuring large projects are not unfairly penalized.
  • Weighting: The framework calculates a weighted average for Quality and Popularity. Maintainability weights are specifically tuned to emphasize recent activity, giving more weight to issues and PRs closed within the last month compared to those from previous years.
  • Final Score: The overall GitRank is the mean of the three category scores.

Experimental Evaluation

The framework was evaluated using a dataset of 500 randomly selected C++ repositories. After filtering out 12 repositories with technical peculiarities (such as non-standard file extensions), the analysis was conducted on 488 projects. The framework was implemented in approximately 700 lines of Python and designed to be highly parallelizable.

Key Results

  • Efficiency: For the 500-repo test set, Phase 1 (data extraction) was completed in 1 hour and 25 minutes across five machines. Phase 2 (scoring) was nearly instantaneous, taking only 0.1 seconds.
  • Ranking Efficacy: The framework successfully generated ranked reports showing clear differentiation between projects. For example, the StarRocks repository demonstrated a high quality score of 97.9, while other repositories showed a significant disconnect between their popularity and maintainability scores.
  • Resource Management: The scoring phase required minimal memory (1.5 KB), proving that once the heavy lifting of static analysis is complete, the ranking process is extremely lightweight.

Limitations and Future Work

While GitRank provides a robust starting point, several areas for improvement remain:

  • Language Support: The current implementation is limited to C/C++. Future work involves integrating static analysis backends for Python, Java, and other popular languages.
  • Noise Reduction: Static analysis tools can produce false positives. Future versions may allow users to adjust metric weights to mitigate the impact of "noisy" data.
  • Customization: A planned feature is a user-definable weighting system, allowing researchers to prioritize specific pillars (e.g., security over popularity) based on their specific research needs.
  • Downstream Validation: The ultimate goal is to validate GitRank by demonstrating that AI models trained on high-ranking repositories outperform those trained on baseline datasets.

Summary updated

BibTeX
@inproceedings{hasabnis2022gitrank,
  author = {Niranjan Hasabnis},
  title = {{GitRank: A Framework to Rank GitHub Repositories}},
  booktitle = {MSR},
  year = {2022},
  url = {https://openreview.net/forum?id=EWHEo6lprh},
}
Figure