Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
^README.Rmd$
^.travis.yml$
^appveyor.yml$
^cyclocomp\.Rproj$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
40 changes: 40 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
with:
extra-packages: rcmdcheck

- uses: r-lib/actions/check-r-package@v1

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cyclocomp
Title: Cyclomatic Complexity of R Code
Version: 1.1.0
Version: 1.1.0.9000
Author: Gabor Csardi
Maintainer: Hannah Alexander <halexander@mango-solutions.com>
Description: Cyclomatic complexity is a software metric (measurement),
Expand All @@ -12,11 +12,10 @@ LazyData: true
URL: https://github.com/MangoTheCat/cyclocomp
BugReports: https://github.com/MangoTheCat/cyclocomp/issues
Imports:
callr,
crayon,
desc,
remotes,
withr
Suggests:
testthat
RoxygenNote: 5.0.1
RoxygenNote: 7.1.2
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ export(cyclocomp)
export(cyclocomp_package)
export(cyclocomp_package_dir)
export(cyclocomp_q)
importFrom(callr,r)
importFrom(callr,rcmd_safe)
importFrom(crayon,red)
importFrom(crayon,underline)
importFrom(crayon,yellow)
importFrom(desc,desc_get)
importFrom(remotes,install_local)
importFrom(utils,head)
importFrom(utils,tail)
importFrom(withr,with_dir)
55 changes: 5 additions & 50 deletions R/package_dir.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,16 @@
#'
#' @family cyclomatic complexity
#' @importFrom remotes install_local
#' @importFrom callr r
#' @importFrom desc desc_get
#' @export

cyclocomp_package_dir <- function(path = ".") {
tmp <- tempfile()
dir.create(tmp)
on.exit(unlink(tmp, recursive = TRUE), add = TRUE)

tmp <- withr::local_tempdir()
pkgname <- desc_get("Package", file = file.path(path, "DESCRIPTION"))

targz <- build_package(path)

install_local(targz, lib = tmp)

r(libpath = c(tmp, .libPaths()),
function(pkg) {
loadNamespace(pkg)
cyclocomp::cyclocomp_package(pkg)
},
args = list(pkgname)
)
}

#' @importFrom withr with_dir
#' @importFrom callr rcmd_safe

build_package <- function(path) {

path <- normalizePath(path)

tmpdir <- tempfile()
dir.create(tmpdir)
on.exit(unlink(tmpdir, recursive = TRUE))

file.copy(path, tmpdir, recursive = TRUE)

## If not a tar.gz, build it. Otherwise just leave it as it is.
if (file.info(path)$isdir) {
build_status <- with_dir(
tmpdir,
rcmd_safe("build", basename(path))
)
unlink(file.path(tmpdir, basename(path)), recursive = TRUE)
}

report_system_error("Build failed", build_status)

## replace previous handler, no need to clean up any more
on.exit(NULL)

file.path(
tmpdir,
list.files(tmpdir, pattern = "\\.tar\\.gz$")
)
install_local(path, lib = tmp)
withr::local_libpaths(c(tmp, .libPaths()))
withr::local_namespace(pkg)
cyclocomp::cyclocomp_package(pkgname)
}

#' @importFrom crayon yellow red underline
Expand Down
41 changes: 0 additions & 41 deletions appveyor.yml

This file was deleted.

22 changes: 22 additions & 0 deletions cyclocomp.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
8 changes: 4 additions & 4 deletions man/cyclocomp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/cyclocomp_package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/cyclocomp_package_dir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.