From 5e581d83c47a7075482786175c8bb53336ba43a6 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Tue, 31 Oct 2023 13:19:07 -0400 Subject: [PATCH] fix: Use `any(nzchar(x))` instead of `nchar(x) > 0` --- R/test-in-browser.R | 4 ++-- R/test-in-sso.R | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/test-in-browser.R b/R/test-in-browser.R index 3d2f8b9fa1..bb0d521751 100644 --- a/R/test-in-browser.R +++ b/R/test-in-browser.R @@ -38,10 +38,10 @@ test_in_browser <- function( return() } proc_output_lines <- app_proc$read_output_lines() - if (any(nchar(proc_output_lines) > 0)) { + if (any(nzchar(proc_output_lines))) { output_lines_val <<- paste0( output_lines_val, - if (nchar(output_lines_val) > 0) "\n", + if (nzchar(output_lines_val)) "\n", paste0(proc_output_lines, collapse = "\n") ) } diff --git a/R/test-in-sso.R b/R/test-in-sso.R index aa1ac06244..9801fc92d5 100644 --- a/R/test-in-sso.R +++ b/R/test-in-sso.R @@ -197,7 +197,7 @@ test_in_ssossp <- function( return("") } out <- docker_proc$read_output_lines() - if (length(out) > 0 && nchar(out) > 0) { + if (length(out) > 0 && any(nzchar(out))) { paste0(out, collapse = "\n") } else { "" @@ -218,7 +218,7 @@ test_in_ssossp <- function( Sys.sleep(0.5) # arbitrary, but it'll be a while till the docker is launched # display all docker output out <- get_docker_output() - if (nchar(out) > 0) { + if (any(nzchar(out))) { cat(out, "\n", sep = "") } invisible() @@ -248,10 +248,10 @@ test_in_ssossp <- function( return("(dead)") } docker_proc_output_lines <- docker_proc$read_output_lines() - if (any(nchar(docker_proc_output_lines) > 0)) { + if (any(nzchar(docker_proc_output_lines))) { output_lines <<- paste0( output_lines, - if (nchar(output_lines) > 0) "\n", + if (nzchar(output_lines)) "\n", paste0(docker_proc_output_lines, collapse = "\n") ) }