Skip to content

Commit

Permalink
fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Oct 24, 2019
1 parent 7ddd4f0 commit c4a1913
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 25 deletions.
6 changes: 4 additions & 2 deletions R/datahash.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#' Calculate Hash of Dataframe
#' Calculates a hash based on the given data that is compatible with different operating systems.
#' Calculates a hash based on the given data that is compatible with different
#' operating systems.
#' @param file The file to calculate the hash.
#' @return A 40 hexadecimal character quasi-unique code representing the dataframe.
#' @return A 40 hexadecimal character quasi-unique code representing the
#' dataframe.
#' @noRd
#' @family internal
#' @importFrom assertthat assert_that
Expand Down
6 changes: 3 additions & 3 deletions R/meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Please use a different NA string or use optimize = TRUE", call. = FALSE)
#' @export
#' @rdname meta
#' @importFrom assertthat assert_that is.flag noNA
meta.logical <- function(x, optimize = TRUE, ...){
meta.logical <- function(x, optimize = TRUE, ...) {
assert_that(is.flag(optimize), noNA(optimize))
if (optimize) {
x <- as.integer(x)
Expand Down Expand Up @@ -162,7 +162,7 @@ meta.POSIXct <- function(x, optimize = TRUE, ...) {
#' @export
#' @rdname meta
#' @importFrom assertthat assert_that is.flag noNA
meta.Date <- function(x, optimize = TRUE, ...){
meta.Date <- function(x, optimize = TRUE, ...) {
assert_that(is.flag(optimize), noNA(optimize))
if (optimize) {
z <- as.integer(x)
Expand Down Expand Up @@ -190,7 +190,7 @@ meta.Date <- function(x, optimize = TRUE, ...){
#' argument intended for internal use.
#' @rdname meta
#' @inheritParams write_vc
meta.data.frame <- function(x, optimize = TRUE, na = "NA", sorting, ...) {
meta.data.frame <- function(x, optimize = TRUE, na = "NA", sorting, ...) { #nolint
assert_that(
!has_name(x, "..generic"),
msg = "'..generic' is a reserved name and not allowed as column name")
Expand Down
16 changes: 8 additions & 8 deletions R/prune.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
#' @template example-prune
rm_data <- function(
root = ".", path = NULL, recursive = TRUE, ...
){
) {
UseMethod("rm_data", root)
}

#' @export
rm_data.default <- function(
root, path = NULL, recursive = TRUE, ...
){
) {
stop("a 'root' of class ", class(root), " is not supported", call. = FALSE)
}

#' @export
#' @importFrom assertthat assert_that is.flag
rm_data.character <- function(
root = ".", path = NULL, recursive = TRUE, ...
){
) {
to_do <- list_data(root = root, path = path, recursive = recursive)
if (length(to_do) == 0) {
return(to_do)
Expand All @@ -63,7 +63,7 @@ rm_data.character <- function(
rm_data.git_repository <- function(
root, path = NULL, recursive = TRUE, ..., stage = FALSE,
type = c("unmodified", "modified", "ignored", "all")
){
) {
type <- match.arg(type)
to_do <- list_data(root = root, path = path, recursive = recursive)
if (length(to_do) == 0) {
Expand Down Expand Up @@ -116,22 +116,22 @@ rm_data.git_repository <- function(
#' @template example-prune
prune_meta <- function(
root = ".", path = NULL, recursive = TRUE, ...
){
) {
UseMethod("prune_meta", root)
}

#' @export
prune_meta.default <- function(
root, path = NULL, recursive = TRUE, ...
){
) {
stop("a 'root' of class ", class(root), " is not supported", call. = FALSE)
}

#' @export
#' @importFrom assertthat assert_that is.flag noNA
prune_meta.character <- function(
root = ".", path = NULL, recursive = TRUE, ...
){
) {
assert_that(is.string(root))
root <- normalizePath(root, winslash = "/", mustWork = TRUE)
assert_that(is.string(path))
Expand Down Expand Up @@ -171,7 +171,7 @@ prune_meta.character <- function(
#' @rdname prune_meta
prune_meta.git_repository <- function(
root, path = NULL, recursive = TRUE, ..., stage = FALSE
){
) {
root_wd <- normalizePath(workdir(root), winslash = "/")
assert_that(is.string(path))
path <- file.path(root_wd, path)
Expand Down
5 changes: 3 additions & 2 deletions R/recent_commit.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#' be rerun. See `vignette("workflow", package = "git2rdata")`.
#' @inheritParams write_vc
#' @param root The root of a project. Can be a file path or a `git-repository`.
#' @param data does `file` refers to a data object (`TRUE`) or to a file (`FALSE`).
#' @param data does `file` refers to a data object (`TRUE`) or to a file
#' (`FALSE`)?
#' Defaults to `FALSE`.
#' @return a `data.frame` with `commit`, `author` and `when` for the most recent
#' commit that adds op updates the file.
Expand Down Expand Up @@ -73,7 +74,7 @@
#' rev(list.files(repo_path, full.names = TRUE, recursive = TRUE,
#' include.dirs = TRUE, all.files = TRUE)),
#' repo_path)
recent_commit <- function(file, root, data = FALSE){
recent_commit <- function(file, root, data = FALSE) {
UseMethod("recent_commit", root)
}

Expand Down
2 changes: 1 addition & 1 deletion R/relabel.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Use write_vc() instead.", call. = FALSE)
#' @export
#' @importFrom assertthat assert_that has_name
#' @importFrom stats setNames
relabel.data.frame <- function(file, root, change) {
relabel.data.frame <- function(file, root, change) { #nolint
assert_that(
has_name(change, "factor"),
has_name(change, "old"),
Expand Down
12 changes: 7 additions & 5 deletions R/write_vc.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#' Store a Data.Frame as a Git2rdata Object on Disk
#'
#' A git2rdata object consists of two files. The `".tsv"` file contains the raw
#' data as a plain text tab separated file. The `".yml"` contains the metadata
#' on the columns in plain text YAML format. See `vignette("plain text", package = "git2rdata")` for more details on the implementation.
#' A git2rdata object consists of two files.
#' The `".tsv"` file contains the raw data as a plain text tab separated file.
#' The `".yml"` contains the metadata on the columns in plain text YAML format.
#' See `vignette("plain text", package = "git2rdata")` for more details on the
#' implementation.
#' @param x the `data.frame`.
#' @param file the name of the git2rdata object. Git2rdata objects cannot
#' have dots in their name. The name may include a relative path. `file` is a
Expand Down Expand Up @@ -52,7 +54,7 @@ write_vc.default <- function(
write_vc.character <- function(
x, file, root = ".", sorting, strict = TRUE, optimize = TRUE, na = "NA",
...
){
) {
assert_that(
inherits(x, "data.frame"), is.string(file), is.string(root), is.string(na),
noNA(na), no_whitespace(na), is.flag(strict), is.flag(optimize)
Expand Down Expand Up @@ -133,7 +135,7 @@ setOldClass("git_repository")
write_vc.git_repository <- function(
x, file, root, sorting, strict = TRUE, optimize = TRUE, na = "NA", ...,
stage = FALSE, force = FALSE
){
) {
assert_that(is.flag(stage), is.flag(force))
hashes <- write_vc(
x = x, file = file, root = workdir(root), sorting = sorting,
Expand Down
3 changes: 2 additions & 1 deletion man/recent_commit.Rd

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

8 changes: 5 additions & 3 deletions man/write_vc.Rd

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

0 comments on commit c4a1913

Please sign in to comment.