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

Deprecate and remove old mocking functions #1986

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

hadley
Copy link
Member

@hadley hadley commented Aug 23, 2024

No description provided.

@hadley hadley changed the title Deprecate old mocking functions Deprecate and remove old mocking functions Nov 15, 2024
@hadley
Copy link
Member Author

hadley commented Jan 10, 2025

Code used to inform users:

library(gh)
library(purrr)
library(dplyr)

packages <-tribble(
  ~package, ~github_url,
  "countdown", "https://github.com/gadenbuie/countdown",
  "covr", "https://github.com/r-lib/covr",
  "crossmap", "https://github.com/rossellhayes/crossmap",
  "crplyr", "https://github.com/Crunch-io/crplyr",
  "crunch", "https://github.com/Crunch-io/rcrunch",
  "crunchy", "https://github.com/Crunch-io/crunchy",
  "cyphr", "https://github.com/ropensci/cyphr",
  "datarobot", NA,
  "dendextend", "https://github.com/talgalili/dendextend",
  "digitize", "https://github.com/tpoisot/digitize",
  "distro", NA,
  "dRiftDM", "https://github.com/bucky2177/dRiftDM",
  "DSMolgenisArmadillo", "https://github.com/molgenis/molgenis-r-datashield",
  "gbfs", "https://github.com/simonpcouch/gbfs",
  "gen3sis", "https://github.com/project-Gen3sis/R-package",
  "graphhopper", "https://github.com/crazycapivara/graphhopper-r",
  "gwasrapidd", "https://github.com/ramiromagno/gwasrapidd",
  "hereR", "https://github.com/munterfi/hereR",
  "humanize", "https://github.com/newtux/humanize",
  "ieegio", "https://github.com/dipterix/ieegio",
  "ipaddress", "https://github.com/davidchall/ipaddress",
  "isotracer", NA,
  "JAGStree", "https://github.com/malfly/JAGStree",
  "leaflet.minicharts", NA,
  "learnr", "https://github.com/rstudio/learnr",
  "MakefileR", "https://github.com/krlmlr/MakefileR",
  "manipulateWidget", "https://github.com/rte-antares-rpackage/manipulateWidget",
  "mbbe", "https://github.com/certara/mbbe",
  "metaDigitise", "https://github.com/daniel1noble/metaDigitise",
  "mknapsack", "https://github.com/madedotcom/mknapsack",
  "mockery", "https://github.com/r-lib/mockery",
  "moexer", "https://github.com/x1o/moexer",
  "MolgenisArmadillo", "https://github.com/molgenis/molgenis-r-armadillo",
  "MolgenisAuth", "https://github.com/molgenis/molgenis-r-auth",
  "NasdaqDataLink", "https://github.com/nasdaq/data-link-r",
  "nhlapi", "https://github.com/jozefhajnala/nhlapi",
  "odin", "https://github.com/mrc-ide/odin",
  "opendatatoronto", "https://github.com/sharlagelfand/opendatatoronto",
  "overture", "https://github.com/kurtis-s/overture",
  "owmr", "https://github.com/crazycapivara/owmr",
  "oxcAAR", NA,
  "passport", "https://github.com/alistaire47/passport",
  "patrick", "https://github.com/google/patrick",
  "plumber", "https://github.com/rstudio/plumber",
  "pocketapi", "https://github.com/CorrelAid/pocketapi",
  "projmgr", "https://github.com/emilyriederer/projmgr",
  "Quandl", "https://github.com/quandl/quandl-r",
  "regmedint", "https://github.com/kaz-yos/regmedint",
  "rentrez", "https://github.com/ropensci/rentrez",
  "reportr", "https://github.com/jonclayden/reportr",
  "restez", "https://github.com/ropensci/restez",
  "Rexperigen", "https://github.com/aquincum/Rexperigen",
  "rnbp", "https://github.com/szymanskir/rnbp",
  "rosetteApi", NA,
  "Rpolyhedra", "https://github.com/ropensci/Rpolyhedra",
  "RPresto", "https://github.com/prestodb/RPresto",
  "RTD", "https://github.com/treasure-data/RTD",
  "Ryacas0", "https://github.com/r-cas/ryacas0",
  "shiny.benchmark", "https://github.com/Appsilon/shiny.benchmark",
  "shinyShortcut", NA,
  "skimr", "https://github.com/ropensci/skimr",
  "spaero", "https://github.com/e3bo/spaero",
  "starwarsdb", "https://github.com/gadenbuie/starwarsdb",
  "taxonomizr", "https://github.com/sherrillmix/taxonomizr",
  "texreg", "https://github.com/leifeld/texreg",
  "ThankYouStars", "https://github.com/ksmzn/ThankYouStars",
  "tinyProject", NA,
  "tryCatchLog", "https://github.com/aryoda/tryCatchLog",
  "tuneRanger", NA,
  "uptasticsearch", "https://github.com/uptake/uptasticsearch",
  "WhatIf", "https://github.com/IQSS/WhatIf",
  "ZillowR", NA,
  "zoltr", "https://github.com/reichlab/zoltr"
)
# Function to extract owner/repo from GitHub URL
extract_repo_info <- function(url) {
  parts <- strsplit(gsub("https://github.com/", "", url), "/")[[1]]
  list(owner = parts[1], repo = parts[2])
}

packages_df <- packages %>%
  filter(!is.na(github_url)) %>%
  mutate(
    repo_info = map(github_url, extract_repo_info),
    owner = map_chr(repo_info, "owner"),
    repo = map_chr(repo_info, "repo")
  ) %>%
  select(-repo_info)  # Clean up the intermediate list-column


# Function to create an issue
create_issue <- function(owner, repo) {
  
  tryCatch({
    gh::gh(
      "POST /repos/{owner}/{repo}/issues",
      owner = owner,
      repo = repo,
      title = "with_mock() is going away",
      body = "This is a heads up to let you know that `with_mock()` is deprecated and will be made defunct soon. The API functions that made it work are being removed in R 4.5.0, so we'd suggest that you switch to `with_mocked_bindings()` instead."
    )
    message(sprintf("Successfully created issue for %s/%s", owner, repo))
  }, error = function(e) {
    message(sprintf("Failed to create issue for %s/%s: %s", owner, repo, e$message))
  })
  
  # Sleep to avoid hitting rate limits
  Sys.sleep(.1)
}

walk2(packages_df$owner, packages_df$repo, create_issue)

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