开发者

What tools are there for suggesting potential refactorings [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I don't want tools for actually performing refactorings, but tools for finding and suggesting potential refactorings. Particularly tools for identifying blocks of code that are similar and could be merged into a utili开发者_运维百科ty functions.

The background here is that I've been asked to investigate reducing the code size of an embedded C system. This task seems to mostly break down into removing code that isn't needed (dead code) and merging code that is duplicated. The various lint like tools will find the dead code. But I still need a way of finding the duplicated code.


I'd suggest taking a look at PMD's Copy Paste Detector. While it defaults to Java code, it also supports c++, php, and ruby.

PMD does this on a lexical basis, and has a few options to ignore constants within code. Better code duplicate detectors build up an AST, and compare similar trees. The AST approach is better, as formatting and variable names don't effect the results.


PMD has already been mentioned. ACNP software has one that's commercial (but pretty cheap).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜