Why you should care
Private methods that are never executed are dead code: unnecessary, inoperative code that should be removed. Cleaning out dead code decreases the size of the maintained codebase, making it easier to understand the program and preventing bugs from being introduced.
How we detect
CAST Highlight counts one occurrence each time a private method is never used.
class toto { private fun meth1() { // +1 VIOLATION : meth1 is never used val newSourcePath = projectRoot.resolve("src/${asRelativePath()}").canonicalFile.invariantSeparatorsPath return 0 } private fun asRelativePath(): String = // +0 VIOLATION : asRelativePath is used by the method meth1 if (scope.isBlank()) name else scope.replace('.', '/') + '/' + name }
References
![5362](https://doc.casthighlight.com/wp-content/uploads/2018/02/map-shadow.png)
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.