Skip to content

expectation_lint() message and marker bugs #211

@fangly

Description

@fangly

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
  1. Markers displayed:
    When running tests, I expect no lint markers to be displayed in Rstudio (or other IDEs). Simply replacing print(lints) by lints in expectation_lint() fixes this issue.

  2. Bad error message:
    This second problem is due to expectation_lint() passing a "msg" containing more than one element to testthat::expect(); the lints 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 where check=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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions