Code Monkey home page Code Monkey logo

fertile's People

Contributors

ambertin avatar beanumber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fertile's Issues

shim common functions

  • Input functions from tidyverse (read_csv(), etc.) and read.csv()
  • Output functions (write_csv(), write.csv(), etc.)
  • library() and require() (@hadley)
  • source()

Do a handful of these manually, and then consider a function factory or some kind of tidy evaluation.

Log the paths and calls to a CSV file (i.e., .fertile.csv)

In interactive mode, throw an error if the path is bad.

Have a sliding scale of strictness

auto-detect cruft

  • when you call a library, but don't use it
  • when you have data files that you don't load
  • when you have script files that you don't execute

warnings about no parameters to inherit

Warning: Topic 'has_tidy_media': no parameters to inherit with @inheritParams
* Topic 'has_tidy_images': no parameters to inherit with @inheritParams
* Topic 'has_tidy_code': no parameters to inherit with @inheritParams
* Topic 'has_tidy_raw_data': no parameters to inherit with @inheritParams
* Topic 'has_tidy_data': no parameters to inherit with @inheritParams
* Topic 'has_tidy_scripts': no parameters to inherit with @inheritParams
* Topic 'has_readme': no parameters to inherit with @inheritParams
* Topic 'has_proj_root': no parameters to inherit with @inheritParams
* Topic 'has_no_nested_proj_root': no parameters to inherit with @inheritParams
* Topic 'has_only_used_files': no parameters to inherit with @inheritParams
* Topic 'has_no_absolute_paths': no parameters to inherit with @inheritParams
* Topic 'has_only_portable_paths': no parameters to inherit with @inheritParams
* Topic 'has_no_randomness': no parameters to inherit with @inheritParams
* Topic 'has_no_lint': no parameters to inherit [... truncated]
Warning: Topic 'proj_test': no parameters to inherit with @inheritParams
* Topic 'proj_analyze': no parameters to inherit with @inheritParams
* Topic 'proj_analyze_files': no parameters to inherit with @inheritParams
* Topic 'proj_suggest_moves': no parameters to inherit with @inheritParams
* Topic 'proj_move_files': no parameters to inherit with @inheritParams
* Topic 'proj_analyze_pkgs': no parameters to inherit with @inheritParams
* Topic 'proj_analyze_paths': no parameters to inherit with @inheritParams

It must be related to the way that multiple function are documented on the same help page. Maybe is has something to do with the sections?

fertile conflicts with here::here()

> library(fertile)
> assets <- read_csv(here::here("assets.csv"))
Checking for absolute paths...
Error: Detected absolute paths
Run `rlang::last_error()` to see where the error occurred.

This seems bad, because the user is following best practices by using here(), but fertile doesn't see that -- it just gets the absolute path.

What can we do about this @ambertin ?

Transition advice from fs to usethis where possible

## ● Checking for README file(s) at root level
##    Problem: No README found in project directory
##    Solution: Create README
##    See for help: ?fs::file_create
## # A tibble: 1 x 2
##   culprit   expr                        
##   <chr>     <glue>                      
## 1 README.md fs::file_create('README.md')

The advice should probably be usethis::use_readme(), right?

allow user-specified directory structure

  • Maybe have a YAML file with sensible defaults
  • Provide an rticles/usethis-style set of templates for certain projects
    • maybe a journal would have their own layout
    • or Project TIER might have their own
    • or a company might have their
    • or an instructor might have their own

gather more helpful test projects

Good test projects:

  • range in complexity
  • do good and bad things
  • are small in terms of file sizes
  • don't take a long time to execute
  • mimic real world projects

show log of recent upgrade events

@jennybc says:

I do a casual install_github("this/that") and find that the bleeding edge version of something I inadvertently updated is a bit broken and I want to roll it back. I wish it were easy to see a log of recent upgrade events with “X.Y.Z -> “X*.Y*.Z*” or “SHA_before --> SHA_after” type of info.

See also #3

Extract srcref from call stack

Rough guess of what you need to do:

  1. Use rlang::call_stack() to get list of all calls leading to logging function
  2. Figure out how many levels you need to go back (maybe can do that by looking at a srcrefs so should actually happen after next step)
  3. Extract srcrefs somehow

Also look at rlang::trace_back() which should be capturing the srcrefs

Remedies for external paths

In various discussion around safe path practices, many people insist that they simply must refer to paths outside the project. I bet a lot of this can be eliminated but I also accept you can't completely design this problem away.

This solution presented by @HenrikBengtsson makes a 💡 go on for lots of people and I think you should have it on your radar here. Either helping people to implement it or providing it as a suggested remedy.

https://community.rstudio.com/t/project-oriented-workflow-setwd-rm-list-ls-and-computer-fires/3549/35?u=jennybryan

rename check()?

@jennybc says:

The name collision between fertile::check() and devtools::check() gives me pause. I guess it could be seen as a positive? But I think it's more negative.

How about fertile::proj_check()?

Where should default log go?

How do we keep track of where the log file goes? At @jennybc 's suggestion I am using rprojroot to find the project directory, but to return the working directory if find_root() fails.

But if somebody just tries to use read_csv(), we can't control whether they are in a project or what the working directory is at the time of the call. So to which log file should that event be written?

Symptom: devtools::test() currently returns 0 errors, but devtools::check() returns 3.

cannot dir_delete(test_path()) while running devtools::test()

When running the following lines of code, devtools::test() fails with this error:

screen shot 2019-03-04 at 7 08 18 pm

dir <- test_path() # "tests/testthat"
temp <- sandbox(dir)

Why is test_path() an invalid directory to delete? Is there a function that dir_delete can be replaced with in sandbox that will allow us to delete test_path()?

Danger block

Allows any dangerous code to run without warnings:

danger({
  x <- read.csv("~/a/path/that/only/exists/on/hadleys/computer.csv")
})

test_that ("danger works") works interactively, but fails under devtools::test()

When running the "danger works" test line by line, each line passes successfully. However, when running devtools::test(), the following error occurs:

screen shot 2019-03-04 at 6 59 06 pm

It appears to possibly a problem where we are unable to detach fertile while running test()

Reference code is given below:

danger <- function(expr) {
detach("package:fertile", unload = TRUE)
on.exit(require("fertile"), add = TRUE)
invisible(expr)
}

test_that("danger works", {
wd <- getwd()
expect_error(setwd(tempdir()), "setwd")
expect_message(danger(setwd(path_real(tempdir()))), "fertile")
expect_equal(path_real(getwd()), path_real(tempdir()))
base::setwd(wd)
})

Should has_*() functions be user-facing?

If a has_*() function, for example, has_only_portable_paths() requires compilation, then what is the best way to check if the project needs to be re-compiled?

In check(), we are going to run a bunch of these, so we compile once first, then do the checks. But if you just want to run one of these functions as a one-off, how is it supposed to know whether the log file accurately captures what happens during compilation? If we allow each function to trigger proj_render(), then this will be horribly inefficient.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.