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

wrong line number reported, also ignores #nolint #203

Closed
flodel opened this issue Feb 10, 2017 · 1 comment
Closed

wrong line number reported, also ignores #nolint #203

flodel opened this issue Feb 10, 2017 · 1 comment

Comments

@flodel
Copy link

flodel commented Feb 10, 2017

This is a pretty weird bug I hope you will be able to reproduce.

Please try running the code provided at the bottom. On my machine, it returns:

/tmp/RtmpE4gvZC/file6dda6d9e5fd8:9:30: style: Do not place spaces around code in parentheses or square brackets.
       deled_p <- grid_points[ d.i] # nolint

which is surprising for two reasons: 1) there is a #nolint on the quoted line and 2) the line number (9) does not match the quoted line.

The bug seems to require very specific conditions: try removing even a blank line from my code or rename a variable, and the bug might disappear...

Thanks for looking into it.

=======================

library(lintr)

text <- '





FUN <- function() {

      matrix(sd, as.data.frame("a"))




   wrapper(d, function(d)       
       deled_p <- grid_points[ d.i] # nolint
)
}
'

tmp <- tempfile()
cat(text, file = tmp)
lint(tmp)
@fangly
Copy link
Contributor

fangly commented May 3, 2017

Thank you flodel. There was indeed an issue with spaces_inside_linter() not handling line numbers correctly. This manifested when there were empty lines in the content to lint. This is fixed in 17a8ee8

@fangly fangly closed this as completed May 3, 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

2 participants