Skip to content

wrong line number reported, also ignores #nolint #203

@flodel

Description

@flodel

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)

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