Skip to content

Commit

Permalink
version 0.1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Maarten van Kessel authored and cran-robot committed Jun 16, 2023
1 parent 9923e41 commit 40501eb
Show file tree
Hide file tree
Showing 29 changed files with 469 additions and 97 deletions.
10 changes: 6 additions & 4 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: PaRe
Type: Package
Title: A Way to Perform Code Review or QA on Other Packages
Version: 0.1.9
Version: 0.1.10
Language: en-US
Authors@R:
person("Maarten", "van Kessel", email = "m.l.vankessel@erasmusmc.nl",
Expand All @@ -20,11 +20,13 @@ Imports: cli (>= 3.6.0), cyclocomp (>= 1.1.0), desc (>= 1.4.2),
pak (>= 0.2.0), rmarkdown (>= 2.20), rsvg (>= 2.4.0), stringr
(>= 1.5.0), igraph (>= 1.3.5), utils, R6 (>= 2.5.1), git2r (>=
0.31.0), checkmate (>= 2.1.0)
Suggests: ggplot2, plotly, ggraph, DT, magick, withr, cowplot, knitr
Suggests: ggplot2, plotly, ggraph, DT, magick, withr, cowplot, knitr,
testthat (>= 3.0.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2023-06-12 12:14:34 UTC; mvankessel
Packaged: 2023-06-16 14:37:21 UTC; mvankessel
Author: Maarten van Kessel [aut, cre]
Maintainer: Maarten van Kessel <m.l.vankessel@erasmusmc.nl>
Repository: CRAN
Date/Publication: 2023-06-12 12:30:03 UTC
Date/Publication: 2023-06-16 14:50:02 UTC
42 changes: 28 additions & 14 deletions MD5
@@ -1,15 +1,16 @@
e09ddd1580ba2e63d5a05a4322713403 *DESCRIPTION
1f8872827c5944a4083e3a67e01f02d0 *NAMESPACE
4f3c2760a56948a8c2890621cade4ece *NEWS.md
157d493b8ec1ebc52c399ce32ae53725 *DESCRIPTION
7ce7e89c91aa1cf431f5cecc99b745c9 *NAMESPACE
4551cba1583b3a5c71f94c1b335e94ab *NEWS.md
5c8bca3dc5926d17a2a309d1dbc4c7bf *R/PaRe-package.R
690883c60013852f5e1e67c9e1e20c61 *R/R6-Code.R
9f0aa369b24fc227f2ed394b6a74331e *R/R6-File.R
d25793e59157161699a9e85b28d038c3 *R/R6-Function.R
24f819cfb13f35164527051d1f25ce96 *R/R6-Repository.R
759240826d491eb327652b7ad6de4c1e *R/callInvestigators.R
fbc031d8397fe8efb4d64f6cdc05c7c3 *R/checkDependencies.R
dd0993d10da9e466ba267ffc2a3821fc *R/R6-Function.R
22fa355e3237367cab984a8fa48d7202 *R/R6-Repository.R
eae9034b467cf7b59cc740360860b681 *R/addPareArticle.R
7912f53547507127ab036551abc1472c *R/callInvestigators.R
7f36ee141ef4ff64d18fe4a920653c7c *R/checkDependencies.R
52ccf7d4a66821ba4cc94aa1db884cc7 *R/countPackageLines.R
83cc4f68f21c3bfbf759926af08624c5 *R/getDefaultPermittedPackages.R
fae4f2918fc0dbdd7fc4875343dd30f2 *R/getDefaultPermittedPackages.R
e95fbb0329c0e82edd8ffd93e3bc909e *R/getDefinedFunctions.R
69852b6bfc046756a05a93a2e2d3a023 *R/getFunctionDiagram.R
4d443a770d57ac467518f85be4908f08 *R/getFunctionUse.R
Expand All @@ -23,17 +24,18 @@ cf794928715019cf81bd51d467156178 *R/utils-pipe.R
b29edef0eaedf18b9a00f64e65c4647c *inst/WORDLIST
aeb3de472dbf4860bbea20ecd9ab8497 *inst/doc/Documentation.R
a84e134bd7a35928e8d001467d70c5c2 *inst/doc/Documentation.Rmd
b3e79e0dccf3f9d3f2ae4d5f5ce394ca *inst/doc/Documentation.html
e01df61baf190f92a040c28dde1c8f9b *inst/doc/Documentation.html
d62b3c4c1af50d76ef77784a8cb26bd1 *inst/img/logo.png
a48bb48401b7f3d9405b85111c0a6262 *inst/rmd/ReportInjectable.Rmd
70fbd9c5231bc16201c45c9c271d8f2b *inst/rmd/report.Rmd
ae0c22d8657758a685abc4a70ddffc76 *inst/rmd/ReportInjectable.Rmd
bed6ce49704747db142f98cba8638968 *inst/rmd/report.Rmd
40a1c71111751992f944d14f4c839718 *inst/testScript.R
1c6f840fc50c6d11fd8c53b2cedbdb65 *inst/whiteList.csv
4fe9810cdec58eda3bfd93e477573bf0 *man/Code.Rd
fb1c213c6b9774076e61f655dbb9afc5 *man/File.Rd
e05e6a2583a3a1d45895a14c200d8487 *man/Function.Rd
0b662bfc2940703b4776f7eca130e4d9 *man/PaRe-package.Rd
b77ebe242a5c024c080f6d834e5943fa *man/File.Rd
9bc04719441eaa99b18a3b8727add56c *man/Function.Rd
e4a62c4e74f164ac71ff62a6ebf51486 *man/PaRe-package.Rd
2a106d209f264abd4bb8eba10424d299 *man/Repository.Rd
902f611637db6d22f6b3be2e1b3ae6f0 *man/addPareArticle.Rd
9efdbb8f255557ca0e1aed582a822e4a *man/checkDependencies.Rd
191038bb66a3ca92eb08629a684471fa *man/checkInstalled.Rd
5d24f00a3b1c79f76e517767facab5d9 *man/countPackageLines.Rd
Expand Down Expand Up @@ -67,6 +69,18 @@ d14143c9b0a631d6ee07e9da956d9867 *man/getGraphData.Rd
5ef87067fec0edf62a0670b70e14c467 *man/pkgDiagram.Rd
e0db61bd097f0f30c129ec957562e993 *man/printMessage.Rd
d33e53f5d0121239eb85c6150e326189 *man/whiteList.Rd
32502e0a19a7dba5b947b24955a39d27 *tests/testthat.R
fd919324481ccdcd647a679d1de26afd *tests/testthat/setup.R
b6e151a5e54d5dc34312a481e6c64d7e *tests/testthat/test-addPareArticle.R
6315cb1b1ea84edf3b8d85233271ec6c *tests/testthat/test-checkDependencies.R
9f686ad86c212d391877685b38b5204d *tests/testthat/test-getApplyCall.R
3ced46199bfdc613138a60c3c37cd22f *tests/testthat/test-getApplyFromLines.R
08c6cbd34629e5ea22a1460ec2836ec5 *tests/testthat/test-getDlplyCall.R
04aa0d38401fe145668737f6ea7e9d1c *tests/testthat/test-getDlplyCallFromLines.R
8c63ce7226f879d1a27630df22dc5ebb *tests/testthat/test-getDoCall.R
c9152ed5f259c127d8becfc40464d48f *tests/testthat/test-getDoCallFromLines.R
c37e7ffff7ce12875d2ff4374a4932d5 *tests/testthat/test-getFunCall.R
6670ead09cc590eb2aed1476cb071abd *tests/testthat/test-getMultiLineFun.R
a84e134bd7a35928e8d001467d70c5c2 *vignettes/Documentation.Rmd
08d9d6b171b970059f24dabd6c576712 *vignettes/img/glueDiagram.svg
78c2ea0c0cc50c7ba60892bc9e42e460 *vignettes/img/glueGraph.png
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -4,6 +4,7 @@ export("%>%")
export(File)
export(Function)
export(Repository)
export(addPareArticle)
export(checkDependencies)
export(countPackageLines)
export(exportDiagram)
Expand Down
21 changes: 21 additions & 0 deletions NEWS.md
@@ -1,3 +1,24 @@
PaRe 0.1.10
==========
1. Fixed issue with pattern matching of files in .gitignore.
2. Fixed issue with retrieving the correct amount of arguments from a function.
3. Changed colour highlights for report.
4. Added addPareArticle function to add a PaRe report as an article.
5. Added setup for unittesting.
6. Added unittest for:
- getDefaultPermittedPackages
- addPareArticle
- getApplyCall
- getApplyFromLines
- getDlplyCall
- getDlplyCallFromLines
- getDoCall
- getDoCallFromLines
- getFunCall
- getMultiLineFun
- checkDependencies
7. Fixed issue detecting functions called by plyr::dlply

PaRe 0.1.9
==========
1. Added CRAN badge to README
Expand Down
10 changes: 5 additions & 5 deletions R/R6-Function.R
Expand Up @@ -107,11 +107,11 @@ Function <- R6::R6Class(
return(invisible(self))
},
getNArgs = function() {
nArgs <- private$lines[1] %>%
stringr::str_remove_all(pattern = "\\s") %>%
stringr::str_split_i(pattern = "function\\(", i = 2) %>%
stringr::str_split_i(pattern = "\\)\\{", i = 1) %>%
stringr::str_remove_all(pattern = "\\w+\\(.+\\)") %>%
nArgs <- getMultiLineFun(line = 1, lines = private$lines) %>%
stringr::str_replace_all(pattern = "[ ]?=.+", replacement = ",") %>%
paste0(collapse = "") %>%
stringr::str_split_i(pattern = "function\\(", 2) %>%
stringr::str_split_i(pattern = "\\)[ ]?\\{", 1) %>%
stringr::str_split(pattern = ",") %>%
unlist() %>%
length()
Expand Down
29 changes: 15 additions & 14 deletions R/R6-Repository.R
Expand Up @@ -58,7 +58,7 @@ Repository <- R6::R6Class(
private$git <- git2r::in_repository(private$path)
private$description <- desc::description$new(private$path)
private$functionUse <- NULL
private$gitIgnore <- readLines(file.path(private$path, ".gitignore"), warn = FALSE)
private$gitIgnore <- private$setupGitIgnore()
private$validate()

private$fetchRFiles()
Expand Down Expand Up @@ -207,8 +207,6 @@ Repository <- R6::R6Class(
description = NULL,
functionUse = NULL,
gitIgnore = c(),


validate = function() {
errorMessages <- checkmate::makeAssertCollection()
# .rproj file
Expand All @@ -225,15 +223,22 @@ Repository <- R6::R6Class(
}
return(invisible(self))
},


setupGitIgnore = function() {
ignorePath <- file.path(private$path, ".gitignore")
if (file.exists(ignorePath)) {
gitIgnore <- readLines(ignorePath, warn = FALSE)
gitIgnore <- gitIgnore[!startsWith(x = gitIgnore, prefix = "#")]
gitIgnore <- gitIgnore[!gitIgnore == ""]
gitIgnore <- stringr::str_replace_all(string = gitIgnore, pattern = "\\*", replacement = ".")
private$gitIgnore <- gitIgnore
}
},
filterIgnored = function(paths) {
for (pat in private$gitIgnore) {
paths <- paths[!grepl(pattern = pat, x = paths)]
}
return(paths)
},

fetchRFiles = function() {
paths <- list.files(file.path(private$path, "R"), recursive = TRUE) %>%
private$filterIgnored()
Expand All @@ -243,13 +248,12 @@ Repository <- R6::R6Class(
}))
return(invisible(self))
},


fetchCppFiles = function() {
paths <- list.files(
path = private$path,
pattern = "\\.(cpp|O|h)$",
recursive = TRUE) %>%
recursive = TRUE
) %>%
private$filterIgnored()

cpp <- paths[endsWith(paths, ".cpp")]
Expand All @@ -268,8 +272,6 @@ Repository <- R6::R6Class(
File$new(repoPath = private$path, filePath = path)
})
},


fetchJavaFiles = function() {
paths <- list.files(path = private$path, pattern = "\\.java$", recursive = TRUE)
paths <- paths[endsWith(paths, ".java")] %>%
Expand All @@ -279,13 +281,12 @@ Repository <- R6::R6Class(
File$new(repoPath = private$path, filePath = path)
})
},


fetchSqlFiles = function() {
paths <- list.files(
path = private$path,
pattern = "\\.sql$",
recursive = TRUE) %>%
recursive = TRUE
) %>%
private$filterIgnored()

private$sqlFiles <- lapply(paths, function(path) {
Expand Down
69 changes: 69 additions & 0 deletions R/addPareArticle.R
@@ -0,0 +1,69 @@
#' addPareArticle
#'
#' Writes an Rmd-file to `./vignettes/articles/PaReReport.Rmd`. The relative
#' path is dictated by the specified path in the \link[PaRe]{Repository} object.
#'
#' @param repo (\link[PaRe]{Repository})
#' Repository object.
#'
#' @return `NULL`
#' Writes Rmd-file to ./vignettes/articles/PaReReport.Rmd
#'
#' @export
#'
#' @examples
#' fetchedRepo <- tryCatch(
#' {
#' # Set dir to clone repository to.
#' tempDir <- tempdir()
#' pathToRepo <- file.path(tempDir, "glue")
#'
#' # Clone repo
#' git2r::clone(
#' url = "https://github.com/darwin-eu/IncidencePrevalence.git",
#' local_path = pathToRepo
#' )
#'
#' # Create instance of Repository object.
#' repo <- PaRe::Repository$new(path = pathToRepo)
#'
#' # Set fetchedRepo to TRUE if all goes well.
#' TRUE
#' },
#' error = function(e) {
#' # Set fetchedRepo to FALSE if an error is encountered.
#' FALSE
#' },
#' warning = function(w) {
#' # Set fetchedRepo to FALSE if a warning is encountered.
#' FALSE
#' }
#' )
#'
#' if (fetchedRepo) {
#' # Run makeReport on the Repository object.
#' addPaReArticle(repo)
#' }
addPareArticle <- function(repo) {
injected <- readLines(
con = system.file(package = "PaRe", "rmd", "ReportInjectable.Rmd")
) %>%
gsub(
pattern = "#!P_TITLE",
replacement = glue::glue("{repo$getName()} [{repo$getDescription()$get_version()}]")
) %>%
gsub(
pattern = "#!P_PATH",
replacement = repo$getPath()
)

dir.create(file.path(repo$getPath(), "vignettes", "articles"))

writeLines(
text = injected,
con = file.path(
repo$getPath(), "vignettes", "articles", "PareReport.Rmd"
)
)
return(invisible(NULL))
}
10 changes: 5 additions & 5 deletions R/callInvestigators.R
Expand Up @@ -44,8 +44,8 @@ getDlplyCallFromLines <- function(lines) {
funCall %>%
stringr::str_remove_all("\\s") %>%
stringr::str_split_i(pattern = "dlply\\(", i = 2) %>%
stringr::str_split_i(pattern = ",", i = 4) %>%
stringr::str_extract(pattern = "\\=\\w+") %>%
stringr::str_split_i(pattern = ",", i = 3) %>%
stringr::str_extract(pattern = "[\\=]?\\w+") %>%
stringr::str_extract(pattern = "\\w+")
})
}
Expand Down Expand Up @@ -80,18 +80,18 @@ getDlplyCall <- function(fun, defFuns) {
#'
#' @return (\link[base]{character})
getApplyFromLines <- function(lines) {
pattern <- "[\\w+]?[Aa]pply\\("
pattern <- "[\\w+]?[Aa]pply(LB)?\\("
indices <- grep(pattern, lines)
unlist(lapply(indices, function(index) {
funCall <- paste0(getMultiLineFun(index, lines), collapse = " ")
if (!stringr::str_detect(string = funCall, pattern = "function[ ]?\\(")) {
funCall <- funCall %>%
stringr::str_remove_all(pattern = "(\\s)")

pat <- ",(?=[FUN=]?\\w+?\\w+)"

if (grepl(pattern = "cluster", x = funCall)) {
pat <- ",(?=[FUN=]?\\w+?\\w+\\))"
} else {
pat <- ",(?=[FUN=]?\\w+?\\w+)"
}

funCall <- funCall %>%
Expand Down
4 changes: 1 addition & 3 deletions R/checkDependencies.R
Expand Up @@ -144,9 +144,7 @@ checkDependencies <- function(

dependencies <- description$get_deps() %>%
dplyr::filter(.data$type %in% dependencyType) %>%
dplyr::select("package", "version")

dependencies <- dependencies %>%
dplyr::select("package", "version") %>%
dplyr::filter(.data$package != "R")

dependencies$version <- stringr::str_remove(
Expand Down
21 changes: 10 additions & 11 deletions R/getDefaultPermittedPackages.R
Expand Up @@ -18,26 +18,26 @@
#'
#' @examples
#' \donttest{
#' # Set cache
#' withr::local_envvar(
#' R_USER_CACHE_DIR = tempfile()
#' )
#' # Set cache
#' withr::local_envvar(
#' R_USER_CACHE_DIR = tempfile()
#' )
#'
#' if (interactive()) {
#' getDefaultPermittedPackages()
#' }
#' if (interactive()) {
#' getDefaultPermittedPackages()
#' }
#' }
getDefaultPermittedPackages <- function(base = TRUE) {
# Custom list
tryCatch(
{
customWhiteList <- dplyr::bind_rows(lapply(seq_len(nrow(whiteList)), function(i) {
customWhiteList <- dplyr::bind_rows(lapply(seq_len(nrow(PaRe::whiteList)), function(i) {
pkgs <- utils::read.table(
file = unlist(whiteList[i, ]["link"]),
file = unlist(PaRe::whiteList[i, ]["link"]),
sep = ",",
header = TRUE
) %>%
select(unlist(whiteList[i, ]["package"]), unlist(whiteList[i, ]["version"]))
select(unlist(PaRe::whiteList[i, ]["package"]), unlist(PaRe::whiteList[i, ]["version"]))
}))

basePackages <- NULL
Expand Down Expand Up @@ -76,7 +76,6 @@ getDefaultPermittedPackages <- function(base = TRUE) {
permittedPackages
},
error = function(e) {
print(e)
message(e)
NULL
},
Expand Down

0 comments on commit 40501eb

Please sign in to comment.