← Latest papers
💻 computer science

SmellBench: Towards Fine-Grained Evaluation of Code Agents on Refactoring Tasks

This paper introduces SmellBench, a new benchmark designed to evaluate code agents on refactoring tasks by injecting real-world code smells, revealing that current top-performing models struggle with cross-file understanding and achieve only moderate success in eliminating these maintainability issues.

Original authors: Fake Lin, Binbin Hu, Xi Zhu, Ziwei Zhao, Zhi Zheng, Ziqi Liu, Zhiqiang Zhang, Jun Zhou, Tong Xu

Published 2026-06-05
📖 5 min read🧠 Deep dive

Original authors: Fake Lin, Binbin Hu, Xi Zhu, Ziwei Zhao, Zhi Zheng, Ziqi Liu, Zhiqiang Zhang, Jun Zhou, Tong Xu

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Picture: The "Messy Room" Problem

Imagine you have a very smart robot assistant (a Code Agent) that can write code, fix bugs, and organize files. You ask it to clean up a messy room (refactor code).

Most tests for these robots only ask: "Did you move the chair so you can walk through the door?" If the robot moves the chair and you can walk, the test says "Pass!"

But the paper argues this isn't enough. The robot might have moved the chair, but in doing so, it knocked over a lamp, left a pile of clothes on the floor, and blocked the window. The room works (you can walk), but it's a disaster to live in long-term. This is what developers call "Code Smells"—clunky, messy, or poorly organized code that works today but will cause headaches tomorrow.

SmellBench is a new test designed to see if these AI robots can actually clean up the mess without making it worse, rather than just checking if the door is still open.


How They Built the Test (The "Controlled Mess" Factory)

The researchers realized that finding real-world examples of messy code is like trying to find a specific grain of sand on a beach. It's hard, and the mess is often mixed with other things (like new features or bug fixes).

So, they built a factory to create perfectly controlled messes:

  1. The Clean Room: They started with 7 famous, clean, well-organized Python projects (like pandas or numpy). Think of these as pristine, perfectly organized libraries.
  2. Injecting the Smell: Instead of waiting for a mess to happen naturally, they used an AI to intentionally mess up the code. They injected 7 specific types of "smells" (like a "God Class" that tries to do too many things, or "Dead Code" that is never used).
  3. The Ground Truth: Because they created the mess, they know exactly what the clean version looked like before they broke it. This is their "Answer Key."

The Result: A dataset of 294 specific "messy" scenarios, ranging from easy to very hard, covering 7 different types of code ugliness.


The 7 Types of "Code Smells" (The Messy Room Scenarios)

The paper focuses on 7 specific ways code gets messy. Here is how they translate to everyday life:

  1. Feature Envy: A person (a function) who is constantly borrowing things from their neighbor's house instead of using their own. Analogy: You keep borrowing your neighbor's hammer because you don't have one, even though you have a toolbox.
  2. God Classes: A single person trying to do every job in the company (cooking, accounting, security, and HR). Analogy: One janitor trying to fix the plumbing, teach math, and bake bread all at once.
  3. Data Clumps: Carrying the same group of items (keys, wallet, phone) together everywhere you go, even when you only need one. Analogy: Carrying a whole toolbox just to change a lightbulb.
  4. Shotgun Surgery: You want to change one small thing (like the color of the walls), but you have to go to 10 different rooms to do it. Analogy: Changing the price of a product requires you to update the receipt, the website, the invoice, and the shipping label separately.
  5. Dead Code: Furniture in a room that no one ever sits on or uses. Analogy: A bookshelf full of books you read 10 years ago that you never touch.
  6. Interface Segregation: A remote control with 50 buttons, but you only ever use 3. Analogy: A menu at a restaurant that forces you to order a steak, a salad, and a dessert just to get a glass of water.
  7. Deep Inlining: A recipe that says "Do step 1, which means do step 2, which means do step 3..." all written in one giant paragraph. Analogy: A map where the directions are written inside the directions, making it impossible to follow.

The Experiment: Can the Robots Clean Up?

The researchers gave these messy code snippets to 2 popular AI agents (OpenHands and Qwen Code) powered by 6 different "brains" (Large Language Models like Claude, GPT, and DeepSeek).

The Rules:

  • The AI had to find the mess.
  • The AI had to fix the mess.
  • The AI had to make sure the code still worked (passed the tests).

The Results (The Shocking Part):
Even the best combination of AI (Qwen Code + Claude Sonnet 4.5) only got a score of 50.34% on eliminating the smells.

  • The "Door" Test (Functional Correctness): The robots were great at this. Most of them kept the "door open" (the code still ran). They passed the basic tests 80-90% of the time.
  • The "Clean Room" Test (Refactoring Quality): The robots failed here. They often fixed the immediate problem but left the room messy. They struggled to see the big picture, especially when the mess involved multiple files (like the "Shotgun Surgery" smell).

Key Finding: The AI is good at making code work, but it is currently bad at making code beautiful and maintainable.


Why This Matters

The paper concludes that we cannot just ask AI, "Did the code run?" We need to ask, "Is the code clean?"

They introduced a new way to grade the AI using a "Judge AI" that looks at:

  1. Did it pass the tests? (Does the door open?)
  2. Did it find the right spot to fix? (Did it look in the right room?)
  3. Is the code actually better? (Is the room tidy?)

The Bottom Line: Current AI agents are like enthusiastic interns who can move furniture but often leave a trail of dust. They are getting better, but they still have a long way to go before they can be trusted to professionally "refactor" (clean up) complex software systems on their own.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →