Repository navigation
extend assignment_linter for other operators - #928
Conversation
|
@AshesITR PTAL at the test failure. Looks odd to me. For now I just removed the test. At HEAD, vs. in this PR it's What's puzzling is the test is checking that exactly the new value of lintr/tests/testthat/test-expect_lint.R Line 28 in 6f55ef5 So I'm second guessing if there's a reason for that? I can't think of any. And There's this comment in the original PR:
|
| expect_error(expect_lint("a=1", c(message = msg, lineXXX = 1L), linter), "invalid field") | ||
|
|
||
| expect_failure(expect_lint("a=1", list(ranges = list(c(2L, 2L))), linter)) | ||
| expect_success(expect_lint("a=1", list(ranges = list(c(2L, 2L))), linter)) |
There was a problem hiding this comment.
What was the original failure?
There was a problem hiding this comment.
Error: check #1: ranges NULL did not match list(c(2L, 2L))
There was a problem hiding this comment.
So that seems like a way of documenting the bug we just fixed 😆
Feel free to remove the test.
There was a problem hiding this comment.
Despite not really knowing the purpose of the test I'm still a bit loath to remove it 😆
I changed it to use a different linter that gives NULL for ranges
|
ah poop. git is hard. |
c774fd2 to
a647042
Compare
| "//EQ_ASSIGN", | ||
| # -> and ->> are both 'RIGHT_ASSIGN' | ||
| if (!allow_right_assign) "//RIGHT_ASSIGN" else if (!allow_cascading_assign) "//RIGHT_ASSIGN[text() = '->>']", | ||
| # <-, :=, and <<- are all 'LEFT_ASSIGN'; check the text if blocking <<- |
There was a problem hiding this comment.
Shouldn't we lint := as well?
There was a problem hiding this comment.
We'd have to write special logic to handle correct rlang and data.table usages. Don't think it's worth it (most people don't know that := can be used for "regular" assignment and it's explicitly not mentioned in the R documentation).
There was a problem hiding this comment.
Agreed. Maybe worth mentioning here why we chose not to lint :=?
|
Looks mostly good, just a few finishing touches needed. |
| * `lintr` now uses the 3rd edition of `testthat` (@MichaelChirico, #910) | ||
| * `lintr` is adopting a new set of linters provided as part of Google's extension to the tidyverse style guide (#884, @michaelchirico) | ||
| + `expect_null_linter()` Require usage of `expect_null(x)` over `expect_equal(x, NULL)` and similar | ||
| * `assignment_linter()` now blocks right assignment (`->` and `->>`) and gains two arguments. `allow_cascading_assign` (`TRUE` by default) toggles whether to block `<<-` and `->>`; `allow_right_assign` toggles whether to block `->` and `->>` (#915, @michaelchirico) |
| "//EQ_ASSIGN", | ||
| # -> and ->> are both 'RIGHT_ASSIGN' | ||
| if (!allow_right_assign) "//RIGHT_ASSIGN" else if (!allow_cascading_assign) "//RIGHT_ASSIGN[text() = '->>']", | ||
| # <-, :=, and <<- are all 'LEFT_ASSIGN'; check the text if blocking <<- |
There was a problem hiding this comment.
Agreed. Maybe worth mentioning here why we chose not to lint :=?
Closes #915