
# Unit test: detect hard-coded absolute paths in the code

library(lintr)

detect_hardcoded_paths <- function() {
  
  # Define the directories to check
  directories <- c("modules", "tools")
  
  # Apply absolute_path_linter() to each directory and save results
  files_with_issues <- lapply(directories, function(dir) {
    lint_dir(path = dir, linters = absolute_path_linter(lax = TRUE))
  })

  # Check results and print out the test outcome
  if (length(files_with_issues) > 0) {
    cat("Test FAILED. Hard-coded paths found:\n")
    print(files_with_issues)
    return(FALSE)
  } else {
    cat("Test PASSED😊 No hard-coded paths found in any file.\n")
    return(TRUE)
  }
}

detect_hardcoded_paths()
