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

Behavior of lintr before/after calling library #382

Closed
tvatter opened this issue Apr 26, 2019 · 4 comments
Closed

Behavior of lintr before/after calling library #382

tvatter opened this issue Apr 26, 2019 · 4 comments
Labels
feature a feature request or enhancement object linters 🏀

Comments

@tvatter
Copy link

tvatter commented Apr 26, 2019

Hi,

I use neovim with ale + Nvim-R and it got me wondering about how lintr works.

Let's say that I have the following file called test.R:

library(purrr)

n <- 10
map(1:n, function(x) rnorm(x))
myfun <- function(n) {
  map(1:n, function(x) rnorm(x))
}

If I start a new R session and call lintr::lint("test.R"), I get a marker related to the second map ("no visible global function definition"), whereas if I call library(purrr) first, I do not get a marker.

  1. Why do I never get a marker for the first map?
  2. In the second case (i.e., if I call lintr::lint after library), how does lintr "knows" that map is "available"?

While I ask the first question by curiosity, I ask the second question because, as mentioned, I use ale and Nvim-R. In this context, although I often load packages in the R session opened with Nvim-R, the markers for missing global function definitions never disappear after loading the appropriate packages.

This is obviously expected since, to the best of my knowledge, there is no connection between ale and Nvim-R. But I am trying to understand where lintr looks for the information about the loaded namespaces with the final goal to get ale to use the current Nvim-R session to make the markers related to global function definitions from packages that are loaded disappear.

I am not sure whether I explained clearly the issue, my apologies if not.

@jimhester
Copy link
Member

ale is calling lintr in a new process, not the current process. Probably we should be loading libraries as well, but lintr is currently mostly geared towards package development rather than scripts unfortunately.

@jimhester jimhester added the feature a feature request or enhancement label Sep 24, 2019
@tvatter
Copy link
Author

tvatter commented Sep 24, 2019

Thanks a lot for the answer! I totally understand and would be interested in implementing this feature if you had a few tips or a small "roadmap".

@tvatter
Copy link
Author

tvatter commented Oct 1, 2019

I just installed the latest version on master and the issue is still I think...

@tvatter
Copy link
Author

tvatter commented Oct 1, 2019

Actually, my two remarks/questions still stand. I just tried Rscript -e 'lintr::lint("test.R")' vs Rscript -e 'library(purrr);lintr::lint("test.R")' using the file above, and I get exactly the same "issue" as before:

  1. With Rscript -e 'lintr::lint("test.R")': no marker related to the first map, but a marker related to the second.
  2. With Rscript -e 'library(purrr);lintr::lint("test.R")': no marker related to either map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement object linters 🏀
Projects
None yet
Development

No branches or pull requests

2 participants