Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Dec 1, 2024
1 parent f2a56af commit 62631e6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions R/data_rename.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ data_rename <- function(data,
# Ex: if select = c("foo" = "Species", "Sepal.Length") then the 2nd name and
# 2nd value are "Sepal.Length"
if (!is.null(names(select))) {
for (i in seq_along(select)) {
if (names(select)[i] == select[i]) {
insight::format_error("When `select` is a named vector, all elements must be named.")
}
if (any(names(select) == select)) {

Check warning on line 119 in R/data_rename.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_rename.R,line=119,col=5,[unnecessary_nesting_linter] Don't use nested `if` statements, where a single `if` with the combined conditional expression will do. For example, instead of `if (x) { if (y) { ... }}`, use `if (x && y) { ... }`.

Check warning on line 119 in R/data_rename.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/data_rename.R,line=119,col=5,[unnecessary_nesting_linter] Don't use nested `if` statements, where a single `if` with the combined conditional expression will do. For example, instead of `if (x) { if (y) { ... }}`, use `if (x && y) { ... }`.
insight::format_error("When `select` is a named vector, all elements must be named.")
}
}

Expand Down

0 comments on commit 62631e6

Please sign in to comment.