gpt4 book ai didi

python - 删除python中的重复代码

转载 作者:IT老高 更新时间:2023-10-28 21:13:10 25 4
gpt4 key购买 nike

python 中有没有用于重复代码检查器的库?我使用 python IDE,但在重构代码时遇到了麻烦。是否有任何可用的 python 库建议程序/项目中的重复代码?

更新:我根据其网站找到了克隆挖掘机,

我们已经在几个开源项目的源代码上测试了 Clone Digger。当前报告格式存在以下缺点:

Differences are highlighted using diff algorithm. This way of highlighting has nothing common with the abstract syntax tree based algorithm of comparing sequences of statements for similarity.

Class and function comments are taken into account during the computation of similarity, but they are not presented in the output. Therefore some clone pairs can look equal but marked as convergent.

还有比这更好的工具吗?

最佳答案

Pylint 可以检查类似/重复的代码:https://pylint.readthedocs.io/en/latest/technical_reference/features.html#similarities-checker

用法:

pylint --disable=all --enable=similarities src/yourcode/

关于python - 删除python中的重复代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10212442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com