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

Introduce deprecated_function_linter() #1386

Open
IndrajeetPatil opened this issue Jun 12, 2022 · 6 comments
Open

Introduce deprecated_function_linter() #1386

IndrajeetPatil opened this issue Jun 12, 2022 · 6 comments
Labels
feature a feature request or enhancement new-linter

Comments

@IndrajeetPatil
Copy link
Collaborator

As discussed in #1377.

This linter will mostly centre around packages that assign lifecycle stages for functions (testthat, tidyverse, etc.).

@AshesITR
Copy link
Collaborator

Is there maybe a way to programmatically extract this lifecycle information from packages?

@IndrajeetPatil
Copy link
Collaborator Author

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")`

@AshesITR
Copy link
Collaborator

It seems the first call in the function should also be to lifecycle.

@AshesITR
Copy link
Collaborator

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

@AshesITR AshesITR added the feature a feature request or enhancement label Jun 13, 2022
@AshesITR
Copy link
Collaborator

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.

@IndrajeetPatil
Copy link
Collaborator Author

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

https://github.com/moodymudskipper/now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement new-linter
Projects
None yet
Development

No branches or pull requests

3 participants