Skip to content

Commit

Permalink
Merge branch 'pipe-consistency' of https://github.com/bairdj/lintr in…
Browse files Browse the repository at this point in the history
…to pipe-consistency
  • Loading branch information
bairdj committed Jul 28, 2023
2 parents 648ae96 + 3707d99 commit 2279132
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .lintr_new
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linters: linters_with_defaults(
any_duplicated_linter(),
any_is_na_linter(),
backport_linter("oldrel-4", except = c("R_user_dir", "str2lang", "str2expression", "deparse1")),
consecutive_stopifnot_linter(),
consecutive_assertion_linter(),
expect_comparison_linter(),
expect_length_linter(),
expect_named_linter(),
Expand Down
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -245,7 +249,7 @@ works when passed to the `styles` parameter (#1924, @hedsnz).
* `unreachable_code_linter()` ignores trailing comments if they match a closing nolint block (#1347, @AshesITR).

* New `function_argument_linter()` to enforce that arguments with defaults appear last in function declarations,
see the [Tidyverse design guide](https://design.tidyverse.org/args-data-details.html) (#450, @AshesITR).
see the [Tidyverse design guide](https://design.tidyverse.org/required-no-defaults.html) (#450, @AshesITR).

* New `allow_trailing` argument added to `assignment_linter()` to check when assignment operators are at the
end of a line, and the value is on the following line (#1491, @ashbaldry)
Expand Down Expand Up @@ -326,7 +330,7 @@ works when passed to the `styles` parameter (#1924, @hedsnz).
+ `open_curly_linter()`
+ `paren_brace_linter()`
* The `...` argument for `lint()`, `lint_dir()`, and `lint_package()` has been promoted to an earlier position to
better match the [Tidyverse design principle](https://design.tidyverse.org/args-data-details.html) of
better match the [Tidyverse design principle](https://design.tidyverse.org/required-no-defaults.html) of
data->descriptor->details. This change enables passing objects to `...` without needing to specify non-required
arguments, e.g. `lint_dir("/path/to/dir", linter())` now works without the need to specify `relative_path`.
This affects some code that uses positional arguments (#935, @MichaelChirico).
Expand Down
2 changes: 1 addition & 1 deletion R/function_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#' @evalRd rd_tags("function_argument_linter")
#' @seealso
#' - [linters] for a complete list of linters available in lintr.
#' - <https://design.tidyverse.org/args-data-details.html>
#' - <https://design.tidyverse.org/required-no-defaults.html>
#' @export
function_argument_linter <- function() {
xpath <- paste(collapse = " | ", glue::glue("
Expand Down
2 changes: 1 addition & 1 deletion R/inner_combine_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
")
Expand Down
2 changes: 1 addition & 1 deletion man/function_argument_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/test-inner_combine_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down

0 comments on commit 2279132

Please sign in to comment.