From b9378c3ae735c334bdb69c5d8a41124c2cac7fd5 Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Tue, 3 Feb 2026 14:50:30 +0000 Subject: [PATCH] Fixed lintr & complexity issues --- R/DBClient-CRUDRows.R | 12 ++++++------ R/DBClient-Initialize.R | 2 +- R/DBClient-dbCollect.R | 36 ++++++++++++++++++------------------ R/DBClient-dbSchema.R | 12 ++++++------ R/DBClient.R | 1 + R/DBConnection-Connect.R | 4 ++-- R/DBConnection-Transaction.R | 14 +++++++------- R/DBConnection.R | 1 + R/aaa.R | 4 ++-- 9 files changed, 44 insertions(+), 42 deletions(-) diff --git a/R/DBClient-CRUDRows.R b/R/DBClient-CRUDRows.R index 08721b9..d57034a 100644 --- a/R/DBClient-CRUDRows.R +++ b/R/DBClient-CRUDRows.R @@ -10,7 +10,7 @@ ) } - return(tbl) + tbl } @@ -40,7 +40,7 @@ insertRows <- function(table_name, rows, key_name = NULL) { return(dbplyr::get_returned_rows(tbl)) } - return(invisible(tbl)) + invisible(tbl) } appendRows <- function(table_name, rows, key_name = NULL) { @@ -64,7 +64,7 @@ appendRows <- function(table_name, rows, key_name = NULL) { return(dbplyr::get_returned_rows(tbl)) } - return(invisible(TRUE)) + invisible(TRUE) } upsertRows <- function(table_name, rows, key_name = NULL) { @@ -98,7 +98,7 @@ upsertRows <- function(table_name, rows, key_name = NULL) { } } - return(invisible(TRUE)) + invisible(TRUE) } updateRows <- function(table_name, rows, key_name = NULL) { @@ -122,7 +122,7 @@ updateRows <- function(table_name, rows, key_name = NULL) { return(dbplyr::get_returned_rows(tbl)) } - return(invisible(TRUE)) + invisible(TRUE) } deleteRows <- function(table_name, rows, key_name = NULL) { @@ -151,5 +151,5 @@ deleteRows <- function(table_name, rows, key_name = NULL) { return(dbplyr::get_returned_rows(tbl)) } - return(invisible(TRUE)) + invisible(TRUE) } diff --git a/R/DBClient-Initialize.R b/R/DBClient-Initialize.R index 623e4ee..bff607b 100644 --- a/R/DBClient-Initialize.R +++ b/R/DBClient-Initialize.R @@ -8,7 +8,7 @@ conn <- NULL NULL initialize <- function(conn) { if (is.null(conn) || !R6::is.R6(conn) || !inherits(conn, "DBConnection")) { - stop("DBConnection instance required!") + stop("DBConnection instance required!") } private$conn <- conn } diff --git a/R/DBClient-dbCollect.R b/R/DBClient-dbCollect.R index b912afb..72450f6 100644 --- a/R/DBClient-dbCollect.R +++ b/R/DBClient-dbCollect.R @@ -50,34 +50,34 @@ collectGeometries <- function( if (sum(geometry_cols %in% colnames(res)) > 0) { res <- dplyr::mutate( - res, - dplyr::across(dplyr::any_of(geometry_cols), function(.col) { - sf::st_as_sfc( - .col, - EWKB = TRUE, - crs = geometry_crs, - check_ring_dir = check_ring_dir - ) - }) - ) + res, + dplyr::across(dplyr::any_of(geometry_cols), function(.col) { + sf::st_as_sfc( + .col, + EWKB = TRUE, + crs = geometry_crs, + check_ring_dir = check_ring_dir + ) + }) + ) } if ("geom" %in% colnames(res) && sum("geom" %in% geometry_cols) == 0) { res <- dplyr::mutate( - res, - geom = sf::st_as_sfc( - .data$geom, EWKB = TRUE, crs = 4326, check_ring_dir = check_ring_dir - ) + res, + geom = sf::st_as_sfc( + .data$geom, EWKB = TRUE, crs = 4326, check_ring_dir = check_ring_dir ) + ) } if ("proj" %in% colnames(res) && sum("proj" %in% geometry_cols) == 0) { res <- dplyr::mutate( - res, - proj = sf::st_as_sfc( - .data$proj, EWKB = TRUE, crs = 3035, check_ring_dir = check_ring_dir - ) + res, + proj = sf::st_as_sfc( + .data$proj, EWKB = TRUE, crs = 3035, check_ring_dir = check_ring_dir ) + ) } res diff --git a/R/DBClient-dbSchema.R b/R/DBClient-dbSchema.R index 4599d69..4ddc328 100644 --- a/R/DBClient-dbSchema.R +++ b/R/DBClient-dbSchema.R @@ -9,13 +9,13 @@ NULL withSchema <- function(table_name) { config <- private$conn$getConfiguration() if (exists("schema", config)) { - return(DBI::dbQuoteIdentifier( + DBI::dbQuoteIdentifier( private$getDBConn(), DBI::Id(schema = config$schema, table = table_name) - )) + ) } else { - return(DBI::dbQuoteIdentifier( + DBI::dbQuoteIdentifier( private$getDBConn(), DBI::Id(table = table_name) - )) + ) } } @@ -32,8 +32,8 @@ NULL dplyrWithSchema <- function(table_name) { config <- private$conn$getConfiguration() if (exists("schema", config) && !is.null(config$schema)) { - return(dbplyr::in_schema(config$schema, table_name)) + dbplyr::in_schema(config$schema, table_name) } else { - return(table_name) + table_name } } diff --git a/R/DBClient.R b/R/DBClient.R index 15f5b08..4fbd421 100644 --- a/R/DBClient.R +++ b/R/DBClient.R @@ -33,6 +33,7 @@ names(member_list) <- member_names NULL #' @export +# nolint next: object_name_linter. R6Class DBClient <- R6::R6Class( "DBClient", public = fn_list, diff --git a/R/DBConnection-Connect.R b/R/DBConnection-Connect.R index 16642ac..3b4d317 100644 --- a/R/DBConnection-Connect.R +++ b/R/DBConnection-Connect.R @@ -48,7 +48,7 @@ connect <- function() { error = function(err) { print("Database error:") utils::str(err) - return(FALSE) + FALSE } ) @@ -66,7 +66,7 @@ NULL getConnection <- function(do_connect = NULL) { if (!self$isConnected()) { if ((!is.null(do_connect) && do_connect) - || (is.null(do_connect) && private$conn$autoconnect)) { + || (is.null(do_connect) && private$conn$autoconnect)) { connect() } else { warning("Database is not connected. Caller of getConnection() may error.") diff --git a/R/DBConnection-Transaction.R b/R/DBConnection-Transaction.R index 6abf408..dc13642 100644 --- a/R/DBConnection-Transaction.R +++ b/R/DBConnection-Transaction.R @@ -11,12 +11,12 @@ transactionLevel <- 0 NULL beginTransaction <- function(allowRecursive = FALSE, quietly = FALSE) { if (private$transactionLevel > 0) { - if (allowRecursive == FALSE) { - if (quietly != FALSE) { - stop("Transaction already started. Aborting.") - } - return(FALSE) - } + if (allowRecursive == FALSE) { + if (quietly != FALSE) { + stop("Transaction already started. Aborting.") + } + return(FALSE) + } } private$transactionLevel <- private$transactionLevel + 1 DBI::dbBegin(self$getConnection()) @@ -63,7 +63,7 @@ commitTransaction <- function(quietly = FALSE) { } private$transactionLevel <- private$transactionLevel - 1 if (transactionLevel > 0) { - return(TRUE) + return(TRUE) } DBI::dbRollback(self$getConnection()) } diff --git a/R/DBConnection.R b/R/DBConnection.R index 3cc22ff..f541812 100644 --- a/R/DBConnection.R +++ b/R/DBConnection.R @@ -34,6 +34,7 @@ names(member_list) <- member_names NULL #' @export +# nolint next: object_name_linter. R6Class DBConnection <- R6::R6Class( "DBConnection", public = fn_list, diff --git a/R/aaa.R b/R/aaa.R index 99875c5..436b766 100644 --- a/R/aaa.R +++ b/R/aaa.R @@ -1,5 +1,5 @@ -if(getRversion() >= "2.15.1") utils::globalVariables(c("self")) -if(getRversion() >= "2.15.1") utils::globalVariables(c("private")) +if (getRversion() >= "2.15.1") utils::globalVariables(c("self")) +if (getRversion() >= "2.15.1") utils::globalVariables(c("private")) #' @importFrom rlang := #' @importFrom rlang .data