Skip to content

Commit

Permalink
update datachecker func
Browse files Browse the repository at this point in the history
  • Loading branch information
oadetayo committed Feb 19, 2025
1 parent 4016d32 commit 8a83983
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions R/pre_commit.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ init_hooks <- function() {
Sys.chmod(hook_path, mode = "0755")

message("Pre-commit hook created at ", hook_path)
return(hook_path)
hook_path
}

#' Commit Hooks for Data Validation, Analytics Check, and Code Styling
Expand Down Expand Up @@ -72,7 +72,7 @@ commit_hooks <- function() {
}

message("\nCommit blocked: Issues detected.")
return(FALSE)
FALSE
}

#' Validate Data Files and Gitignore Configuration
Expand All @@ -98,14 +98,14 @@ data_checker <- function(datafile_log = "datafiles_log.csv",

# Read tracking files
ign_files <- utils::read.csv(ignore_file,
header = FALSE,
stringsAsFactors = FALSE, col.names = "filename"
header = FALSE,
stringsAsFactors = FALSE, col.names = "filename"
)

tryCatch(
{
log_files <- utils::read.csv(datafile_log, stringsAsFactors = FALSE)
if(!all(c("filename","status") %in% colnames(log_files))){
if (!all(c("filename", "status") %in% colnames(log_files))) {
stop("data logfile must contain the columns filename and status")
}
ign_text <- readr::read_file(".gitignore")
Expand All @@ -125,7 +125,7 @@ data_checker <- function(datafile_log = "datafiles_log.csv",
"Any files containing sensitive or unpublished data must also be
included in the .gitignore file."
)
return(FALSE)
FALSE
}
)

Expand Down Expand Up @@ -229,9 +229,9 @@ data_checker <- function(datafile_log = "datafiles_log.csv",
check_analytics_key <- function(ga_file = "google-analytics.html",
ui_file = "ui.R") {
ga_pattern <- "Z967JJVQQX"
if (!file.exists(ga_file)){
message("skipping check for google analytics keys...")
return(TRUE)
if (!file.exists(ga_file)) {
message("skipping check for google analytics keys...")
return(TRUE)
}
ga_content <- readLines(ga_file)

Expand Down

0 comments on commit 8a83983

Please sign in to comment.