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

Can't found use of libraries on custom expressions #207

Closed
latot opened this issue Oct 3, 2023 · 5 comments
Closed

Can't found use of libraries on custom expressions #207

latot opened this issue Oct 3, 2023 · 5 comments

Comments

@latot
Copy link

latot commented Oct 3, 2023

Hi all, I was creating a library with some "types", is a type of expression from the typed library, basically it helps to check if a variable has some propoerties, like the vector to be only integers, a dataframe with some columns, etc, etc.

The code works like this:

sfnetworks_sfnetwork <- typed::as_assertion_factory(function(
    value,
    null_ok = FALSE) {
  if (null_ok && is.null(value)) {
    return(NULL)
  }
  if (!sfnetworks::is.sfnetwork(value)) {
    e <- sprintf(
      "%s\n%s",
      "type mismatch",
      waldo::compare(
        typeof(value),
        "sfnetworks",
        x_arg = "typeof(value)",
        y_arg = "expected"
      )
    )
    stop(e, call. = FALSE)
  }

  value
})

In the package sfnetworks is added as a needed package, but rcmdcheck says:

rcmdcheck::rcmdcheck()
── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file.../DESCRIPTION...preparinggeotypes:checking DESCRIPTION meta-information ...checking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directoriesbuildinggeotypes_0.0.1.tar.gz’
   
── R CMD check ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─  using log directory/tmp/Rtmp6pcvWP/file36fc25c70fe02/geotypes.Rcheck’
─  using R version 4.3.1 (2023-06-16)
─  using platform: x86_64-pc-linux-gnu (64-bit)
─  R was compiled by
       x86_64-pc-linux-gnu-gcc (Gentoo Hardened 12.3.1_p20230526 p2) 12.3.1 20230526
       GNU Fortran (Gentoo Hardened 12.3.1_p20230526 p2) 12.3.1 20230526running under: Gentoo Linuxusing session charset: UTF-8checking for filegeotypes/DESCRIPTION...this is packagegeotypesversion0.0.1’
─  package encoding: UTF-8checking package namespace information ...checking package dependencies (15.2s)
✔  checking if this is a source package ...checking if there is a namespacechecking for executable files ...checking for hidden files and directories ...checking for portable file nameschecking for sufficient/correct file permissionschecking whether packagegeotypescan be installed (1000ms)
✔  checking installed package size ...checking package directorychecking DESCRIPTION meta-information ...checking top-level files ...checking for left-over fileschecking index informationchecking package subdirectories ...checking R files for non-ASCII characters ...checking R files for syntax errors ...checking whether the package can be loaded ...checking whether the package can be loaded with stated dependencies ...checking whether the package can be unloaded cleanly ...checking whether the namespace can be loaded with stated dependencies ...checking whether the namespace can be unloaded cleanly ...checking loading without being on the library search path ...
N  checking dependencies in R code (367ms)
   Namespaces in Imports field not imported from:sf’ ‘sfnetworksAll declared Imports should be used.checking S3 generic/method consistency ...checking replacement functions ...checking foreign function calls ...checking R code for possible problems (767ms)
✔  checking Rd files ...checking Rd metadata ...checking Rd cross-references ...checking for missing documentation entries ...checking for code/documentation mismatches (539ms)
✔  checking Rd \usage sections (340ms)
✔  checking Rd contents ...checking for unstated dependencies in examples ...checking examples ... NONEchecking for unstated dependencies intests...checking tests ...Runningtestthat.R’ (666ms)
✔  checking PDF version of manual (1.6s)
   
   See/tmp/Rtmp6pcvWP/file36fc25c70fe02/geotypes.Rcheck/00check.logfor details.
   
   
── R CMD check results ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── geotypes 0.0.1 ────
Duration: 23.7schecking dependencies in R code ... NOTE
  Namespaces in Imports field not imported from:sf’ ‘sfnetworksAll declared Imports should be used.

0 errors| 0 warnings| 1 note

Seems if some libraries are used inside some expressions rcmdcheck does not detect it.

There is a sf warning too, because there is other function in my lib the uses it.

Thx!

@gaborcsardi
Copy link
Member

What do you get with R CMD check?

@jennybc
Copy link
Member

jennybc commented Oct 3, 2023

(I was already writing this when @gaborcsardi posted.)

There are some syntactical irregularities above.

But let's assume that's a matter of issue authoring?

There are two main things to know:

  1. The rcmdcheck package runs R CMD check under the hood. So it's transmitting the results of checks maintained in base R, not in this package. If you build and check your package without using rcmdcheck, you'll see the same result.
  2. There are definitely cases where a package uses another package, but R CMD check can't detect it. That is addressed here in the R Packages book: https://r-pkgs.org/dependencies-in-practice.html#how-to-not-use-a-package-in-imports

@latot
Copy link
Author

latot commented Oct 3, 2023

mmm, I know the syntax is the best, that is the smaller version, first, I'll update the main post with other code that is easier to check with the full logs.

Now, the libs are not used indirectly, they are in the code, now you can see it.

I didn't know rcmdcheck only capture the results, which is the best place to report this?

Thx!

@jennybc
Copy link
Member

jennybc commented Oct 3, 2023

which is the best place to report this?

You'd have to report as a bug in base R or open a discussion on a mailing list. But if I were you, I'd use the technique described in the reference above to silence the NOTE and just let it go.

@latot
Copy link
Author

latot commented Oct 3, 2023

D: Okis, thx for the suggestion, if is not worth report it, I'll go with that options :)

Thx!

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

No branches or pull requests

3 participants