Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expectation_lint() message and marker bugs #211

Closed
fangly opened this issue Feb 23, 2017 · 1 comment
Closed

expectation_lint() message and marker bugs #211

fangly opened this issue Feb 23, 2017 · 1 comment

Comments

@fangly
Copy link
Contributor

fangly commented Feb 23, 2017

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)
@fangly fangly changed the title expect_lint() message and marker bugs expectation_lint() message and marker bugs Feb 23, 2017
fangly added a commit to fangly/lintr that referenced this issue Mar 8, 2017
* do not display markers when check is NULL
* fixed malformed error messages
* more consistent errors messages
* check validity of Lint fields in 'checks'
* return invisible(NULL), just like expect_error()
* doc update
@fangly
Copy link
Contributor Author

fangly commented Mar 13, 2017

Fixed in #214

@fangly fangly closed this as completed Mar 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant