I have a chunk of code about 1200 lines of code in my Activity. Is there a tool that watches through my code and finds some similar duplicate code that can be put in one method? Like this:
onCreate(){
image1.startAnimation(am1) ;
image2.startAnimation(am1) ;
.....
image1.startAnimation(am1) ;
image2.startAnimation(am1) ;
}
I want to put same code in one method, is there way to automatically spot duplicate codes?
Code replication is a two-step process. First, a code version is transferred from staging to the target instance, then it is activated on the target instance. You can run both steps as a single replication process, or run them separately. Running them separately can help you identify the source of failures.
Code Inspection: Duplicated code fragmentReports duplicated blocks of code from the selected scope: the same file or the entire project. The inspection features quick-fixes that help you to set the size of detected duplicates, navigate to repetitive code fragments, and compare them in a tool window.
To avoid the problem of duplicated bugs, never reuse code by copying and pasting existing code fragments. Instead, put it in a method if it is not already in one, so that you can call it the second time that you need it.
In computer programming, duplicate code is a sequence of source code that occurs more than once, either within a program or across different programs owned or maintained by the same entity. Duplicate code is generally considered undesirable for a number of reasons.
You can use sonarqube to find some similar, duplicate code http://androidhubb.blogspot.com/2019/04/sonarqube-android-how-to-use-sonarqube.html
you can push the repository to githup or gitlab or Bitbucket then use one of these sites to find some similar, duplicate code
*codecy
*codegrip
*codebeat
I started to use codebeat https://codebeat.co
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With