Code Smells detectors
A Code smell is an interesting Software Engineering concept. According to Wikipedia, a Code Smell
“refers to any symptom in the source code of a program that possibly indicates a deeper problem.[1] According to Martin Fowler, “a code smell is a surface indication that usually corresponds to a deeper problem in the system“.[2] Another way to look at smells is with respect to principles and quality:[3] “smells are certain structures in the code that indicate violation of fundamental design principles and negatively impact design quality“.
Common code smells include:
- Application-level smells
- Duplicated code, Contrived complexity
- Class-level smells
- Large class, Feature envy, Inappropriate intimacy, Refused bequest, Lazy class/freeloader
- Method-level smells
- Too many parameters, Long method, Excessively long identifiers, Excessively short identifiers, Excessive return of data
- Excessive use of literals, Cyclomatic complexity, Downcasting
- Orphan variable or constant class
- Data clump
Code Smells detection tools
Some free code smell detection tools (which perform static code analysis) include:
- PMD (Java)
- JDeodorant (Java)
- JSNose (Javascript)
- FxCop (C# / .NET)
- StyleCop (C# / .NET)
- https://en.wikipedia.org/wiki/StyleCop
- NOTE: StyleCop works with source code, whereas FxCop works with compiled files
Conclusion
Most of these smells lower your code’s quality and maintainability. Be sure to include some of these detection tools on your development processes, as well as appropriate coding standards. Automatic noncompliance detection can be accomplished by adding these tools to your build process.
You can research more tools at https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis
References
- https://www.industriallogic.com/blog/smells-to-refactorings-cheatsheet/
- https://blog.codinghorror.com/code-smells/
- https://en.wikipedia.org/wiki/Code_smell
- Tufano, M.; Palomba, F.; Bavota, G.; Oliveto, R.; Di Penta, M.; De Lucia, A.; Poshyvanyk, D. (2015-05-01). “When and Why Your Code Starts to Smell Bad” (PDF). 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering (ICSE). 1: 403–414. doi:10.1109/ICSE.2015.59.
- Fowler, Martin. “CodeSmell”. martinfowler.com/.
- Suryanarayana, Girish (November 2014). Refactoring for Software Design Smells. Morgan Kaufmann. p. 258. ISBN 978-0128013977.
- https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis
- https://pmd.github.io/pmd-5.7.0/index.html
- https://github.com/tsantalis/JDeodorant
- https://github.com/saltlab/JSNose
- http://www.techrepublic.com/blog/software-engineer/maintain-code-consistency-with-microsoft-stylecop/