What Is a Code Smell?

A code smell is a surface-level indicator in source code that suggests a deeper problem in the design, without necessarily being a bug itself.

Published October 8, 2026

A code smell is a surface-level indicator in source code that suggests a deeper problem in the design, without necessarily being a bug itself.

Why it exists

  • Certain patterns — very long functions, duplicated logic, deeply nested conditionals, classes that do too many unrelated things — tend to correlate with harder-to-maintain code
  • These patterns aren't incorrect by themselves, but they're a signal worth investigating

How to apply it

  • Treat a code smell as a prompt to look closer and consider refactoring, not an automatic requirement to change something
  • Common smells include duplicated code, long parameter lists, large classes, and excessive use of global/shared state

FAQ

Is a code smell always a bug?

No — code with a smell can work perfectly correctly; the term describes a maintainability risk, not a functional defect.

More General articles