Skip to content

Commit 3ef8ee7

Browse files
committed
Ran styler on whole package, fixed indenting
1 parent f090d39 commit 3ef8ee7

10 files changed

Lines changed: 1294 additions & 959 deletions

R/optional_data_checks.R

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,52 @@
1313
#' test_pii_data_emails()
1414
#' }
1515
test_pii_data_emails <- function(directory = here::here()) {
16-
17-
#get the full file names and paths for all files in directory
16+
# get the full file names and paths for all files in directory
1817
files <- list.files(directory, full.names = TRUE)
1918

20-
emails_list <- NULL #list of lists containing offending emails.
21-
#populate emails_list with pii emails:
22-
for(file in files){
23-
data_emails <- NULL #holds emails
24-
email_files <- NULL #holds names of files that contain emails
19+
emails_list <- NULL # list of lists containing offending emails.
20+
# populate emails_list with pii emails:
21+
for (file in files) {
22+
data_emails <- NULL # holds emails
23+
email_files <- NULL # holds names of files that contain emails
2524
personal_emails <- NULL # holds offending emails
26-
if(grepl(".csv", file, ignore.case = TRUE)) {
27-
#read data line by line, concatenate lines (emails split across a lines)
25+
if (grepl(".csv", file, ignore.case = TRUE)) {
26+
# read data line by line, concatenate lines (emails split across a lines)
2827
data_lines <- paste(readLines(file), collapse = " ")
29-
#for each csv file, extract all emails and add them to file_emails
28+
# for each csv file, extract all emails and add them to file_emails
3029
data_emails <- suppressWarnings(
31-
regmatches(data_lines,gregexpr("([_+a-z0-9-]+(\\.[_+a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,14}))", data_lines)))
30+
regmatches(data_lines, gregexpr("([_+a-z0-9-]+(\\.[_+a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,14}))", data_lines))
31+
)
3232
data_emails <- unlist(data_emails, recursive = FALSE)
3333

34-
#if a file contains emails, check for offending emails:
35-
if(length(seq_along(data_emails)) > 0){
36-
for(i in seq_along(data_emails)){
37-
#filter out .govs
38-
if(!stringr::str_detect(data_emails[i], ".gov")){
34+
# if a file contains emails, check for offending emails:
35+
if (length(seq_along(data_emails)) > 0) {
36+
for (i in seq_along(data_emails)) {
37+
# filter out .govs
38+
if (!stringr::str_detect(data_emails[i], ".gov")) {
3939
personal_emails <- append(personal_emails, data_emails[i])
4040
}
4141
}
4242
}
43-
if(!is.null(personal_emails)){
43+
if (!is.null(personal_emails)) {
4444
pii_emails <- list(personal_emails)
4545
names(pii_emails) <- basename(file)
46-
emails_list<-append(emails_list, pii_emails)
46+
emails_list <- append(emails_list, pii_emails)
4747
}
4848
}
4949
}
50-
#if there are offending emails, fail with warning:
51-
if(!is.null(emails_list)){
50+
# if there are offending emails, fail with warning:
51+
if (!is.null(emails_list)) {
5252
msg <- paste0("--> {.file ", names(emails_list), "}: ", unlist(emails_list))
5353
names(msg) <- rep(" ", length(msg))
5454
err <- paste0("The following data files contain emails with potential PII:")
5555

5656
cli::cli_warn(c("!" = err, msg))
57-
#if no pii emails (non .gov), pass test:
57+
# if no pii emails (non .gov), pass test:
5858
} else {
5959
cli::cli_inform(
60-
c("v" = "Data files do not appear to contain any personal emails."))
60+
c("v" = "Data files do not appear to contain any personal emails.")
61+
)
6162
}
62-
#return(invisible(metadata))
63+
# return(invisible(metadata))
6364
}

0 commit comments

Comments
 (0)