-
Notifications
You must be signed in to change notification settings - Fork 193
Description
Hi,
I found a few issues with expectation_lint()
:
> lintr:::expect_lint("x <- 1", NULL) # markers displayed!
> lintr:::expect_lint("x <- 1\n", NULL) # markers displayed!
Error: returned ...
> lintr:::expect_lint("x <- 1\n\n", NULL) # markers displayed!
Error in stop(exp) : bad error message
> lintr:::expect_lint("x <- 1", "superfluous")
Error: did not return 1 lints as expected from content:x <- 1
> lintr:::expect_lint("x <- 1\n", "superfluous")
As expected
> lintr:::expect_lint("x <- 1\n\n", "superfluous")
Error in stop(exp) : bad error message
-
Markers displayed:
When running tests, I expect no lint markers to be displayed in Rstudio (or other IDEs). Simply replacingprint(lints)
bylints
inexpectation_lint()
fixes this issue. -
Bad error message:
This second problem is due toexpectation_lint()
passing a "msg" containing more than one element totestthat::expect()
; thelints
variable contains more than one lint. In addition, the name of the linters are supposed to be shown, but since I am using the default linters (using...
), no linter name is shown. Personally, I would drop this information as long as the details of the lints (which contain the linter name) are shown.
In the case wherecheck=NULL
, "msg" could be:
paste0("Got ", length(lints), " lints instead of none!\n", paste0(lints, collapse="\n"))
In the case where check="superfluous"
, "msg" could be:
paste0("Got ", length(lints), " lints instead of ", length(checks), "!\n", paste0(lints, collapse="\n"))
That's it! Cheers,
Florent
PS/ The sofware versions used are:
- R 3.2.5
- RStudio 1.0.136
- lintr development version (23/02/2017)