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


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.


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


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

    exclusions = list(

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


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...