aaronrudkin / werner Goto Github PK
View Code? Open in Web Editor NEWA R package designed to improve package code quality by assessing relationships between functions in packages.
License: Other
A R package designed to improve package code quality by assessing relationships between functions in packages.
License: Other
MWE:
library(werner)
explore_package("foreign")
Not super clear why this works but testthat's version doesn't; I'm guessing I need to add any packages that are tested into "Suggests".
MWE:
library(werner)
explore_package("Zelig")$`Zelig::to_zelig`
Consider base::tryCatch
:
function (expr, ..., finally)
{
tryCatchList <- function(expr, names, parentenv, handlers) {
nh <- length(names)
if (nh > 1L)
tryCatchOne(tryCatchList(expr, names[-nh], parentenv,
handlers[-nh]), names[nh], parentenv, handlers[[nh]])
else if (nh == 1L)
tryCatchOne(expr, names, parentenv, handlers[[1L]])
else expr
}
...
tryCatchList(expr, classes, parentenv, handlers)
}
It's obvious that tryCatchList
is defined within the function. werner handles these improperly, returning INVALID namespace for the internal functions.
library(werner)
explore_package("base")$`base::tryCatch`
I believe that calls from one function to another via a *apply function are not being recorded, possibly because the function is resolving as a symbol rather than a language call, so it's not being picked up?
utils at some point creates an environment with the name tools.rstudio which at least one function call calls; this causes an error because of my strategy for finding functions by loading packages onto the namespace not working when the package in question isn't a package. I mitigated it by detecting it and ignoring it, but not totally sure if there's something else I should be doing here. Probably ephemeral to utils.
INVALID resolutions in base:
library(werner)
z = explore_package("base")
z$`base::unloadNamespace`
base::unloadNamespace
resolves to:
function (ns)
{
if ((is.character(ns) && any(ns == loadedNamespaces())) ||
(is.environment(ns) && any(getNamespaceName(ns) == loadedNamespaces()))) {
runHook <- function(hookname, env, ...) {
if (!is.null(fun <- env[[hookname]])) {
res <- tryCatch(fun(...), error = identity)
if (inherits(res, "error")) {
warning(gettextf("%s failed in %s() for '%s', details:\n call: %s\n error: %s",
hookname, "unloadNamespace", nsname, deparse(conditionCall(res))[1L],
conditionMessage(res)), call. = FALSE, domain = NA)
}
}
}
...
}
The fun()
call is obviously defined inside the function.
Functions which take function calls as arguments and then use those function calls later will currently flag INVALID:
MWE:
library(werner)
explore_package("base")$`base::outer`
FUN
is an argument to outer which defaults to "*"
.
Currently, .Internal methods are not correctly supported; werner will find the function, be unable to namespace it (because it doesn't exist in any namespace).
MWE:
library(werner)
explore_package("base")$`base::readRDS`
It would be slick if long functions were larger and short functions were smaller. LoC is one measure, out degree would be another.
library(werner)
explore_package("testthat")
Trying to explore the base package will fail because werner will hit functions that are reserved keywords and fail to backtick them. I should add to the name quoter context for these.
The reserved keywords are:
"while", "repeat", "next", "if", "function", "for", and "break"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.