【问题标题】:Exclude source file line range from a single lintr (NOT all lintr)从单个 lintr 中排除源文件行范围(不是所有 lintr)
【发布时间】:2020-10-27 16:40:43
【问题描述】:

为了检查我的包的代码质量,我正在使用包lintr 使用命令

lintr::lint_package()

得到一个我想忽略的结果:

函数的圈复杂度应小于 15

如何忽略单个 lintr 的单个“误报”lintr 结果 (cyclocomp_linter) 对于文件(行号范围)?

编辑 1: 目前我正在使用此 .lintr 配置文件作为解决方法(通过完全禁用 lintr):

linters: with_defaults(
    cyclocomp_linter = NULL # instead of NULL I could use: cyclocomp_linter(16)
  )

【问题讨论】:

    标签: r lintr


    【解决方案1】:

    虽然它不能完全解决您的问题,但您可以使用 # nolint start 然后 # nolint end 包装该函数,以防止任何 linter 标记该函数。

    目前正在开发用于防止特定 linter 标记特定行集的语法 - 请参阅 https://github.com/jimhester/lintr/pull/660。这将出现在下一个主要的 lintr 版本 (3.0.0) 中。

    【讨论】:

    • 感谢您跟踪我的问题并在下一个版本中链接新功能,真是个好消息:-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 2019-08-19
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    相关资源
    最近更新 更多