-
Notifications
You must be signed in to change notification settings - Fork 186
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
Convert all TODO(user) to TODO(issue) #2494
Changes from 4 commits
17cc495
02c95a6
0e4d613
7eca989
cf1dc38
571e1ca
a334dcf
f691db5
8036e1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,6 @@ | |
#' @evalRd rd_tags("keyword_quote_linter") | ||
#' @seealso [linters] for a complete list of linters available in lintr. | ||
#' @export | ||
# TODO(michaelchirico): offer a stricter version of this that | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue reference lost There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is #2471. I took a bit of a judgment call in some cases on totally removing the TODO from the sources, here's one of them. I think it's a bit odd to anchor this TODO to the function overall, interrupting the roxygen2 mark-up, so I removed it. |
||
# requires backticks to be used for non-syntactic names (i.e., not quotes). | ||
# Here are the relevant xpaths: | ||
# //expr[expr[SYMBOL_FUNCTION_CALL]]/SYMBOL_SUB[starts-with(text(), '`')] | ||
# //expr[expr[SYMBOL_FUNCTION_CALL]]/STR_CONST[{is_quoted(text())}] | ||
keyword_quote_linter <- function() { | ||
# Check if a string could be assigned as an R variable. | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,6 @@ | |
#' @seealso [linters] for a complete list of linters available in lintr. | ||
#' @export | ||
list_comparison_linter <- function() { | ||
# TODO(michaelchirico): extend to cases where using simplify=FALSE implies a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I don't think the TODO anchors to this expression in particular, so I removed it. The issue is #2472. |
||
# list output, e.g. with sapply, replicate, mapply. | ||
list_mapper_alternatives <- c( | ||
lapply = "vapply(x, FUN, character(1L))", | ||
map = "map_chr(x, FUN)", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,10 +49,6 @@ test_that("any_duplicated_linter catches length(unique()) equivalencies too", { | |
expect_lint("length(unique(x)) != length(x)", lint_msg_x, linter) | ||
expect_lint("length(unique(x)) < length(x)", lint_msg_x, linter) | ||
expect_lint("length(x) > length(unique(x))", lint_msg_x, linter) | ||
|
||
# TODO(michaelchirico): try and match data.table- and dplyr-specific versions of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed all of the TODO from the tests, I don't think they should live there. For the record this is #2481. |
||
# this, e.g. DT[, length(unique(col)) == .N] or | ||
# > DT %>% filter(length(unique(col)) == n()) | ||
}) | ||
|
||
test_that("any_duplicated_linter catches expression with two types of lint", { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,14 +60,6 @@ test_that("expect_s3_class_linter blocks simple disallowed usages", { | |
rex::rex("expect_s3_class(x, k) is better than expect_true(is.<k>(x))"), | ||
linter | ||
) | ||
|
||
# TODO(michaelchirico): consider more carefully which sorts of class(x) %in% . and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# . %in% class(x) calls should be linted | ||
#> expect_lint( | ||
#> "expect_true('lm' %in% class(x))", | ||
#> "expect_s3_class\\(x, k\\) is better than expect_equal\\(class\\(x\\), k", | ||
#> expect_s3_class_linter | ||
#> ) | ||
}) | ||
|
||
local({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,19 +270,6 @@ test_that("fixed replacement is correct with UTF-8", { | |
) | ||
}) | ||
|
||
# TODO(michaelchirico): one difference for stringr functions vs. base is that | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is done already, I think on the last release when we did pipe-awareness consistency. |
||
# stringr is much friendlier to piping, so that | ||
# > str %>% str_replace_all("x$", "y") | ||
# actually doesn't need fixed(), but the logic now is only looking at "y" | ||
# since it's the second argument and a non-regex string. Similarly, | ||
# > str %>% str_detect("x") | ||
# is a false negative. thankfully there appear to be few false positives here | ||
|
||
# TODO(michaelchirico): we could in principle build in logic to detect whether | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# perl=TRUE and interpret "regex or not" accordingly. One place | ||
# up in practice is for '\<', which is a special character in default | ||
# regex but not in PCRE. Empirically relevant for HTML-related regex e.g. \\<li\\> | ||
|
||
#' Generate a string with a non-printable Unicode entry robust to test environment | ||
#' | ||
#' Non-printable unicode behaves wildly different with `encodeString()` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,5 +83,3 @@ test_that("exceptions= argument works", { | |
|
||
expect_lint("if (!foo(x)) y else z", NULL, if_not_else_linter(exceptions = "foo")) | ||
}) | ||
|
||
# TODO(michaelchirico): should if (A != B) be considered as well? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,3 @@ test_that("lints vectorize", { | |
ifelse_censor_linter() | ||
) | ||
}) | ||
|
||
# TODO(michaelchirico): how easy would it be to strip parens when considering lint? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# e.g. ifelse(x < (kMaxIndex - 1), x, kMaxIndex - 1) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,18 +94,12 @@ test_that("it handles tex", { | |
file = test_path("knitr_formats", "test.Rtex"), | ||
checks = list( | ||
list(regexes[["indent"]], line_number = 11L), | ||
# TODO(AshesITR): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both are #1043 |
||
# masking the Rtex escape char by whitespace causes false-positive indentation lints | ||
list(regexes[["assign"]], line_number = 11L), | ||
list(regexes[["indent"]], line_number = 22L), | ||
list(regexes[["local_var"]], line_number = 23L), | ||
list(regexes[["assign"]], line_number = 23L), | ||
list(regexes[["trailing"]], line_number = 25L), | ||
list(regexes[["trailws"]], line_number = 25L) | ||
# TODO(AshesITR): #1043 | ||
# file_lines contains a whitespace on the final line for Rtex, because that is used to mark the Rtex escape char | ||
# "%" as well. | ||
# cf. get_source_expressions("tests/testthat/knitr_formats/test.Rtex")$lines[[25]] | ||
), | ||
linters = default_linters, | ||
parse_settings = FALSE | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,6 @@ test_that("nzchar_linter skips as appropriate for other nchar args", { | |
# type="bytes" should be >= the value for the default (type="chars") | ||
expect_lint("nchar(x, type='width') == 0L", NULL, linter) | ||
|
||
# TODO(michaelchirico): check compatibility of nchar(., allowNA=TRUE). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# there are no examples in ?nchar, nor any relevant usages on StackOverflow. | ||
# just assume they are incompatible now to be conservative. | ||
expect_lint("nchar(x, allowNA=TRUE) == 0L", NULL, linter) | ||
|
||
# nzchar also has keepNA argument so a drop-in switch is easy | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,7 @@ test_that("one_call_pipe_linter blocks simple disallowed usages", { | |
# new lines don't matter | ||
expect_lint("x %>%\n foo()", lint_msg, linter) | ||
|
||
# catch the "inner" pipe chain, not the "outer" one | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# TODO(michaelchirico): actually, this should lint twice -- we're too aggressive | ||
# in counting _all_ nested calls. | ||
# nested case | ||
expect_lint("x %>% inner_join(y %>% filter(is_treatment))", lint_msg, linter) | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,8 +167,6 @@ test_that("unnecessary_lambda_linter doesn't apply to keyword args", { | |
test_that("purrr-style anonymous functions are also caught", { | ||
linter <- unnecessary_lambda_linter() | ||
|
||
# TODO(michaelchirico): this is just purrr::flatten(x). We should write another | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# linter to encourage that usage. | ||
expect_lint("purrr::map(x, ~.x)", NULL, linter) | ||
expect_lint("purrr::map_df(x, ~lm(y, .x))", NULL, linter) | ||
expect_lint("map_dbl(x, ~foo(bar = .x))", NULL, linter) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,6 @@ test_that("unnecessary_nesting_linter skips allowed usages", { | |
) | ||
}) | ||
|
||
# TODO(michaelchirico): consider if there's a nice easy pattern to enforce for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# multiple if/else cases. This test in particular would be easy to un-nest, | ||
# but it's not true in general. | ||
test_that("Multiple if/else statements don't require unnesting", { | ||
# with further branches, reducing nesting might be less readable | ||
expect_lint( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -720,30 +720,3 @@ test_that("allow_comment_regex= obeys covr's custom exclusion when set", { | |
linter_covr | ||
) | ||
}) | ||
|
||
# nolint start: commented_code_linter. | ||
# TODO(michaelchirico): extend to work on switch() statements | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# test_that("unreachable_code_linter interacts with switch() as expected", { | ||
# unreachable_inside_switch_lines <- trim_some(" | ||
# foo <- function(x) { | ||
# switch(x, | ||
# a = { | ||
# return(x) | ||
# x + 1 | ||
# }, | ||
# b = { | ||
# return(x + 1) | ||
# } | ||
# ) | ||
# } | ||
# ") | ||
# expect_lint( | ||
# unreachable_inside_switch_lines, | ||
# rex::rex("Code and comments coming after a return() or stop()"), | ||
# unreachable_code_linter() | ||
# ) | ||
# }) | ||
# nolint end: commented_code_linter. | ||
|
||
# TODO(michaelchirico): This could also apply to cases without | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# explicit returns (where it can only apply to comments) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,15 +61,3 @@ test_that("lints vectorize", { | |
yoda_test_linter() | ||
) | ||
}) | ||
|
||
# TODO(michaelchirico): Should this be extended to RUnit tests? It seems yes, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dropped this |
||
# but the argument names in RUnit (inherited from base all.equal()) are a bit | ||
# confusing, e.g. `checkEqual(target=, current=)`. From the name, one might | ||
# reasonably conclude 'expected' comes first, and 'actual' comes second. | ||
# TODO(michaelchirico): What sorts of combinations of literals can be included? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# e.g. expect_equal(c(1, 2), x) is a yoda test; is expect_equal(c(x, 1), y)? | ||
# clearly it's not true for general f() besides c(). What about other | ||
# constructors of literals? data.frame(), data.table(), tibble(), ...? | ||
# TODO(michaelchirico): The logic could also be extended to "tests" inside regular | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is #1835 |
||
# code, not just test suites, e.g. `if (2 == x)`, `while(3 <= x)`, | ||
# `stopifnot('a' == foo(y))`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two are combined in #2470