From 475e6857be8c7ee934517376968484ad8020eea6 Mon Sep 17 00:00:00 2001 From: Maarten van Kessel Date: Fri, 29 Nov 2024 13:18:34 +0100 Subject: [PATCH 1/8] cran hotfix --- DESCRIPTION | 2 +- extras/PackageMaintenance.R | 2 +- tests/testthat/test-checkDependencies.R | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3dc9380..b9794ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: PaRe Type: Package Title: A Way to Perform Code Review or QA on Other Packages -Version: 0.1.14 +Version: 0.1.15 Language: en-US Authors@R: person("Maarten", "van Kessel", email = "m.l.vankessel@erasmusmc.nl", diff --git a/extras/PackageMaintenance.R b/extras/PackageMaintenance.R index 5ab84e8..140cfc8 100644 --- a/extras/PackageMaintenance.R +++ b/extras/PackageMaintenance.R @@ -1,6 +1,6 @@ # Copyright 2024 DARWIN EU® # -# This file is part of TreatmentPatterns +# This file is part of PaRe # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/testthat/test-checkDependencies.R b/tests/testthat/test-checkDependencies.R index ec858bd..fe7a752 100644 --- a/tests/testthat/test-checkDependencies.R +++ b/tests/testthat/test-checkDependencies.R @@ -15,11 +15,8 @@ test_that("void", { }) test_that("minimal", { - skip_if( - utils::packageVersion(pkg = "base") > package_version("4.4.0") - ) + skip_if_offline() repo <- makeRepo() - testthat::skip_if(!R6::is.R6(repo)) expect_message( suppressWarnings(checkDependencies(repo = repo)), @@ -30,8 +27,9 @@ test_that("minimal", { test_that("parallel", { + skip_if_offline() + repo <- makeRepo() - testthat::skip_if(!R6::is.R6(repo)) expect_message( suppressWarnings(checkDependencies(repo = repo, nThreads = 2)), From 92610472fed267d36c1e1d2ce5a421c6379a5565 Mon Sep 17 00:00:00 2001 From: Maarten van Kessel Date: Fri, 29 Nov 2024 14:49:54 +0100 Subject: [PATCH 2/8] Updated test suite for CRAN --- DESCRIPTION | 1 + tests/testthat/helper-checkSuggests.R | 3 ++- tests/testthat/helper-makeRepo.R | 18 ------------------ tests/testthat/setup.R | 17 +++++++++++++++++ tests/testthat/test-addPareArticle.R | 5 ++--- tests/testthat/test-checkDependencies.R | 7 +++---- tests/testthat/test-getApplyCall.R | 10 ++++------ tests/testthat/test-getDlplyCall.R | 10 ++++------ tests/testthat/test-getDoCall.R | 10 ++++------ tests/testthat/test-getDoCallFromLines.R | 3 --- tests/testthat/test-getFunCall.R | 7 ++++--- tests/testthat/test-getMultiLineFun.R | 7 ++++--- 12 files changed, 45 insertions(+), 53 deletions(-) delete mode 100644 tests/testthat/helper-makeRepo.R create mode 100644 tests/testthat/setup.R diff --git a/DESCRIPTION b/DESCRIPTION index b9794ee..dfaa7c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,6 +44,7 @@ Suggests: withr, cowplot, knitr, + curl, testthat (>= 3.0.0) VignetteBuilder: knitr Roxygen: list(markdown = TRUE) diff --git a/tests/testthat/helper-checkSuggests.R b/tests/testthat/helper-checkSuggests.R index 7811f79..0cea7ec 100644 --- a/tests/testthat/helper-checkSuggests.R +++ b/tests/testthat/helper-checkSuggests.R @@ -3,6 +3,7 @@ checkSuggests <- function() { c("ggplot2", "plotly", "ggraph", "DT", "magick", "withr", "cowplot", "knitr", "testthat"), require, character.only = TRUE, - quietly = TRUE + quietly = TRUE, + warn.conflicts = FALSE )))) } diff --git a/tests/testthat/helper-makeRepo.R b/tests/testthat/helper-makeRepo.R deleted file mode 100644 index a4f696e..0000000 --- a/tests/testthat/helper-makeRepo.R +++ /dev/null @@ -1,18 +0,0 @@ -makeRepo <- function() { - repo <- tryCatch({ - tmpDir <- tempdir() - pathToRepo <- file.path(tmpDir, "glue") - - if (!dir.exists(pathToRepo)) { - git2r::clone( - url = "https://github.com/tidyverse/glue", - local_path = pathToRepo - ) - } - - PaRe::Repository$new(path = pathToRepo) - }, error = function(e) { - FALSE - }) - return(repo) -} diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..690e33c --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1,17 @@ +library(PaRe) +library(testthat) +library(git2r) + +path <- file.path(tempdir(), "glue") + +if (!is.null(curl::nslookup("captive.apple.com", error = FALSE))) { + clone( + url = "https://github.com/tidyverse/glue", + local_path = path + ) +} + +withr::defer({ + unlink(path, recursive = TRUE, force = TRUE)}, + teardown_env() +) diff --git a/tests/testthat/test-addPareArticle.R b/tests/testthat/test-addPareArticle.R index 0e47cf0..1268b0a 100644 --- a/tests/testthat/test-addPareArticle.R +++ b/tests/testthat/test-addPareArticle.R @@ -1,13 +1,12 @@ test_that("minimal", { skip_if_not(checkSuggests()) + skip_if_offline() - repo <- makeRepo() - testthat::skip_if(!R6::is.R6(repo)) + repo <- Repository$new(path) suppressWarnings(addPareArticle(repo)) path <- file.path(repo$getPath(), "vignettes", "articles", "PareReport.Rmd") expect_true(file.exists(path)) - unlink(repo$getPath(), recursive = TRUE) }) diff --git a/tests/testthat/test-checkDependencies.R b/tests/testthat/test-checkDependencies.R index fe7a752..b22e2cc 100644 --- a/tests/testthat/test-checkDependencies.R +++ b/tests/testthat/test-checkDependencies.R @@ -16,24 +16,23 @@ test_that("void", { test_that("minimal", { skip_if_offline() - repo <- makeRepo() + + repo <- Repository$new(path) expect_message( suppressWarnings(checkDependencies(repo = repo)), "All dependencies are approved." ) - unlink(repo$getPath(), recursive = TRUE) }) test_that("parallel", { skip_if_offline() - repo <- makeRepo() + repo <- Repository$new(path) expect_message( suppressWarnings(checkDependencies(repo = repo, nThreads = 2)), "All dependencies are approved." ) - unlink(repo$getPath(), recursive = TRUE) }) diff --git a/tests/testthat/test-getApplyCall.R b/tests/testthat/test-getApplyCall.R index 7420746..ca0cc68 100644 --- a/tests/testthat/test-getApplyCall.R +++ b/tests/testthat/test-getApplyCall.R @@ -1,9 +1,8 @@ -library(PaRe) -library(testthat) - test_that("minimal", { - repo <- makeRepo() - testthat::skip_if_not(all(class(repo) == c("Repository", "R6"))) + skip_if_offline() + + repo <- Repository$new(path) + files <- repo$getRFiles() glueIdx <- sapply(files, function(file) { file$getName() == "glue.R" @@ -20,5 +19,4 @@ test_that("minimal", { fun <- funs[glueIdx][[1]] expect_null(PaRe:::getApplyCall(fun, defFuns)) - unlink(repo$getPath(), recursive = TRUE) }) diff --git a/tests/testthat/test-getDlplyCall.R b/tests/testthat/test-getDlplyCall.R index a9fcf23..dc853af 100644 --- a/tests/testthat/test-getDlplyCall.R +++ b/tests/testthat/test-getDlplyCall.R @@ -1,6 +1,3 @@ -library(PaRe) -library(testthat) - # if dlply calls > 0 # lapply # if dlply call %in% defined functions @@ -10,8 +7,10 @@ library(testthat) # 2: if1 if2 test_that("minimal", { - repo <- makeRepo() - testthat::skip_if_not(all(class(repo) == c("Repository", "R6"))) + skip_if_offline() + + repo <- Repository$new(path) + files <- repo$getRFiles() glueIdx <- sapply(files, function(file) { file$getName() == "glue.R" @@ -28,5 +27,4 @@ test_that("minimal", { fun <- funs[glueIdx][[1]] expect_null(PaRe:::getDlplyCall(fun, defFuns)) - unlink(repo$getPath(), recursive = TRUE) }) diff --git a/tests/testthat/test-getDoCall.R b/tests/testthat/test-getDoCall.R index 5b1f89f..9c162f8 100644 --- a/tests/testthat/test-getDoCall.R +++ b/tests/testthat/test-getDoCall.R @@ -1,9 +1,8 @@ -library(PaRe) -library(testthat) - test_that("minimal", { - repo <- makeRepo() - testthat::skip_if_not(all(class(repo) == c("Repository", "R6"))) + skip_if_offline() + + repo <- Repository$new(path) + files <- repo$getRFiles() glueIdx <- sapply(files, function(file) { file$getName() == "glue.R" @@ -20,5 +19,4 @@ test_that("minimal", { fun <- funs[glueIdx][[1]] expect_null(PaRe:::getDoCall(fun, defFuns)) - unlink(repo$getPath(), recursive = TRUE) }) diff --git a/tests/testthat/test-getDoCallFromLines.R b/tests/testthat/test-getDoCallFromLines.R index 9406b3e..dde7171 100644 --- a/tests/testthat/test-getDoCallFromLines.R +++ b/tests/testthat/test-getDoCallFromLines.R @@ -1,6 +1,3 @@ -library(PaRe) -library(testthat) - test_that("minimal", { lines <- c( "do.call(mean, list(c(1, 2, 3)))", diff --git a/tests/testthat/test-getFunCall.R b/tests/testthat/test-getFunCall.R index f67d488..431212a 100644 --- a/tests/testthat/test-getFunCall.R +++ b/tests/testthat/test-getFunCall.R @@ -1,6 +1,8 @@ test_that("minimal", { - repo <- makeRepo() - testthat::skip_if_not(all(class(repo) == c("Repository", "R6"))) + skip_if_offline() + + repo <- Repository$new(path) + files <- repo$getRFiles() glueIdx <- sapply(files, function(file) { file$getName() == "glue.R" @@ -19,5 +21,4 @@ test_that("minimal", { df <- bind_rows(PaRe:::getFunCall(fun, defFuns)) expect_true(nrow(df) == 1) expect_true(ncol(df) == 2) - unlink(repo$getPath(), recursive = TRUE) }) diff --git a/tests/testthat/test-getMultiLineFun.R b/tests/testthat/test-getMultiLineFun.R index 20467fb..7144186 100644 --- a/tests/testthat/test-getMultiLineFun.R +++ b/tests/testthat/test-getMultiLineFun.R @@ -15,8 +15,10 @@ # 10: while con1 con2 if1 if2 test_that("regular use", { - repo <- makeRepo() - testthat::skip_if_not(all(class(repo) == c("Repository", "R6"))) + skip_if_offline() + + repo <- Repository$new(path) + files <- repo$getRFiles() glueIdx <- sapply(files, function(file) { file$getName() == "glue.R" @@ -33,7 +35,6 @@ test_that("regular use", { fun <- funs[glueIdx][[1]] expect_true(length(PaRe:::getMultiLineFun(line = 1, lines = fun$getLines())) == 1) - unlink(repo$getPath(), recursive = TRUE) }) test_that("No closing bracket", { From 815814579e6ae25b42e67641920bfd8b0bdc09d6 Mon Sep 17 00:00:00 2001 From: Maarten van Kessel Date: Fri, 29 Nov 2024 16:00:01 +0100 Subject: [PATCH 3/8] Updated tests --- CRAN-SUBMISSION | 6 +++--- tests/testthat/setup.R | 16 ++++++++++++---- tests/testthat/test-addPareArticle.R | 1 + tests/testthat/test-checkDependencies.R | 2 ++ tests/testthat/test-getApplyCall.R | 1 + tests/testthat/test-getDlplyCall.R | 1 + tests/testthat/test-getDoCall.R | 1 + tests/testthat/test-getFunCall.R | 1 + tests/testthat/test-getMultiLineFun.R | 1 + 9 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index d6e7e62..a323ba4 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.1.14 -Date: 2024-11-28 15:02:25 UTC -SHA: 6b421989f4c43662982bbe2723d109a843f5e982 +Version: 0.1.15 +Date: 2024-11-29 14:23:55 UTC +SHA: 92610472fed267d36c1e1d2ce5a421c6379a5565 diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 690e33c..484effe 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -3,12 +3,20 @@ library(testthat) library(git2r) path <- file.path(tempdir(), "glue") +repoCloned <- NULL if (!is.null(curl::nslookup("captive.apple.com", error = FALSE))) { - clone( - url = "https://github.com/tidyverse/glue", - local_path = path - ) + tryCatch({ + clone( + url = "https://github.com/tidyverse/glue", + local_path = path + ) + repoCloned <- TRUE + }, error = function(e) { + repoCloned <- FALSE + }) +} else { + repoCloned <- FALSE } withr::defer({ diff --git a/tests/testthat/test-addPareArticle.R b/tests/testthat/test-addPareArticle.R index 1268b0a..f45ab02 100644 --- a/tests/testthat/test-addPareArticle.R +++ b/tests/testthat/test-addPareArticle.R @@ -1,6 +1,7 @@ test_that("minimal", { skip_if_not(checkSuggests()) skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) diff --git a/tests/testthat/test-checkDependencies.R b/tests/testthat/test-checkDependencies.R index b22e2cc..f66fce9 100644 --- a/tests/testthat/test-checkDependencies.R +++ b/tests/testthat/test-checkDependencies.R @@ -16,6 +16,7 @@ test_that("void", { test_that("minimal", { skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) @@ -28,6 +29,7 @@ test_that("minimal", { test_that("parallel", { skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) diff --git a/tests/testthat/test-getApplyCall.R b/tests/testthat/test-getApplyCall.R index ca0cc68..f4c8316 100644 --- a/tests/testthat/test-getApplyCall.R +++ b/tests/testthat/test-getApplyCall.R @@ -1,5 +1,6 @@ test_that("minimal", { skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) diff --git a/tests/testthat/test-getDlplyCall.R b/tests/testthat/test-getDlplyCall.R index dc853af..7236fb8 100644 --- a/tests/testthat/test-getDlplyCall.R +++ b/tests/testthat/test-getDlplyCall.R @@ -8,6 +8,7 @@ test_that("minimal", { skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) diff --git a/tests/testthat/test-getDoCall.R b/tests/testthat/test-getDoCall.R index 9c162f8..fc1ee8c 100644 --- a/tests/testthat/test-getDoCall.R +++ b/tests/testthat/test-getDoCall.R @@ -1,5 +1,6 @@ test_that("minimal", { skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) diff --git a/tests/testthat/test-getFunCall.R b/tests/testthat/test-getFunCall.R index 431212a..1af42fc 100644 --- a/tests/testthat/test-getFunCall.R +++ b/tests/testthat/test-getFunCall.R @@ -1,5 +1,6 @@ test_that("minimal", { skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) diff --git a/tests/testthat/test-getMultiLineFun.R b/tests/testthat/test-getMultiLineFun.R index 7144186..0ad1a08 100644 --- a/tests/testthat/test-getMultiLineFun.R +++ b/tests/testthat/test-getMultiLineFun.R @@ -16,6 +16,7 @@ test_that("regular use", { skip_if_offline() + skip_if_not(repoCloned) repo <- Repository$new(path) From f43e8d8939d53cd9ecc1959489185f9419528598 Mon Sep 17 00:00:00 2001 From: Maarten van Kessel Date: Tue, 3 Dec 2024 09:18:32 +0100 Subject: [PATCH 4/8] CRAN sub --- CRAN-SUBMISSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index a323ba4..f428b04 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ Version: 0.1.15 -Date: 2024-11-29 14:23:55 UTC -SHA: 92610472fed267d36c1e1d2ce5a421c6379a5565 +Date: 2024-11-29 15:15:17 UTC +SHA: 815814579e6ae25b42e67641920bfd8b0bdc09d6 From 3c8d59c3dbb5e8229f41d2e461dc2b0b20fe4a3b Mon Sep 17 00:00:00 2001 From: Maarten van Kessel Date: Tue, 3 Dec 2024 13:21:44 +0100 Subject: [PATCH 5/8] report fix --- inst/rmd/report.Rmd | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/inst/rmd/report.Rmd b/inst/rmd/report.Rmd index d1a68ea..b812e43 100644 --- a/inst/rmd/report.Rmd +++ b/inst/rmd/report.Rmd @@ -180,11 +180,8 @@ DT::datatable(data.frame( meanDegree = round(mean(igraph::degree(graphData)), 2), meanDistance = round(mean(igraph::distances(graphData)), 2) ), - rownames= FALSE) -}, error = function(e) { - message("Could not get graph data with error:") - message(sprintf("\t%s", e)) -}) + rownames = FALSE +) ``` ### Function use per dependency From f4177d9f6fb4bd343b5720434e3a2c6981035474 Mon Sep 17 00:00:00 2001 From: mvankessel-EMC Date: Wed, 4 Feb 2026 11:55:43 +0100 Subject: [PATCH 6/8] summarise -> reframe --- R/lint.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/lint.R b/R/lint.R index 5a693f7..425ef18 100644 --- a/R/lint.R +++ b/R/lint.R @@ -151,7 +151,7 @@ lintScore <- function(repo, messages) { pct <- messages %>% dplyr::group_by(.data$type) %>% dplyr::tally() %>% - dplyr::summarise(.data$type, pct = round(.data$n / nLines * 100, 2)) + dplyr::reframe(.data$type, pct = round(.data$n / nLines * 100, 2)) if (nrow(pct) == 0) { message(glue::glue("{nrow(pct)} Lintr messages found")) From 4391dd09a7693cd49b45af4d65a92edee88c7ec4 Mon Sep 17 00:00:00 2001 From: mvankessel-EMC Date: Wed, 4 Feb 2026 13:34:31 +0100 Subject: [PATCH 7/8] release prep --- DESCRIPTION | 2 +- NEWS.md | 8 ++ R/getDefaultPermittedPackages.R | 44 +++++--- tests/testthat/setup.R | 27 +++-- vignettes/Documentation.Rmd | 9 +- vignettes/articles/PareReport.Rmd | 174 ++++++++++++++++++------------ 6 files changed, 162 insertions(+), 102 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index dfaa7c4..0398366 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: PaRe Type: Package Title: A Way to Perform Code Review or QA on Other Packages -Version: 0.1.15 +Version: 0.1.16 Language: en-US Authors@R: person("Maarten", "van Kessel", email = "m.l.vankessel@erasmusmc.nl", diff --git a/NEWS.md b/NEWS.md index e343d7d..1bb4788 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +PaRe 0.1.16 +========== +1. Use `dplyr::reframe()` instead of `dplyr::summarise()` + +PaRe 0.1.15 +========== +1. Updated internal test setup + PaRe 0.1.14 ========== 1. Changed tests so R-CMD-Check passes on depends-only environment diff --git a/R/getDefaultPermittedPackages.R b/R/getDefaultPermittedPackages.R index 3355f07..0db08e9 100644 --- a/R/getDefaultPermittedPackages.R +++ b/R/getDefaultPermittedPackages.R @@ -18,28 +18,38 @@ getParDeps <- function(pkgs, nThreads) { deps <- if (nThreads > 1) { cl <- parallel::makeCluster(nThreads) on.exit(parallel::stopCluster(cl = cl)) - parallel::clusterEvalQ(cl = cl, expr = {library("pak", character.only = TRUE)}) + parallel::clusterEvalQ(cl = cl, expr = { + library("pak", character.only = TRUE) + }) parallel::parLapply(cl = cl, X = pkgs, fun = function(pkg) { - tryCatch({ - res <- pak::pkg_deps(pkg = pkg) - return(res) - }, error = function(e) { - return(NULL) - }, warning = function(w) { - return(res) - }) + tryCatch( + { + res <- pak::pkg_deps(pkg = pkg) + return(res) + }, + error = function(e) { + return(NULL) + }, + warning = function(w) { + return(res) + } + ) }) } else { lapply(X = pkgs, function(pkg) { - tryCatch({ - res <- pak::pkg_deps(pkg = pkg) - return(res) - }, error = function(e) { - return(NULL) - }, warning = function(w) { - return(res) - }) + tryCatch( + { + res <- pak::pkg_deps(pkg = pkg) + return(res) + }, + error = function(e) { + return(NULL) + }, + warning = function(w) { + return(res) + } + ) }) } diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 484effe..1df6163 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -6,20 +6,25 @@ path <- file.path(tempdir(), "glue") repoCloned <- NULL if (!is.null(curl::nslookup("captive.apple.com", error = FALSE))) { - tryCatch({ - clone( - url = "https://github.com/tidyverse/glue", - local_path = path - ) - repoCloned <- TRUE - }, error = function(e) { - repoCloned <- FALSE - }) + tryCatch( + { + clone( + url = "https://github.com/tidyverse/glue", + local_path = path + ) + repoCloned <- TRUE + }, + error = function(e) { + repoCloned <- FALSE + } + ) } else { repoCloned <- FALSE } -withr::defer({ - unlink(path, recursive = TRUE, force = TRUE)}, +withr::defer( + { + unlink(path, recursive = TRUE, force = TRUE) + }, teardown_env() ) diff --git a/vignettes/Documentation.Rmd b/vignettes/Documentation.Rmd index b036c16..50c5fdd 100644 --- a/vignettes/Documentation.Rmd +++ b/vignettes/Documentation.Rmd @@ -234,10 +234,11 @@ PaRe::pkgDiagram(repo = repo) %>% if (fetchedRepo) { if (all(c( require("DiagrammeRsvg", character.only = TRUE), - require("magick", character.only = TRUE)))) { - PaRe::pkgDiagram(repo = repo) %>% - DiagrammeRsvg::export_svg() %>% - magick::image_read_svg() + require("magick", character.only = TRUE) + ))) { + PaRe::pkgDiagram(repo = repo) %>% + DiagrammeRsvg::export_svg() %>% + magick::image_read_svg() } } ``` diff --git a/vignettes/articles/PareReport.Rmd b/vignettes/articles/PareReport.Rmd index 8a486c8..1fbd03d 100644 --- a/vignettes/articles/PareReport.Rmd +++ b/vignettes/articles/PareReport.Rmd @@ -43,66 +43,91 @@ defFuns <- defFuns %>% ``` ```{r summaryDefFunStats, echo=FALSE} -DT::datatable(data.frame( - min = c(min(defFuns$nArgs, na.rm = TRUE), - min(defFuns$size, na.rm = TRUE), - min(defFuns$cycloComp, na.rm = TRUE)), - median = c(median(defFuns$nArgs, na.rm = TRUE), - median(defFuns$size, na.rm = TRUE), - median(defFuns$cycloComp, na.rm = TRUE)), - max = c(max(defFuns$nArgs, na.rm = TRUE), - max(defFuns$size, na.rm = TRUE), - max(defFuns$cycloComp, na.rm = TRUE)), - row.names = c("Number of arguments", - "Lines of code", - "Cyclomatic complexity")), - options = list(dom = 't')) +DT::datatable( + data.frame( + min = c( + min(defFuns$nArgs, na.rm = TRUE), + min(defFuns$size, na.rm = TRUE), + min(defFuns$cycloComp, na.rm = TRUE) + ), + median = c( + median(defFuns$nArgs, na.rm = TRUE), + median(defFuns$size, na.rm = TRUE), + median(defFuns$cycloComp, na.rm = TRUE) + ), + max = c( + max(defFuns$nArgs, na.rm = TRUE), + max(defFuns$size, na.rm = TRUE), + max(defFuns$cycloComp, na.rm = TRUE) + ), + row.names = c( + "Number of arguments", + "Lines of code", + "Cyclomatic complexity" + ) + ), + options = list(dom = "t") +) ``` ```{r echo=FALSE} -gg_nArgs <- defFuns %>% - ggplot2::ggplot()+ - ggplot2::geom_histogram(ggplot2::aes(nArgs), binwidth = 1, - colour = "black", - fill = "grey")+ - ggplot2::theme_minimal()+ +gg_nArgs <- defFuns %>% + ggplot2::ggplot() + + ggplot2::geom_histogram(ggplot2::aes(nArgs), + binwidth = 1, + colour = "black", + fill = "grey" + ) + + ggplot2::theme_minimal() + ggplot2::xlab("Number of arguments") -gg_size <- defFuns %>% - ggplot2::ggplot()+ - ggplot2::geom_histogram(ggplot2::aes(size), binwidth = 1, - colour = "black", - fill = "grey")+ - ggplot2::theme_minimal()+ +gg_size <- defFuns %>% + ggplot2::ggplot() + + ggplot2::geom_histogram(ggplot2::aes(size), + binwidth = 1, + colour = "black", + fill = "grey" + ) + + ggplot2::theme_minimal() + ggplot2::xlab("Lines of code") -gg_cycloComp <- defFuns %>% - ggplot2::ggplot()+ - ggplot2::geom_histogram(ggplot2::aes(cycloComp), binwidth = 1, - colour = "black", - fill = "grey")+ - ggplot2::theme_minimal()+ +gg_cycloComp <- defFuns %>% + ggplot2::ggplot() + + ggplot2::geom_histogram(ggplot2::aes(cycloComp), + binwidth = 1, + colour = "black", + fill = "grey" + ) + + ggplot2::theme_minimal() + ggplot2::xlab("Cyclomatic complexity") cowplot::plot_grid(gg_nArgs, gg_size, gg_cycloComp, nrow = 3) ``` ```{r, warning=FALSE, message=FALSE, echo=FALSE} -p <- defFuns %>% - ggplot2::ggplot(ggplot2::aes(group = name))+ - ggplot2::geom_point(ggplot2::aes(size, cycloComp, - colour = nArgs), - size = 3)+ - ggplot2::scale_colour_gradient(name = "Number of\nargruments", - low = "blue", high = "red") + +p <- defFuns %>% + ggplot2::ggplot(ggplot2::aes(group = name)) + + ggplot2::geom_point( + ggplot2::aes(size, cycloComp, + colour = nArgs + ), + size = 3 + ) + + ggplot2::scale_colour_gradient( + name = "Number of\nargruments", + low = "blue", high = "red" + ) + ggplot2::theme_minimal() + ggplot2::xlab("Lines of code") + ggplot2::ylab("Cyclomatic complexity") + ggplot2::theme(legend.position = "top") - plotly::ggplotly(p, - tooltip = c("group", "colour", - "x", "y")) +plotly::ggplotly(p, + tooltip = c( + "group", "colour", + "x", "y" + ) +) ``` ## Function details @@ -114,15 +139,17 @@ lineBreaks <- c(100, 200) DT::datatable( defFuns %>% - dplyr::mutate(file_start = paste0(.data$fileName, " (from line: ", lineStart, ")")) %>% - dplyr::select("name", "nArgs", "size","cycloComp", "file_start") %>% + dplyr::mutate(file_start = paste0(.data$fileName, " (from line: ", lineStart, ")")) %>% + dplyr::select("name", "nArgs", "size", "cycloComp", "file_start") %>% dplyr::rename( "Function" = "name", "Number of arguments" = "nArgs", "Lines of code" = "size", "Cyclomatic complexity" = "cycloComp", - "Location" = "file_start"), - rownames = FALSE) %>% + "Location" = "file_start" + ), + rownames = FALSE +) %>% DT::formatStyle("Number of arguments", backgroundColor = DT::styleInterval(argBreaks, colours)) %>% DT::formatStyle("Cyclomatic complexity", backgroundColor = DT::styleInterval(complexBreaks, colours)) %>% DT::formatStyle("Lines of code", backgroundColor = DT::styleInterval(lineBreaks, colours)) @@ -132,7 +159,8 @@ DT::datatable( ```{r countLines, echo=FALSE} DT::datatable( PaRe::countPackageLines(repo), - rownames = "# lines of code") + rownames = "# lines of code" +) ``` ## Style adherence, syntax errors and possible semantic issues @@ -140,19 +168,21 @@ DT::datatable( ```{r lintScores, message=FALSE, warning=FALSE, echo=FALSE} lintMsgs <- PaRe::lintRepo(repo) -DT::datatable(PaRe::lintScore(repo, lintMsgs) %>% - dplyr::rename("Percentage of lines assessed" = "pct"), - rownames = FALSE) +DT::datatable( + PaRe::lintScore(repo, lintMsgs) %>% + dplyr::rename("Percentage of lines assessed" = "pct"), + rownames = FALSE +) ``` ### Warnings ```{r lintMessages warnings, message=FALSE, warning=FALSE, echo=FALSE} DT::datatable( lintMsgs %>% - dplyr::filter(type == "warning") %>% - dplyr::group_by(message) %>% - dplyr::tally(sort = TRUE), - rownames= FALSE + dplyr::filter(type == "warning") %>% + dplyr::group_by(message) %>% + dplyr::tally(sort = TRUE), + rownames = FALSE ) ``` @@ -160,10 +190,10 @@ DT::datatable( ```{r lintMessages style, message=FALSE, warning=FALSE, echo=FALSE} DT::datatable( lintMsgs %>% - dplyr::filter(type == "style") %>% - dplyr::group_by(message) %>% - dplyr::tally(sort = TRUE), - rownames= FALSE + dplyr::filter(type == "style") %>% + dplyr::group_by(message) %>% + dplyr::tally(sort = TRUE), + rownames = FALSE ) ``` @@ -181,13 +211,15 @@ DT::datatable(PaRe::checkDependencies(repo = repo, nThreads = 10)) ```{r dependencyGraphStats, message=FALSE, warning=FALSE, echo=FALSE} graphData <- PaRe::getGraphData(repo = repo, nThreads = 10) -DT::datatable(data.frame( - countVertices = length(igraph::V(graphData)), - countEdges = length(igraph::E(graphData)), - meanDegree = round(mean(igraph::degree(graphData)), 2), - meanDistance = round(mean(igraph::distances(graphData)), 2) +DT::datatable( + data.frame( + countVertices = length(igraph::V(graphData)), + countEdges = length(igraph::E(graphData)), + meanDegree = round(mean(igraph::degree(graphData)), 2), + meanDistance = round(mean(igraph::distances(graphData)), 2) ), - rownames= FALSE) + rownames = FALSE +) ``` ### Function use per dependency @@ -196,11 +228,12 @@ funsUsed <- PaRe::getFunctionUse(repo = repo) DT::datatable( funsUsed, - rownames = FALSE) + rownames = FALSE +) ``` ```{r plotFunctionUse, dpi=100, fig.height=25, out.width="100%", message=FALSE, warning=FALSE, echo=FALSE} -function_sub <- funsUsed %>% +function_sub <- funsUsed %>% dplyr::filter(!pkg %in% c("base")) fun_counts <- function_sub %>% @@ -212,16 +245,19 @@ nonPkgFuns <- fun_counts[!fun_counts$fun %in% defFuns$fun, ] ggplot2::ggplot( data = nonPkgFuns, - mapping = ggplot2::aes(x = .data$fun, y = .data$n, fill = .data$pkg)) + + mapping = ggplot2::aes(x = .data$fun, y = .data$n, fill = .data$pkg) +) + ggplot2::geom_col() + ggplot2::facet_wrap( dplyr::vars(.data$pkg), scales = "free_x", - ncol = 2) + + ncol = 2 + ) + ggplot2::theme_bw() + ggplot2::theme( legend.position = "none", - axis.text.x = (ggplot2::element_text(angle = 45, hjust = 1, vjust = 1))) + axis.text.x = (ggplot2::element_text(angle = 45, hjust = 1, vjust = 1)) + ) ``` ## Further reading From 0f274434ea86f490b1634e9b13487f047dd72a58 Mon Sep 17 00:00:00 2001 From: mvankessel-EMC Date: Wed, 4 Feb 2026 13:54:08 +0100 Subject: [PATCH 8/8] updated news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 1bb4788..9f02ffb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ PaRe 0.1.16 ========== -1. Use `dplyr::reframe()` instead of `dplyr::summarise()` +1. Use `dplyr::reframe()` instead of `dplyr::summarise()` for dplyr >= 1.2.0 compatability PaRe 0.1.15 ==========