Empty functions and methods should be avoided

Why you should care

For maintainability aspect, it is not recommended to have empty functions, methods or classes, as it could decrease readability because readers need to guess whether it's intentional or not. Technology scope: ABAP, C#, Go, Groovy, Java, Kotlin, Scala, Swift. Note that for Java and Kotlin, this code insight also applies for classes.

CAST Recommendations

Check if the object is referenced. If not then remove it.

How we detect

This Code Insight counts one occurrence each time a function, a method or a class is found and that it doesn't contain any statement.

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.
For reference only. For the complete details please refer the original article
https://doc.casthighlight.com/alt_emptyartifact-code-contains-many-empty-functions-procedures-methods-modules/
Have more questions? Submit a request

Comments

Powered by Zendesk