Migrating a ray tracer from Java and Groovy to Kotlin (part 2)
October 06, 2018
I continued to work on migrating my ray tracer to Kotlin.
I switched the gradle build script to Kotlin. In the
build.gradle.kts syntax completion is available for gradle tasks because everything is statically typed now. It took a while to get used to, but in the end it is worthwhile.
One very useful tool for Kotlin development is detekt, a static code analysis tool that operates on the abstract syntax tree of the Kotlin compiler.
Detekt found a lot of issues with my code. I really expected a lot of issues, because the code in some places is very experimental, contains bugs and not tested 100%. Due to time constraints I am not able to work on the ray tracer a lot in my spare time.
You can run the analysis with
$ gradlew detekt
And detekt creates a long report that ends with the following lines.
Overall debt: 11h 20min Complexity Report: - 14,916 lines of code (loc) - 10,966 source lines of code (sloc) - 7,926 logical lines of code (lloc) - 1,261 comment lines of code (cloc) - 1,765 cyclomatic complexity (mcc) - 1,236 cognitive complexity - 97 number of total code smells - 11% comment source ratio - 222 mcc per 1,000 lloc - 12 code smells per 1,000 lloc Project Statistics: - number of properties: 2178 - number of functions: 882 - number of classes: 233 - number of packages: 37 - number of kt files: 244
Very useful, indeed.