Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong regex in valid_package_name_regexp #61

Closed
KevCaz opened this issue May 12, 2020 · 2 comments
Closed

Wrong regex in valid_package_name_regexp #61

KevCaz opened this issue May 12, 2020 · 2 comments

Comments

@KevCaz
Copy link
Contributor

KevCaz commented May 12, 2020

Here are two examples where I think valid_package_name() is misbehaving.

R> valid_package_name("!r2!")
Name valid:
R> valid_package_name("!r2 _ r2!")
Name valid:

According to https://cran.r-project.org/doc/manuals/r-release/R-exts.html#The-DESCRIPTION-file

This should contain only (ASCII) letters, numbers and dot, have at least two characters and start with a letter and not end in a dot

so my understanding is that ^ and $ are missing in valid_package_name_regexp (and so in standard_regexps()$valid_package_name)

valid_package_name2 <- function(name) {

  # This is the algorithm used in R CMD check at
  # https://github.com/wch/r-source/blob/a3a73a730962fa214b4af0ded55b497fb5688b8b/src/library/tools/R/QC.R#L3214
  valid <- TRUE

  # check for a package called 'R'
  res <- if (tolower(name) == "r") {
    FALSE
  } else {
    grepl(glue::glue("^{valid_package_name_regexp}$"), name)
  }
  structure(res, class = "available_valid_name")
}

now

R> valid_package_name2("!r2!")
Name valid:R> valid_package_name2("!r2 _ r2!")
Name valid:R> valid_package_name2("r2")
Name valid:

If this is right and useful, I can create a PR.

KevCaz pushed a commit to KevCaz/available that referenced this issue Oct 14, 2020
@llrs
Copy link
Contributor

llrs commented Feb 10, 2021

Shouldn't this be closed by #64 ?

@KevCaz
Copy link
Contributor Author

KevCaz commented Feb 10, 2021

Yup. Thanks!

@KevCaz KevCaz closed this as completed Feb 10, 2021
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

No branches or pull requests

2 participants