AI-Driven Code Refactoring: Using Graph Neural Networks to Enhance Software Maintainability

📅 2025-04-14
📈 Citations: 1
Influential: 1
📄 PDF

career value

156K/year
🤖 AI Summary
This work addresses the declining maintainability of software caused by high cyclomatic complexity and coupling in code refactoring. We propose the first end-to-end Graph Neural Network (GNN)-driven, semantics-aware refactoring method. By modeling Abstract Syntax Trees (ASTs) as graphs and integrating AST embeddings with static analysis, our approach automatically identifies and optimizes high-complexity, high-coupling code fragments. Unlike conventional rule-based or shallow-model approaches, ours is the first to systematically apply GNNs across the entire refactoring decision pipeline. Evaluated on 2 million Python code snippets, our method achieves 92% refactoring accuracy, reduces average cyclomatic complexity by 35%, and decreases coupling by 33%. These improvements significantly outperform established baselines—including SonarQube and decision tree–based methods—demonstrating both technical novelty and practical efficacy in automated, semantics-guided code refactoring.

Technology Category

Application Category

📝 Abstract
This study explores Graph Neural Networks (GNNs) as a transformative tool for code refactoring, using abstract syntax trees (ASTs) to boost software maintainability. It analyzes a dataset of 2 million snippets from CodeSearchNet and a custom 75000-file GitHub Python corpus, comparing GNNs against rule-based SonarQube and decision trees. Metrics include cyclomatic complexity (target below 10), coupling (target below 5), and refactoring precision. GNNs achieve 92% accuracy, reducing complexity by 35% and coupling by 33%, outperforming SonarQube (78%, 16%) and decision trees (85%, 25%). Preprocessing fixed 60% of syntax errors. Bar graphs, tables, and AST visuals clarify results. This offers a scalable AI-driven path to cleaner codebases, which is crucial for software engineering.
Problem

Research questions and friction points this paper is trying to address.

Using GNNs to improve software maintainability via code refactoring
Comparing GNN performance against rule-based and decision tree methods
Reducing code complexity and coupling with AI-driven refactoring
Innovation

Methods, ideas, or system contributions that make the work stand out.

AI-driven code refactoring with Graph Neural Networks
Uses abstract syntax trees for maintainability enhancement
Achieves 92% accuracy in complexity reduction