Skip to content

Fix NA-in-coercion-to-boolean error in LinkNormalization() (cause of CRAN archival) - #85

Open
tamirlibel wants to merge 1 commit into
salimk:masterfrom
tamirlibel:fix/link-normalization-gsub-na-error
Open

Fix NA-in-coercion-to-boolean error in LinkNormalization() (cause of CRAN archival)#85
tamirlibel wants to merge 1 commit into
salimk:masterfrom
tamirlibel:fix/link-normalization-gsub-na-error

Conversation

@tamirlibel

Copy link
Copy Markdown

Summary

  • This package was archived from CRAN on 2025-04-04 because its documentation examples errored out with Error in gsub(...): NA in coercion to boolean, traced to LinkNormalization -> grepl -> paste0 -> gsub.
  • Root cause: two gsub() calls in R/LinkNormalization.R had a stray 4th positional argument (".*") that was landing on gsub's ignore.case parameter instead of being part of the surrounding paste0() regex string. as.logical(".*") is NA, which R's internal gsub rejects with a hard error. This broke LinkNormalization(), and by extension LinkExtractor() and Rcrawler(), on every call.
  • Fix: move the ".*" out of the gsub() calls and into the enclosing paste0() where it was clearly intended, restoring the original regex-building logic.
  • Also removed a stray LazyData: TRUE in DESCRIPTION (no data/ directory exists) and added .Rbuildignore entries for .travis.yml and the unfilled LICENSE template, clearing the remaining R CMD check NOTEs.

Test plan

  • Ran the LinkNormalization() @examples block directly — previously crashed with NA in coercion to boolean, now returns correctly normalized URLs.
  • Ran devtools::check(cran = TRUE) (R CMD check --as-cran) on R 4.6.0 — before: 1 error (examples), 2 notes; after: 0 errors, 0 warnings, 0 notes.

Fixing this should let a resubmission to CRAN pass the automated checks that led to archival.

Two gsub() calls passed a stray fourth positional argument (".*")
that landed on gsub's ignore.case parameter instead of the intended
paste0() regex string, causing as.logical(".*") -> NA and a hard
error ("NA in coercion to boolean"). This broke LinkNormalization(),
and by extension LinkExtractor() and Rcrawler(), and is why the
package's CRAN examples failed and the package was archived from
CRAN on 2025-04-04.

Also drop the stray LazyData: TRUE (no data/ directory exists) and
add .Rbuildignore entries for .travis.yml and the unfilled LICENSE
template, clearing the remaining R CMD check NOTEs.

Verified with a clean R CMD check --as-cran: 0 errors, 0 warnings, 0 notes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant