pharmaR / riskmetric

Metrics to evaluate the risk of R packages
https://pharmar.github.io/riskmetric/
Other
156 stars 29 forks source link

Assessing Dependencies Bug #306

Open Jeff-Thompson12 opened 11 months ago

Jeff-Thompson12 commented 11 months ago

https://github.com/pharmaR/riskmetric/blob/3d1501880edc07cff5cd72129c0df0899db83029/R/assess_dependencies.R#L107

Found this bug when a package only has one of the three fields (e.g. only list "Imports" with no "LinkingTo" or "Depends"). Easily remedied with sapply(strsplit(deps, ","), trimws, simplify = FALSE).

dgkf commented 11 months ago

I think if setting simplify = FALSE on sapply, then you might as well convert to lapply.

In general, I would highly recommend replacing all uses of sapply with lapply's or vapply's.

From Advanced R:

Base R has two apply functions that can return atomic vectors: sapply() and vapply(). I recommend that you avoid sapply() because it tries to simplify the result, so it can return a list, a vector, or a matrix. This makes it difficult to program with, and it should be avoided in non-interactive settings

If it helps to cut down on the boilerplate, I'd also recommend adopting this pattern to pre-define vapply flavors used in many of the r-lib packages.

Robert-Krajcik commented 10 months ago

If you are looking for a package to test, here is the DESCRIPTION file for package {abc} riskmetric::assess_dependencies() fails on this one.

Package: abc
Type: Package
Title: Tools for Approximate Bayesian Computation (ABC)
Version: 2.2.1
Date: 2022-05-17
Authors@R: c( 
    person("Csillery", "Katalin", role = "aut", email="kati.csillery@gmail.com"),
    person("Lemaire", "Louisiane", role = "aut"),
    person("Francois", "Olivier", role = "aut"),
    person("Blum", "Michael",
    email = "michael.blum.temp@gmail.com", role = c("aut", "cre")))
Depends: R (>= 2.10), abc.data, nnet, quantreg, MASS, locfit
Description: Implements several ABC algorithms for
        performing parameter estimation, model selection, and goodness-of-fit.
        Cross-validation tools are also available for measuring the
        accuracy of ABC estimates, and to calculate the
        misclassification probabilities of different models.
Repository: CRAN
License: GPL (>= 3)
NeedsCompilation: no
Packaged: 2022-05-18 18:46:30 UTC; mblum
Author: Csillery Katalin [aut],
  Lemaire Louisiane [aut],
  Francois Olivier [aut],
  Blum Michael [aut, cre]
Maintainer: Blum Michael <michael.blum.temp@gmail.com>
Date/Publication: 2022-05-19 07:20:02 UTC
AARON-CLARK commented 5 months ago

Bumping this issue with a +1