Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A base R replacement to formatR::tidy_source() #563

Merged
merged 26 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d199fdb
Fix #562
wlandau-lilly Oct 28, 2018
308254c
Rearrange a couple functions
wlandau-lilly Oct 28, 2018
15fbbb0
Remove uncovered code
wlandau-lilly Oct 29, 2018
bd86659
Update docs
wlandau-lilly Oct 29, 2018
ba0e3a5
Merge branch 'master' into 562
wlandau-lilly Oct 29, 2018
65ed003
Use parse data
wlandau-lilly Oct 30, 2018
341b481
Fix standardize_code()
wlandau-lilly Oct 30, 2018
3b7455e
Fix #562
wlandau-lilly Oct 30, 2018
cd478eb
Merge branch '562' of github.com:ropensci/drake into 562
wlandau-lilly Oct 30, 2018
69ff455
Remove magrittr pipes
wlandau-lilly Nov 3, 2018
89d48c0
Merge branch 'master' into 562
wlandau-lilly Nov 3, 2018
4980d93
Fix a test
wlandau-lilly Nov 3, 2018
5178783
Fix merge conflicts in #563
wlandau-lilly Nov 14, 2018
09fee55
Merge branch 'master' into 562
wlandau-lilly Nov 27, 2018
a2715d7
Move around tests
wlandau-lilly Nov 27, 2018
2a78453
Merge branch 'master' into 562
wlandau-lilly Dec 4, 2018
9bde196
Merge master
wlandau-lilly Dec 9, 2018
60a4462
Merge branch 'master' into 562
wlandau-lilly Dec 15, 2018
ae4f4b8
Fix #562
wlandau-lilly Dec 16, 2018
dacb836
Merge branch 'master' into 562
wlandau-lilly Dec 16, 2018
f4ddf0c
Merge branch 'master' into 562
wlandau-lilly Jan 2, 2019
cf6f9aa
Use simple deparsing to standardize commands
wlandau-lilly Jan 2, 2019
a2c0c10
Add back lost files
wlandau-lilly Jan 2, 2019
5274ed3
Use NA_character_
wlandau-lilly Jan 2, 2019
f4bf10f
Try to avoid unnecessary hidden deparsing
wlandau-lilly Jan 2, 2019
5a82537
Refresh codemeta.json
wlandau-lilly Jan 2, 2019
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
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Depends:
Imports:
base64url,
digest,
formatR,
igraph,
methods,
pkgconfig,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export(workplan)
importFrom(base64url,base32_decode)
importFrom(base64url,base32_encode)
importFrom(digest,digest)
importFrom(formatR,tidy_source)
importFrom(igraph,V)
importFrom(igraph,adjacent_vertices)
importFrom(igraph,components)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Version 6.2.1 is a hotfix to address the failing automated CRAN checks for 6.2.0

## Enhancements

- Remove strict dependencies on packages `evaluate`, `formatR`, `fs`, `future`, `parallel`, `R.utils`, `stats`, and `stringi`.
- **Large speed boost**: reduce repeated calls to `parse()` in `code_dependencies()`.
- **Large speed boost**: change the default value of `memory_strategy` (previously `pruning_strategy`) to `"speed"` (previously `"lookahead"`).
- Compute a special data structure in `drake_config()` (`config$layout`) just to store the code analysis results. This is an intermediate structure between the workflow plan data frame and the graph. It will help clean up the internals in future development.
Expand Down
33 changes: 11 additions & 22 deletions R/commands.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,10 @@ preprocess_command <- function(command, config) {
as.call(c(quote(rlang::expr), command))
}

# The old standardization command
# that relies on formatR.
# Eventually, we may move to styler,
# since it is now the preferred option for
# text tidying.
# The important thing for drake's standardization of commands
# is to stay stable here, not to be super correct.
# If styler's behavior changes a lot, it will
# put targets out of date.
standardize_command <- function(x) {
x <- ignore_ignore(x)
x <- language_to_text(x)
x <- formatR::tidy_source(
source = NULL,
comment = FALSE,
blank = FALSE,
arrow = TRUE,
brace.newline = FALSE,
indent = 4,
output = FALSE,
text = as.character(x),
width.cutoff = 119
)$text.tidy
x <- paste(x, collapse = "\n")
braces(x)
standardize_code(x)
}

ignore_ignore <- function(expr) {
Expand Down Expand Up @@ -86,3 +65,13 @@ language_to_text <- function(x) {
}
x
}

standardize_code <- function(x){
if (!length(x)){
return(NA_character_)
}
if (is.character(x)) {
x <- parse(text = x, keep.source = FALSE)[[1]]
}
deparse(x)
}
2 changes: 0 additions & 2 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,6 @@ drake_config <- function(
}
seed <- choose_seed(supplied = seed, cache = cache)
trigger <- convert_old_trigger(trigger)
decode <- ht_new()
encode <- ht_new()
layout <- whole_static_analysis(
plan = plan,
envir = envir,
Expand Down
1 change: 0 additions & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#' @useDynLib drake
#' @importFrom base64url base32_decode base32_encode
#' @importFrom digest digest
#' @importFrom formatR tidy_source
#' @importFrom igraph adjacent_vertices components delete_vertices
#' degree igraph_opt igraph_options induced_subgraph is_dag
#' make_empty_graph set_vertex_attr simplify subcomponent
Expand Down
9 changes: 0 additions & 9 deletions R/test.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ with_all_options <- function(code) {
force(code)
}

write_v4.3.0_project <- function() { # nolint
zip <- system.file(
file.path("testing", "built_mtcars_example_v4.3.0.zip"),
package = "drake",
mustWork = TRUE
)
unzip(zip, exdir = ".", setTimes = TRUE)
}

write_v6.2.1_project <- function() { # nolint
zip <- system.file(
file.path("testing", "built_mtcars_example_v6.2.1.zip"),
Expand Down
8 changes: 2 additions & 6 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ assert_pkg <- function(pkg, version = NULL, install = "install.packages") {
invisible()
}

braces <- function(x) {
paste("{\n", x, "\n}")
}

clean_dependency_list <- function(x) {
if (!length(x)) {
clean_dependency_list <- function(x){
if (!length(x)){
return(character(0))
}
x <- unlist(x)
Expand Down
44 changes: 10 additions & 34 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"codeRepository": "https://github.com/ropensci/drake",
"issueTracker": "https://github.com/ropensci/drake/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "6.2.1.9000",
"version": "6.2.1.9001",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"version": "3.4.3",
"version": "3.5.2",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 3.4.3 (2017-11-30)",
"runtimePlatform": "R version 3.5.2 (2018-12-20)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -100,18 +100,6 @@
},
"sameAs": "https://CRAN.R-project.org/package=bindr"
},
{
"@type": "SoftwareApplication",
"identifier": "callr",
"name": "callr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=callr"
},
{
"@type": "SoftwareApplication",
"identifier": "clustermq",
Expand Down Expand Up @@ -379,19 +367,19 @@
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.3.0"
"version": ">= 3.4.0"
},
{
"@type": "SoftwareApplication",
"identifier": "codetools",
"name": "codetools",
"identifier": "base64url",
"name": "base64url",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=codetools"
"sameAs": "https://CRAN.R-project.org/package=base64url"
},
{
"@type": "SoftwareApplication",
Expand All @@ -405,18 +393,6 @@
},
"sameAs": "https://CRAN.R-project.org/package=digest"
},
{
"@type": "SoftwareApplication",
"identifier": "formatR",
"name": "formatR",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=formatR"
},
{
"@type": "SoftwareApplication",
"identifier": "igraph",
Expand Down Expand Up @@ -478,9 +454,9 @@
"name": "utils"
}
],
"releaseNotes": "https://github.com/bpbond/drake/blob/master/NEWS.md",
"readme": "https://github.com/bpbond/drake/blob/master/README.md",
"fileSize": "489.96KB",
"releaseNotes": "https://github.com/ropensci/drake/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/drake/blob/master/README.md",
"fileSize": "379.5KB",
"contIntegration": [
"https://ci.appveyor.com/project/ropensci/drake",
"https://travis-ci.org/ropensci/drake",
Expand Down
Loading