You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改GitHub Super Linter的jscpd重复率检测阈值?

修改GitHub Super Linter的jscpd重复检测阈值

报错信息翻译:

ERROR: jscpd 检测到重复内容占比(7.3%)超过阈值(0%)
Error: ERROR: jscpd 检测到重复内容占比(7.3%)超过阈值(0%)
at ThresholdReporter.report (/node_modules/@jscpd/finder/dist/reporters/threshold.js:12:19)
at /node_modules/@jscpd/finder/dist/in-files-detector.js:82:26
at Array.forEach ()
at /node_modules/@jscpd/finder/dist/in-files-detector.js:81:28
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

修改方法有两种:

方法一:通过项目配置文件设置

  • 在项目根目录创建或编辑路径为.github/linters/.jscpd.json的配置文件
  • 在文件中添加或修改threshold字段,填入你需要的阈值(数字格式,无需加%符号),示例:
{
  "threshold": 8,
  "reporters": ["html", "console", "threshold"]
}

方法二:通过GitHub Actions工作流环境变量设置

  • 打开项目中的GitHub Actions工作流文件(通常位于.github/workflows/目录下,比如linter.yml)
  • 在调用github/super-linter的步骤里,添加JSCPD_THRESHOLD环境变量并设置目标阈值,示例:
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Super-Linter
        uses: github/super-linter@v5
        env:
          DEFAULT_BRANCH: main
          JSCPD_THRESHOLD: 8 # 此处设置自定义阈值

注意事项

  • 阈值设置建议匹配或略高于当前检测出的重复率(比如当前7.3%,设8%即可通过)
  • 确保配置文件路径正确,工作流中的环境变量需放在env区块内

内容的提问来源于stack exchange,提问作者Dean Schulze

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 19:02:48