Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio tool that spots duplicate or similar parts of code?

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?

like image 279
ERJAN Avatar asked Oct 17 '15 12:10

ERJAN


People also ask

How do you replicate a code?

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.

What is duplicated code fragment?

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.

How do you avoid repetition in code?

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.

What is duplicate source code?

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.


1 Answers

  1. 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

like image 91
Zahraa Resen Avatar answered Nov 14 '22 08:11

Zahraa Resen