ThinkR-open / checkhelper

A package to help deal with devtools::check outputs
https://thinkr-open.github.io/checkhelper/
Other
34 stars 4 forks source link

False positive when using `find_missing_tags` and `@rdname` #82

Open AlexisDerumigny opened 11 months ago

AlexisDerumigny commented 11 months ago

Hi, thanks for this package it is very helpful!

I am currently preparing a package to submit to CRAN, and I had some false positives when using find_missing_tags. This is related to #42 and #70 but slightly different.

Here is a reprex:

library(checkhelper)

# Create fake package ----
pkg_path <- tempfile(pattern = "pkg.")
dir.create(pkg_path)

# Create fake package
usethis::create_package(pkg_path, open = FALSE)
#> ✔ Setting active project to 'C:/Users/aderumigny/AppData/Local/Temp/Rtmpa8F7P7/pkg.85c6e7e73b5'
#> ✔ Creating 'R/'
#> ✔ Writing 'DESCRIPTION'
#> Package: pkg.85c6e7e73b5
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R (parsed):
#>     * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID)
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
#>     license
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)
#> RoxygenNote: 7.2.3
#> ✔ Writing 'NAMESPACE'
#> ✔ Setting active project to '<no active project>'

# Create function 
cat("
#' My topic
#' @return some kind of value
#' @name hello
NULL

#' @rdname hello
#' @export
my_fun <- function() {
data %>%
filter(col == 3) %>%
mutate(new_col = 1) %>%
ggplot() +
  aes(x, y, colour = new_col) +
  geom_point()
}

", file = file.path(pkg_path, "R", "function.R"))

find_missing_tags(pkg_path)
#> ℹ Loading pkg.85c6e7e73b5
#> Problem: Missing or empty return value for exported functions: my_fun
#> 
#> 
#> 
#> Good! There is no missing `@export` or `@noRd` in your documentation
#> 
#> ℹ Loading pkg.85c6e7e73b5
#> Writing 'NAMESPACE'
#> Writing 'hello.Rd'
#> $package_doc
#> # A tibble: 0 × 0
#> 
#> $data
#> # A tibble: 0 × 0
#> 
#> $functions
#> # A tibble: 1 × 11
#>      id filename  topic has_export has_return return_value has_nord rdname_value
#>   <int> <chr>     <chr> <lgl>      <lgl>      <chr>        <lgl>    <chr>       
#> 1     1 function… my_f… TRUE       FALSE      ""           FALSE    hello       
#> # ℹ 3 more variables: not_empty_return_value <lgl>,
#> #   test_has_export_and_return <chr>, test_has_export_or_has_nord <chr>

I think this is a false positive since I did specify a return value for the topic linked to the function (and the generated .Rd file indeed has a \value part as intended). I think something went wrong with set_correct_return_to_alias but I am not exactly sure what. Maybe this is because I documented NULL which is not recognized as a function?