Open IndrajeetPatil opened 2 years ago
Is there maybe a way to programmatically extract this lifecycle information from packages?
Yeah, I was thinking the same.
Probably via .Rd
files because a function is marked as deprecated using the following code in the docs:
#' `r lifecycle::badge("deprecated")`
It seems the first call in the function should also be to lifecycle
.
Seems like if we loadNamespace()
the required packages, we can inspect the functions to see if their call graph unconditionally hits a (known) deprecation function:
body(testthat::expect_that)[[2]][[1]]
#> edition_deprecate
body(survival::survConcordance)[[3]][[1]]
#> .Deprecated
body(tibble::data_frame)[[2]][[1]]
#> deprecate_warn
I just discovered lifecycle::lint_lifecycle()
Maybe we can convince lifecycle
to export lifecycle_linter()
?
That means the deprecated_function_linter()
could focus on other lifecycle management styles, e.g. .Deprecated()
or the style used in testthat.
A few resources to consider here, which would help us with implementation:
{pkgdown}
has a utility to extract lifecycle badge:https://github.com/r-lib/pkgdown/blob/0ba8cb6c68c098a0d1d780052758da5ac9f83e3a/R/package.R#L188
{now}
detects and removes functions of given lifecycle from the namespace’s exports
As discussed in https://github.com/r-lib/lintr/pull/1377.
This linter will mostly centre around packages that assign lifecycle stages for functions (testthat, tidyverse, etc.).