`lintr::expect_lint_free()` not passing file exclusions

Problem

I am integrating lintr testing into an R package but I want to exclude the zzz.R file contained in the R directory for various reasons. When using lintr::expect_lint_free(exclusions = list("R/zzz.R")) it does not seem to properly exclude the exclusion, but if I use lintr::lint_package(exclusions = list("R/zzz.R")) it properly excludes the zzz.R file. See below.

Example

Below is a simple example illustrating differing results. You can also use this example pkg to reproduce this sample problem.

Question

Maybe I'm missing something but I thought expect_lint_free passed its arguments to lint_package? Is there different procedure for specifying files to exclude from linting when using lintr::expect_lint_free()? If this is a bug then I'll post an issue on Github but I wanted to make sure I wasn't overlooking some.

1 Like

With testthat tests are running in a working directory corresponding to where the testtfiles are. i.e tests/testthat

If I try

lintr::expect_lint_free(exclusions = list("../../R/zzz.R"))

this works.

And with this too

  lintr::expect_lint_free(
    exclusions = list(
      rprojroot::find_package_root_file("R/zzz.R")
      ))

I think there is a bug here or at least something to be improved because it does not seems right to take care of that. :thinking:

One thing that make me think of a bug is the fact defining exclusions in option file does not work either

# .lintr file
exclusions: "R/zzz.R"

see ?read_setting about this option

You need to exclude in absolute path, but lintr should handle relative path I guess

3 Likes

There is an issue that seems related but it is said to be fixed


It could be related as not fixed for expect_lint_free...