Automated-refactoring tool to find similar duplicate source code for Java/Javascript?
<p>I'm looking for a tool to find duplicate or <strong>similar</strong> code of Java/Javascript.  I can't tell the exact definition of "<strong>similar</strong>", but I wish the tool is smart enough and give me advices to refactor the code,  e.g.,   </p>

<p>(1) class A and class B have imilar methods (e.g., there 5 methods have same method name, arguments and similar implementation appearing in both classes), then it should advise to move these similar methods into a base class.<br>
(2) class A has similar code lines at different places multiple times, the tool should advise to move these similar code lines into a single method. </p>

<p>I tried <a href="http://pmd.github.io/" rel="noreferrer" title="PMD">PMD</a> which can find duplicate code lines but it's not clever enough. It did not find out those <strong>similar</strong> source codes which is widely spreaded in one my projects.  </p>

<p>Is there such tool? </p>