-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
80 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#' Function giving opinions about a package | ||
#' | ||
#' @param pkg_path | ||
#' | ||
#' @return A data.frame of opinions | ||
#' @export | ||
#' | ||
give_opinions <- function(pkg_path = .){ | ||
descr_path <- file.path(pkg_path, "DESCRIPTION") | ||
# opinions about DESCRIPTION | ||
descr_issues <- give_opinions_desc(descr_path) | ||
|
||
|
||
fixmes <- descr_issues | ||
fixmes$package <- as.character(descr$get("Package")) | ||
} | ||
|
||
give_opinions_desc <- function(descr_path){ | ||
descr <- desc::desc(descr_path) | ||
# Authors | ||
if (inherits( try(descr$get_authors(), silent = TRUE), | ||
'try-error')){ | ||
authors_fixme <- "The syntax Authors@R instead of plain Author and Maintainer is recommended in particular because it allows richer metadata" # no lint | ||
}else{ | ||
authors_fixme <- NULL | ||
} | ||
|
||
# URL | ||
if(is.na(descr$get("URL"))){ | ||
url_fixme <- "URL field. Indicate the URL to your code repository." | ||
}else{ | ||
url_fixme <- NULL | ||
} | ||
|
||
# BugReports | ||
if(is.na(descr$get("BugReports"))){ | ||
bugreports_fixme <- "BugReports field. Indicate where to report bugs, e.g. GitHub issue tracker." | ||
}else{ | ||
bugreports_fixme <- NULL | ||
} | ||
|
||
fixmes <- c(authors_fixme, url_fixme, bugreports_fixme) | ||
fixmes <- fixmes[!is.null(fixmes)] | ||
|
||
if(length(fixmes) >0){ | ||
|
||
tibble::tibble(where = "DESCRIPTION", | ||
fixme = fixmes) | ||
}else{ | ||
NULL | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
context("test-give_opinions.R") | ||
|
||
testthat::test_that("Message if no URL", { | ||
f <- system.file("examples/DESCRIPTION_no_URL", package = "codemetar") | ||
desc_fixmes <- give_opinions_desc(f) | ||
expect_is(desc_fixmes, "data.frame") | ||
expect_equal(desc_fixmes$where, "DESCRIPTION") | ||
expect_true(any(grepl("URL", desc_fixmes$fixme))) | ||
}) | ||
|
||
testthat::test_that("Message if no BugReports", { | ||
f <- system.file("examples/DESCRIPTION_no_bugreports", package = "codemetar") | ||
desc_fixmes <- give_opinions_desc(f) | ||
expect_is(desc_fixmes, "data.frame") | ||
expect_equal(desc_fixmes$where, "DESCRIPTION") | ||
expect_true(any(grepl("BugReports", desc_fixmes$fixme))) | ||
}) | ||
|
||
testhat::test_that("No message if ok description"){ | ||
f <- system.file("examples/DESCRIPTION_Rforge", package = "codemetar") | ||
expect_is(give_opinions_desc(f), NULL) | ||
} |