【问题标题】:Find duplicate blocks of code in a Python file在 Python 文件中查找重复的代码块
【发布时间】:2022-07-07 22:13:30
【问题描述】:

有没有办法使用 pylint 或 flake8 为 Python 同一文件中的重复块/代码行获取警告?

我知道对于 pylint R0801 会警告不同文件中的重复代码,但如果同一文件中存在大量(即 > 3 个连续行)代码重复,我也希望收到警告。

【问题讨论】:

  • 寻求关于 SO 的工具建议是题外话,因为它往往会鼓励垃圾邮件的答案
  • 删除了工具请求 - 任何建设性意见?

标签: python lint pylint flake8 software-quality


【解决方案1】:

静态代码分析器支持在同一 Python 文件中查找重复代码,例如 PyCharm、PyLint、Flake8 和 mypy。

Here is more info about this feature in PyCharm.

【讨论】:

    猜你喜欢
    • 2010-09-07
    • 1970-01-01
    • 2015-04-23
    • 2023-04-04
    • 1970-01-01
    • 2017-02-21
    • 2015-07-19
    • 2020-09-30
    • 1970-01-01
    相关资源
    最近更新 更多