从单个lintr中排除源文件行范围并非所有lintr

问题描述

要检查我的软件包的代码质量,我正在使用lintr软件包,使用命令

lintr::lint_package()

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

函数的圈复杂度应小于15

如何忽略单个lintrcyclocomp_linter)的单个“假阳性” lintr结果 文件(行号范围)?

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

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

解决方法

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

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