The custom linters of diseasy
Examples
diseasy_code_linters()
#> [[1]]
#> function (source_expression)
#> {
#> if (!lintr::is_lint_level(source_expression, "file")) {
#> return(list())
#> }
#> detection_info <- stringr::str_locate_all(source_expression$file_lines,
#> stringr::regex("[^\\x00-\\x7f]", ignore_case = TRUE))
#> detection_info <- purrr::map2(detection_info, seq_along(detection_info),
#> ~dplyr::mutate(as.data.frame(.x), line_number = .y))
#> detection_info <- dplyr::filter(purrr::reduce(detection_info,
#> rbind), !is.na(.data$start))
#> purrr::pmap(detection_info, function(start, end, line_number) {
#> lintr::Lint(filename = source_expression$filename, line_number = line_number,
#> column_number = start, type = "style", message = paste(general_msg,
#> "non-ASCII character found"), line = source_expression$file_lines[line_number],
#> ranges = list(c(start, end)))
#> })
#> }
#> <bytecode: 0x564c0a421e50>
#> <environment: 0x564c0a418f38>
#> attr(,"class")
#> [1] "linter" "function"
#> attr(,"name")
#> [1] "non_ascii_linter"
#>
#> [[2]]
#> function (source_expression)
#> {
#> if (!lintr::is_lint_level(source_expression, "file")) {
#> return(list())
#> }
#> todo_info <- stringr::str_locate_all(source_expression$file_lines,
#> stringr::regex("(?<=\\s|^)todos?:?(?=\\s|$)", ignore_case = TRUE))
#> todo_info <- dplyr::filter(purrr::reduce(purrr::map2(todo_info,
#> seq_along(todo_info), ~dplyr::mutate(as.data.frame(.x),
#> line_number = .y)), rbind), !is.na(.data$start))
#> purrr::pmap(todo_info, function(start, end, line_number) {
#> lintr::Lint(filename = source_expression$filename, line_number = line_number,
#> column_number = start, type = "style", message = paste(general_msg,
#> "`TODO` statement found"), line = source_expression$file_lines[line_number],
#> ranges = list(c(start, end)))
#> })
#> }
#> <bytecode: 0x564c0f750248>
#> <environment: 0x564c0f7539f8>
#> attr(,"class")
#> [1] "linter" "function"
#> attr(,"name")
#> [1] "todo_linter"
#>