Analyzing and Visualizing Software Quality of Code in GitHub Repositories Using AST-Based Metrics
摘要
Context: High code quality is essential in software development, as it directly impacts readability, maintainability, reliability, security, and efficiency. Quality assessment becomes increasingly important as projects grow more complex and new developers are added. Problem: Tracking and maintaining code quality in growing projects with multiple contributors poses significant challenges, especially for development teams with limited resources. Method: This paper introduces a Python-based tool that automatically retrieves, analyzes, and visualizes software quality metrics for Python code files in user-selected GitHub repositories. Using Abstract Syntax Tree (AST) analysis, the tool calculates Halstead, Traditional, and Object-Oriented metrics on a per-file basis and supports visualizing these values across commits and pull requests. Result: The tool accurately calculates Halstead, LOC, Length of Identifier, and Cyclomatic Complexity metrics, with the results verified using manual calculations. However, the tool produces incorrect metric results for Fan-in, Fan-out, and inheritance-related OO metrics due to the lack of multi-file analysis. Conclusion: The tool’s ability to automate metric calculation, store results, visualize results, and integrate into GitHub workflows helps developers monitor code quality trends over time. Though currently limited to per-file analysis, the tool provides a foundation for continuous quality assessment, with the next step for adding multi-file analysis support discussed.