返回术语表
代码审查与质量Popular

Code Smell

A surface indication in the source code that usually corresponds to a deeper problem in the system. Not a bug itself, but a sign that refactoring may be needed.

定义

The term "code smell" was coined by Kent Beck and popularized by Martin Fowler. Common code smells include: Long Methods (functions doing too much), God Classes (classes with too many responsibilities), Duplicate Code (copy-pasted logic), Feature Envy (methods that use another class's data more than their own), and Magic Numbers (unexplained numeric literals).

为什么重要

Code smells indicate potential maintainability problems. While they don't prevent code from working, they make it harder to understand, modify, and extend. Studies show that code with multiple smells has 2-3x higher defect rates. Addressing smells early prevents technical debt accumulation.

示例

A method has 200 lines and 15 parameters — this is a "Long Method" code smell. It suggests the method should be broken into smaller, focused functions.

相关术语

code smellwhat is code smellcode smells examplescode smell definition

使用diffray自动化代码审查

多智能体AI代码审查系统。自动发现bug、安全漏洞和架构问题。