Reputation: 5575
Is there a way to find duplicated (Copy/pasted code, repeated code) Kotlin code in Android Studio? I have Android Studio 4.0 but can't find this "Duplicated code fragment" option.
Are there any Android Studio plugins that do this job for Kotlin?
Upvotes: 4
Views: 1934
Reputation: 18022
You can install the sonarLint plugin.
It has many rules which are executed on source code to find possible issues like bugs or code smells.
This is done with the rules provided by default.
Other example of repetition:
Just need to install the sonarLint plugin in Preferences/Plugins:
A more advanced tool you could check is Gradle CPD plugin. This is a Gradle plugin to find duplicate code using PMDs copy/paste detection (= CPD). You can find information about how to install it and how to use it in the same readme of the repository. CPD supports Kotlin since v6.10.0.
Upvotes: 5