Skip to content

Commit

Permalink
Eliminate stringsAsFactors (#2755)
Browse files Browse the repository at this point in the history
Fixes #2708
  • Loading branch information
ccani007 authored Aug 15, 2024
1 parent 1d40a80 commit be2fd26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions R/build-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ data_news <- function(pkg, call = caller_env() ) {
} else {
timeline <- NULL
}

purrr::walk2(
sections,
versions,
Expand Down Expand Up @@ -284,7 +284,6 @@ pkg_timeline <- function(package) {
data.frame(
version = names(timeline),
date = as.Date(timeline),
stringsAsFactors = FALSE,
row.names = NULL
)
}
Expand Down
3 changes: 1 addition & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ re_match <- function(text, pattern, perl = TRUE, ...) {
matchstr[ start == -1 ] <- NA_character_

res <- data.frame(
stringsAsFactors = FALSE,
.text = text,
.match = matchstr
)
Expand All @@ -124,7 +123,7 @@ re_match <- function(text, pattern, perl = TRUE, ...) {
groupstr[ gstart == -1 ] <- NA_character_
dim(groupstr) <- dim(gstart)

res <- cbind(groupstr, res, stringsAsFactors = FALSE)
res <- cbind(groupstr, res)
}

names(res) <- c(attr(match, "capture.names"), ".text", ".match")
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-build-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ test_that("news is syntax highlighted once", {
pkg <- local_pkgdown_site()
pkg <- pkg_add_file(pkg, "NEWS.md", c(
"# testpackage 1.0.0.9000",
"```r",
"x <- 1",
"```r",
"x <- 1",
"```"
))
suppressMessages(build_news(pkg, preview = FALSE))
Expand Down Expand Up @@ -117,8 +117,7 @@ test_that("correct timeline for first ggplot2 releases", {
timeline <- pkg_timeline("ggplot2")[1:3, ]
expected <- data.frame(
version = c("0.5", "0.5.1", "0.5.2"),
date = as.Date(c("2007-06-01", "2007-06-09", "2007-06-18")),
stringsAsFactors = FALSE
date = as.Date(c("2007-06-01", "2007-06-09", "2007-06-18"))
)

expect_equal(timeline, expected)
Expand Down

0 comments on commit be2fd26

Please sign in to comment.