Skip to content

fix #432 - Object usage line numbers - #440

Merged
russHyde merged 1 commit into
r-lib:masterfrom
russHyde:object-usage-line-numbers
Jan 17, 2020
Merged

russHyde merged 1 commit into
r-lib:masterfrom
russHyde:object-usage-line-numbers

Conversation

@russHyde

Copy link
Copy Markdown
Collaborator

In #432 it was noted that the line-number for object-usage-linter
warnings were often incorrect. They were being reported relative to the
start of the defining function, rather than the start of the file.

- A test was added that throws an object-usage-lint on line-2 of the
function but line-5 of the file.

- Modified object-usage-linter.R so that it reported the line-number from the original file, rather than the line-number of the encasing function

This led to several of the knitr-format tests failing because lints were throwing in a different order. The original tests were misordered , and have been modified.

Briefly:
Each of the knitr-format tests had code blocks that look like this:

~~~~
a = 1
~~~~

~~~~
b <- function(x) {
  d = 1
}

~~~~

The lints should be ordered:
- assignment (`=` for a)
- local variable ‘d’ assigned but may not be used
- assignment (`=` for d)
- trailing blank line

I updated the tests and added the explicit line-numbers where the lints
should throw to test-knitr_formats.R

@miker985

miker985 commented Jan 6, 2020

Copy link
Copy Markdown

I can confirm this fixes the reported issue in #432

In r-lib#432 it was noted that the line-number for object-usage-linter
warnings were often incorrect. They were being reported relative to the
start of the defining function, rather than the start of the file.

A test was added that throws an object-usage-lint on line-2 of the
function but line-5 of the file.

Also,

- any pre-existing knitr-format tests were expanded so that the observed
lints occurred on an explicit `line_number`

- updated NEWS.md
@russHyde
russHyde force-pushed the object-usage-line-numbers branch from 83f8e85 to 4f8de87 Compare January 16, 2020 16:39
@russHyde

russHyde commented Jan 16, 2020 •

Copy link
Copy Markdown
Collaborator Author

I've added a NEWS entry and squashed down to a single commit. Would you be able to review this @jimhester so that I can look at #445 (which is a slightly different bug)

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

Successfully merging this pull request may close these issues.

3 participants