diff --git a/NEWS.md b/NEWS.md index 463dd129c..8e5cca885 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # lintr (development version) +## Bug fixes + +* `inner_combine_linter()` no longer throws on length-1 calls to `c()` like `c(exp(2))` or `c(log(3))` (#2017, @MichaelChirico). Such usage is discouraged by `unnecessary_concatenation_linter()`, but `inner_combine_linter()` _per se_ does not apply. + # lintr 3.1.0 ## Deprecations & Breaking Changes diff --git a/R/inner_combine_linter.R b/R/inner_combine_linter.R index 68abd1244..607e61bbe 100644 --- a/R/inner_combine_linter.R +++ b/R/inner_combine_linter.R @@ -78,7 +78,7 @@ inner_combine_linter <- function() { ) xpath <- glue::glue(" //SYMBOL_FUNCTION_CALL[text() = 'c'] - /parent::expr + /parent::expr[count(following-sibling::expr) > 1] /following-sibling::expr[1][ {c_expr_cond} ] /parent::expr ") diff --git a/tests/testthat/test-inner_combine_linter.R b/tests/testthat/test-inner_combine_linter.R index 36ec6138a..d445dd6d3 100644 --- a/tests/testthat/test-inner_combine_linter.R +++ b/tests/testthat/test-inner_combine_linter.R @@ -67,6 +67,10 @@ test_that("inner_combine_linter is order-agnostic for matching arguments", { ) }) +test_that("c() with ...length()=1 is OK", { + expect_lint("c(exp())", NULL, inner_combine_linter()) +}) + skip_if_not_installed("tibble") patrick::with_parameters_test_that( "inner_combine_linter skips allowed usages:",