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

New check idea: RCurl or XML dependency #44

Closed
maelle opened this issue Sep 10, 2021 · 14 comments
Closed

New check idea: RCurl or XML dependency #44

maelle opened this issue Sep 10, 2021 · 14 comments

Comments

@maelle
Copy link
Contributor

maelle commented Sep 10, 2021

No description provided.

@mpadge
Copy link
Member

mpadge commented Sep 10, 2021

Would you like to give it a go? That's important enough to be included in #' @return Cross only form.

@maelle
Copy link
Contributor Author

maelle commented Sep 10, 2021

I will do that next week! 😺

@maelle
Copy link
Contributor Author

maelle commented Sep 14, 2021

Dev guide ref: https://devguide.ropensci.org/building.html#recommended-scaffolding

Packages to avoid are therefore RCurl, XML, rjson, RJSONIO.

@maelle
Copy link
Contributor Author

maelle commented Sep 14, 2021

In practice, how to extract dependencies

@mpadge
Copy link
Member

mpadge commented Sep 14, 2021

They're already part of the pkgstats output:

# in `pkgcheck` directory:
s <- pkgstats::pkgstats ()
s$desc [, c ("depends", "imports", "suggests")] # it's a one-row data.frame
#>   depends
#> 1      NA
#>                                                                                                                              imports
#> 1 cli, covr, curl, gert, ghql, goodpractice, httr, jsonlite, magrittr, methods, pkgstats, rappdirs, roxygen2, rvest, srr, visNetwork
#>                                      suggests
#> 1 callr, knitr, pkgbuild, rmarkdown, testthat

Created on 2021-09-14 by the reprex package (v2.0.0.9000)

@maelle
Copy link
Contributor Author

maelle commented Sep 14, 2021

Ah good!

@maelle
Copy link
Contributor Author

maelle commented Sep 24, 2021

Noting that this check will not check the recursive deps

@mpadge
Copy link
Member

mpadge commented Sep 24, 2021

No, of course not, recursive dep checks are and should always remain beyond scope here.

@maelle
Copy link
Contributor Author

maelle commented Sep 24, 2021

I fully agree! Although I started wondering about ways to identify weaknesses in the dependencies stack 😁

@mpadge
Copy link
Member

mpadge commented Sep 24, 2021

One start is new pkgstats checks which I've just finished. Now gets even more information than the comment linked above, which now looks something like this:

library (pkgstats)
packageVersion ("pkgstats")
#> [1] '0.0.1.27'
u <- "https://cran.r-project.org/src/contrib/dplyr_1.0.7.tar.gz"
path <- file.path (tempdir (), tail (strsplit (u, "\\/") [[1]], 1))
download.file (u, destfile = path)

s <- pkgstats (path)
nrow (s$external_calls)
#> [1] 2537
x <- strsplit (pkgstats_summary (s)$external_calls, ",") [[1]]
x <- do.call (rbind, strsplit (x, ":"))
x <- data.frame (pkg = x [, 1],
                 n_total = as.integer (x [, 2]),
                 n_unique = as.integer (x [, 3]))
x$n_total_rel <- round (x$n_total / sum (x$n_total), 3)
x$n_unique_rel <- round (x$n_unique / sum (x$n_unique), 3)
x <- x [order (x$n_total, decreasing = TRUE), ]
rownames (x) <- NULL
print (x)
#>           pkg n_total n_unique n_total_rel n_unique_rel
#> 1       dplyr    1404      651       0.553        0.784
#> 2        base     927      139       0.365        0.167
#> 3       utils      72        3       0.028        0.004
#> 4    generics      31        2       0.012        0.002
#> 5       stats      26        6       0.010        0.007
#> 6  tidyselect      20        4       0.008        0.005
#> 7    graphics      11        5       0.004        0.006
#> 8     methods      11        3       0.004        0.004
#> 9       vctrs       6        2       0.002        0.002
#> 10     dbplyr       5        1       0.002        0.001
#> 11   ellipsis       5        1       0.002        0.001
#> 12      rlang       4        3       0.002        0.004
#> 13        DBI       3        1       0.001        0.001
#> 14     lobstr       3        2       0.001        0.002
#> 15     tibble       3        2       0.001        0.002
#> 16         R6       2        1       0.001        0.001
#> 17     `dplyr       1        1       0.000        0.001
#> 18  lifecycle       1        1       0.000        0.001
#> 19    RSQLite       1        1       0.000        0.001
#> 20   testthat       1        1       0.000        0.001

Created on 2021-09-24 by the reprex package (v2.0.1.9000)

You get full info on every function called from every package. RCurl and XML are examples of packages which simply should not be used, but in other cases where packages have been superseded but may still contain auxiliary functions which have no direct replacement, we now have a way to check that. And an even more powerful way to analyse weaknesses in a dependency stack.

@maelle
Copy link
Contributor Author

maelle commented Sep 24, 2021

so cool! I remember that from https://github.com/r-lib/itdepends

@mpadge
Copy link
Member

mpadge commented Nov 19, 2021

Re-opening to extended the check to include a print method reflecting ropensci/software-review-meta#47. If any of the obsolete spatial packages are included, print a message identifying which ones, and linking to the scaffolding section for potential replacements.

@mpadge
Copy link
Member

mpadge commented Nov 19, 2021

The new print methods are at the very end of the checks.

  • The has_scrap causes an ":heavy_multiplication_x: unexpected files" in the summary, with details in print.
  • The obsolute_pkg_deps checks identify an internal list of merely potentially obsolete packages which are only reported on in print method (currently just the spatial ones).
library (pkgcheck)
f <- system.file ("extdata", "pkgstats_9.9.tar.gz", package = "pkgstats")
path <- pkgstats::extract_tarball (f)
checks <- pkgcheck (path, goodpractice = FALSE)
checks$checks$has_scrap <- c ("a", "b")
checks$checks$obsolete_pkg_deps <- c ("blah", "sp", "rgdal")
print (checks)
#> Loading required namespace: goodpractice
#> 
#> ── pkgstats 9.9 ────────────────────────────────────────────────────────────────
#> 
#> ✔ Package name is available
#> ✔ has a 'CITATION' file.
#> ✖ Package depends on the following obsolete packages: [blah]
#> ✖ does not have a 'codemeta.json' file.
#> ✖ does not have a 'contributing' file.
#> ✔ uses 'roxygen2'.
#> ✔ 'DESCRIPTION' has a URL field.
#> ✔ 'DESCRIPTION' has a BugReports field.
#> ✖ Package has no HTML vignettes
#> ✖ These functions do not have examples: [pkgstats_from_archive.Rd].
#> ✔ Package has continuous integration checks.
#> ✖ Package contains unexpected files.
#> 
#> ℹ Current status:
#> ✖ This package is not ready to be submitted.
#> 
#> 
#> ── git ──
#> 
#> • HEAD:
#> • Default branch:
#> • Number of commits:
#> • First commit:
#> • Number of authors:
#> 
#> 
#> ── Package Structure ──
#> 
#> ℹ Package uses the following languages:
#> • C++: 9%
#> • R: 91%
#> 
#> ℹ Package has
#> • 1 author.
#> • 0 vignettes.
#> • No internal data
#> • 9 imported packages.
#> • 11 exported functions (median 43 lines of code).
#> • 120 non-exported functions (median 21 lines of code).
#> • 12 C++ functions (median 16 lines of code).
#> • 1 parameters per function (median).
#> 
#> ── All statistics
#>                    measure  value percentile noteworthy
#> 1                  files_R   19.0       77.9           
#> 2                files_src    3.0       82.9           
#> 4          files_vignettes    0.0        0.0       TRUE
#> 5              files_tests    7.0       83.7           
#> 6                    loc_R 2698.0       88.6           
#> 7                  loc_src  277.0       29.5           
#> 8                loc_tests  266.0       58.4           
#> 9            num_vignettes    0.0        0.0       TRUE
#> 12                 n_fns_r  131.0       78.1           
#> 13        n_fns_r_exported   11.0       45.5           
#> 14    n_fns_r_not_exported  120.0       82.1           
#> 15               n_fns_src   12.0       83.7           
#> 16        n_fns_per_file_r    3.8       52.3           
#> 17      n_fns_per_file_src    4.0       36.9           
#> 18       num_params_per_fn    1.0        1.1       TRUE
#> 19            loc_per_fn_r   23.0       77.1           
#> 20        loc_per_fn_r_exp   43.0       76.8           
#> 21    loc_per_fn_r_not_exp   21.5       79.5           
#> 22          loc_per_fn_src   16.0       61.3           
#> 23        rel_whitespace_R   18.8       88.1           
#> 24      rel_whitespace_src   24.2       85.5           
#> 25    rel_whitespace_tests   27.1       85.0           
#> 26     doclines_per_fn_exp   31.0       34.6           
#> 27 doclines_per_fn_not_exp    0.0        0.0       TRUE
#> 28    fn_call_network_size  104.0       77.8
#> 
#> ℹ Package network diagram is at [.../pkgstats_pkgstats.html].
#> 
#> 
#> ── goodpractice ──
#> 
#> ℹ 'goodpractice' not included with these checks
#> 
#> ── Other checks ──
#> 
#> ✖ Package contains the following unexpected files:
#>   • a
#>   • b
#> ✖ Package contains the following (potentially) obsolete packages:
#>   • sp
#>   • rgdal
#> 
#> See our [Recommended
#> Scaffolding](https://devguide.ropensci.org/building.html?q=scaffol#recommended-scaffolding)
#> for alternatives.
#> 
#> ── Package Versions ──
#> 
#>   pkgstats: 0.0.3.51
#>   pkgcheck: 0.0.2.135

Created on 2021-11-19 by the reprex package (v2.0.1.9000)

Re-opening now to also update the markdown output to reflect this console output.

@mpadge mpadge reopened this Nov 19, 2021
@mpadge mpadge closed this as completed in 779ff99 Nov 19, 2021
@mpadge
Copy link
Member

mpadge commented Nov 19, 2021

Checks for pkgstats (v0.0.3.051)

git hash: 8d4e7e70

  • ✔️ Package name is available
  • ✔️ has a 'CITATION' file.
  • ✖️ Package depends on the following obsolete packages: [blah]
  • ✔️ has a 'codemeta.json' file.
  • ✔️ has a 'contributing' file.
  • ✔️ uses 'roxygen2'.
  • ✔️ 'DESCRIPTION' has a URL field.
  • ✔️ 'DESCRIPTION' has a BugReports field.
  • ✖️ Package has no HTML vignettes
  • ✖️ These functions do not have examples: [pkgstats_from_archive.Rd].
  • ✔️ Package has continuous integration checks.
  • ✔️ Package coverage is 86.7%.
  • ✖️ Package contains unexpected files.
  • ✔️ R CMD check found no errors.
  • ✔️ R CMD check found no warnings.

Important: All failing checks above must be addressed prior to proceeding

Package License: GPL-3


1. Statistical Properties

This package features some noteworthy statistical properties which may need to be clarified by a handling editor prior to progressing.

Details of statistical properties (click to open)

The package has:

  • code in C++ (9% in 3 files) and R (91% in 19 files)
  • 1 authors
  • no vignette
  • no internal data file
  • 9 imported packages
  • 11 exported functions (median 43 lines of code)
  • 120 non-exported functions in R (median 21 lines of code)
  • 12 R functions (median 16 lines of code)

Statistical properties of package structure as distributional percentiles in relation to all current CRAN packages
The following terminology is used:

  • loc = "Lines of Code"
  • fn = "function"
  • exp/not_exp = exported / not exported

The final measure (fn_call_network_size) is the total number of calls between functions (in R), or more abstract relationships between code objects in other languages. Values are flagged as "noteworthy" when they lie in the upper or lower 5th percentile.

measure value percentile noteworthy
files_R 19 77.9
files_src 3 82.9
files_vignettes 0 0.0 TRUE
files_tests 6 81.5
loc_R 2698 88.6
loc_src 277 29.5
loc_tests 145 44.6
num_vignettes 0 0.0 TRUE
n_fns_r 131 78.1
n_fns_r_exported 11 45.5
n_fns_r_not_exported 120 82.1
n_fns_src 12 83.7
n_fns_per_file_r 4 52.3
n_fns_per_file_src 4 36.9
num_params_per_fn 1 1.1 TRUE
loc_per_fn_r 23 77.1
loc_per_fn_r_exp 43 76.8
loc_per_fn_r_not_exp 22 79.5
loc_per_fn_src 16 61.3
rel_whitespace_R 19 88.1
rel_whitespace_src 24 85.5
rel_whitespace_tests 31 80.6
doclines_per_fn_exp 23 19.0
doclines_per_fn_not_exp 0 0.0 TRUE
fn_call_network_size 104 77.8

1a. Network visualisation

Click to see the interactive network visualisation of calls between objects in package


2. goodpractice and other checks

Details of goodpractice and other checks (click to open)

3a. Continuous Integration Badges

github

GitHub Workflow Results

name conclusion sha date
pkgdown success 8d4e7e 2021-11-17
R-CMD-check failure 8d4e7e 2021-11-17
test-coverage success 8d4e7e 2021-11-17

3b. goodpractice results

R CMD check with rcmdcheck

rcmdcheck found no errors, warnings, or notes

Test coverage with covr

Package coverage: 86.7

Cyclocomplexity with cyclocomp

No functions have cyclocomplexity >= 15

Static code analyses with lintr

lintr found the following 496 potential issues:

message number of times
Avoid changing the working directory, or restore it in on.exit 2
Lines should not be more than 80 characters. 494


3. Other Checks

✖️ Package contains the following unexpected files:

  • a
  • b

✖️ Package contains the following (potentially) obsolete packages:

  • sp
  • rgdal

See our Recommended Scaffolding for alternatives.


Package Versions

package version
pkgstats 0.0.3.51
pkgcheck 0.0.2.139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants