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

Ambiguous files in cache cause lint crash #212

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

Ambiguous files in cache cause lint crash #212

fangly opened this issue Feb 24, 2017 · 1 comment

Comments

@fangly
Copy link
Contributor

fangly commented Feb 24, 2017

Hi Jim,

I obtained a "Marker line is unspecified or invalidNA" error when using lintr with caching. I managed to find out what is causing this problem. It is reproducible using these steps:

  1. Create two packages, "A" and "B", that have the identically-named files "tests/testthat.R". Let us assume that "A/tests/testthat.R" and "B/tests/testthat.R" are identical, except that "A/tests/testthat.R" has some trailing newlines.
  2. In package A, run expect_lint_free(cache=TRUE). This runs fine, yields a few lints because of the trailing newlines, and generates a "~/.R/lintr_cache/testthat.R" file.
  3. In package B, run expect_lint_free(cache=TRUE). This operation crashes with "Marker line is unspecified or invalidNA". I imagine this is because lintr sees the "~/.R/lintr_cache/testthat.R" file and wrongly assumes that it belongs to package B. Since there are some lints at line numbers after last line of file "B/tests/testthat.R", mayhem ensues...

My conclusion is that the cache should differentiate files belonging to different packages. This is important because many packages use the same names, e.g. "testthat.R" or "zzz.R".

But the problem is probably not limited to identically-named files between packages. When I create a file "A/R/more/testthat.R", issue a clear_cache() and re-run expect_lint_free(cache=TRUE), there is a single "~/.R/lintr_cache/testthat.R" file, meaning that the two "testthat.R" files in package A were likely cached in the same location, one of them overwriting the other.

A straightforward solution would be to create a subfolder for each package, and further subfolders mimicking the folder structure of the respective packages, i.e.

Source file Cache file
A/tests/testthat.R ~/.R/lintr_cache/A/tests/testthat.R
A/R/more/testthat.R ~/.R/lintr_cache/A/R/more/testthat.R
B/tests/testthat.R ~/.R/lintr_cache/B/tests/testthat.R

Cheers,
Florent

@russHyde
Copy link
Collaborator

Fixed in #232 . Closing

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

2 participants