Skip to content

Commit b40e0b8

Browse files
lint files
1 parent 6acd614 commit b40e0b8

File tree

6 files changed

+359
-244
lines changed

6 files changed

+359
-244
lines changed

.lintr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
linters: with_defaults(assignment_linter = NULL, line_length_linter = NULL)

r_regex_tester/global.R

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
rm(list=ls())
2-
options(shiny.trace=FALSE)
1+
rm(list = ls())
2+
options(shiny.trace = FALSE)
33

44
library(shiny)
55
library(shinyBS)
@@ -12,38 +12,53 @@ library(htmltools)
1212
source("helper_functions.R")
1313
source("regexplainer.R")
1414

15-
buy_me_stuff_button_html <- sample(c('www/buy_me_coffee_button.html',
16-
'www/buy_me_beer_button.html'),
15+
buy_me_stuff_button_html = sample(c("www/buy_me_coffee_button.html",
16+
"www/buy_me_beer_button.html"),
1717
size = 1)
1818

19-
safe_slashes <- purrr::possibly(half_slashes, otherwise = NULL, quiet=FALSE)
20-
safe_highlight_test_str <- purrr::possibly(highlight_test_str, otherwise = NULL, quiet=FALSE)
21-
safe_html_format_match_list <- purrr::possibly(html_format_match_list, otherwise = NULL, quiet=FALSE)
22-
safe_get_match_list <- purrr::possibly(get_match_list, otherwise = NULL, quiet=FALSE)
23-
safe_regexplain <- purrr::possibly(regexplain, otherwise = NULL, quiet=FALSE)
19+
purr_possibly = function(.f, otherwise = NULL, quiet=FALSE) {
20+
purrr::possibly(.f, otherwise = otherwise, quiet = quiet)
21+
}
22+
23+
safe_slashes = purr_possibly(half_slashes)
24+
safe_highlight_test_str = purr_possibly(highlight_test_str)
25+
safe_html_format_match_list = purr_possibly(html_format_match_list)
26+
safe_get_match_list = purr_possibly(get_match_list)
27+
safe_regexplain = purr_possibly(regexplain)
28+
29+
highlight_color_pallete = "Set3"
30+
2431

25-
highlight_color_pallete <- "Set3"
32+
mgsub = function(pattern, replacement, text.var, leadspace = FALSE,
33+
trailspace = FALSE, fixed = TRUE, trim = TRUE,
34+
order.pattern = fixed, ...) {
35+
#' @description I wanted qdap::mgsub() w/o having to have full qdap package,
36+
#' which has had issues deploying around rJava i think...
2637

27-
mgsub = function (pattern, replacement, text.var, leadspace = FALSE, trailspace = FALSE,
28-
fixed = TRUE, trim = TRUE, order.pattern = fixed, ...) {
2938
if (leadspace | trailspace)
30-
replacement <- spaste(replacement, trailing = trailspace, leading = leadspace)
31-
39+
replacement = spaste(replacement,
40+
trailing = trailspace,
41+
leading = leadspace)
42+
3243
if (fixed && order.pattern) {
33-
ord <- rev(order(nchar(pattern)))
34-
pattern <- pattern[ord]
44+
ord = rev(order(nchar(pattern)))
45+
pattern = pattern[ord]
3546
if (length(replacement) != 1)
36-
replacement <- replacement[ord]
47+
replacement = replacement[ord]
3748
}
3849
if (length(replacement) == 1)
39-
replacement <- rep(replacement, length(pattern))
40-
50+
replacement = rep(replacement, length(pattern))
51+
4152
for (i in seq_along(pattern)) {
42-
text.var <- gsub(pattern[i], replacement[i], text.var, fixed = fixed, ...)
53+
text.var = gsub(pattern[i], replacement[i], text.var, fixed = fixed, ...)
4354
}
44-
55+
4556
if (trim)
46-
text.var <-
47-
gsub("\\s+", " ", gsub("^\\s+|\\s+$", "", text.var, perl = TRUE), perl = TRUE)
57+
text.var = gsub(
58+
"\\s+",
59+
" ",
60+
gsub("^\\s+|\\s+$", "", text.var, perl = TRUE),
61+
perl = TRUE
62+
)
4863
text.var
4964
}

0 commit comments

Comments
 (0)