Fixed lintr & complexity issues

This commit is contained in:
2026-02-03 14:50:30 +00:00
parent 14e58ed9da
commit b9378c3ae7
9 changed files with 44 additions and 42 deletions

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -33,6 +33,7 @@ names(member_list) <- member_names
NULL
#' @export
# nolint next: object_name_linter. R6Class
DBClient <- R6::R6Class(
"DBClient",
public = fn_list,

View File

@@ -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.")

View File

@@ -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())
}

View File

@@ -34,6 +34,7 @@ names(member_list) <- member_names
NULL
#' @export
# nolint next: object_name_linter. R6Class
DBConnection <- R6::R6Class(
"DBConnection",
public = fn_list,

View File

@@ -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