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

lintr >= 3.0.0 support #180

Merged
merged 8 commits into from
Feb 18, 2025
Merged

lintr >= 3.0.0 support #180

merged 8 commits into from
Feb 18, 2025

Conversation

AshesITR
Copy link
Contributor

@AshesITR AshesITR commented Nov 19, 2023

Still missing some documentation.

NB there are quite a few lints on lifecycle code:

Lints in lifecycle code
R/compat-obj-type.R:58:9: style: [lifecycle_linter] `rlang::is_na` is questioning
    if (is_na(x)) {
        ^~~~~
R/deprecate.R:288:16: style: [lifecycle_linter] `rlang::chr` is questioning
    details <- chr()
               ^~~
R/expect.R:34:27: style: [lifecycle_linter] `rlang::is_na` is questioning
  if (!is_null(regexp) && is_na(regexp)) {
                          ^~~~~
R/lifecycle-package.R:16:3: style: [lifecycle_linter] `rlang::local_use_cli` is experimental
  local_use_cli()
  ^~~~~~~~~~~~~
R/utils.R:10:9: style: [lifecycle_linter] `rlang::chr` is questioning
  paste(chr(...), collapse = "\n")
        ^~~
vignettes/manage.Rmd:34:8: style: [lifecycle_linter] `tibble::data_frame` is deprecated
df1 <- data_frame(x = 1, y = 2)
       ^~~~~~~~~~
vignettes/manage.Rmd:37:8: style: [lifecycle_linter] `tibble::data_frame` is deprecated
df2 <- data_frame(a = "apple", b = "banana")
       ^~~~~~~~~~
vignettes/manage.Rmd:62:8: style: [lifecycle_linter] `tibble::data_frame` is deprecated
df1 <- data_frame(x = 1, y = 2)
       ^~~~~~~~~~
vignettes/manage.Rmd:63:8: style: [lifecycle_linter] `tibble::data_frame` is deprecated
df2 <- data_frame(a = "apple", b = "banana")
       ^~~~~~~~~~
vignettes/manage.Rmd:72:8: style: [lifecycle_linter] `tibble::data_frame` is deprecated
df1 <- data_frame(x = 1, y = 2)
       ^~~~~~~~~~
vignettes/stages.Rmd:52:15: style: [lifecycle_linter] `tibble::data_frame` is deprecated
df <- tibble::data_frame(x = 1)
              ^~~~~~~~~~

@AshesITR
Copy link
Contributor Author

AshesITR commented Nov 19, 2023

fixes #122, #155, #165, #178, #179

@AshesITR
Copy link
Contributor Author

I'm not sure if pkg_lifecycle_statuses() is documented in a good place at ?lifecycle_linter.
Also, pattern= might drift from lintr in the future. It might be worth deprecating the argument and not passing it on?

Users of lintr could simply add linters: linters_with_defaults(lifecycle::lifecycle_linter()) to their configs to include it in the regular workflow.

I also opted to default to tidyverse::tidyverse_packages() for the packages= argument of lifecycle_linter().
This makes lifecycle::lifecycle_linter() behave nicely by default, but implicitly requires tidyverse or a non-missing packages= argument. I could add a check for robustness there if you agree with this behavior.

@@ -7,6 +7,7 @@
^pkgdown$
^lifecycle\.Rproj$
^\.Rproj\.user$
^\.idea$
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB this is for PyCharm

@@ -0,0 +1,2 @@
linter,tags
lifecycle_linter,robustness best_practices configurable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes linters_with_tags("best_practices", packages = "lifecycle") work.

packages = tidyverse::tidyverse_packages(),
which = c("superseded", "deprecated", "questioning", "defunct", "experimental", "soft-deprecated", "retired"),
symbol_is_undesirable = FALSE
) {
Copy link
Contributor Author

@AshesITR AshesITR Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea for future expansion: except = character() arg to explicitly allow some functions.

@AshesITR
Copy link
Contributor Author

cc @hadley LMK if you need anything. I didn't write any tests because there were none before and adding them would require a significant amount of work.

@Moohan
Copy link

Moohan commented Feb 13, 2025

I just installed this version and got this message (red font)

Registered S3 methods overwritten by 'callr':
  method                    from
  format.callr_status_error     
  print.callr_status_error   

Other than that, it works as expected for lifecycle::lint_lifecycle(packages = packages) whereas v1.0.4 does not.

@hadley hadley merged commit 8e9a74c into r-lib:main Feb 18, 2025
@hadley
Copy link
Member

hadley commented Feb 18, 2025

Thanks!

@AshesITR AshesITR deleted the fix/lintr-support branch February 18, 2025 18:34
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.

3 participants