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

Investigate checkUsage() output on internal functions #314

Open
joshuaulrich opened this issue Nov 2, 2019 · 1 comment
Open

Investigate checkUsage() output on internal functions #314

joshuaulrich opened this issue Nov 2, 2019 · 1 comment

Comments

@joshuaulrich
Copy link
Owner

joshuaulrich commented Nov 2, 2019

@harvey131 discovered an unused environment variable in .rbind.xts() in #313. So it would be a good idea to check for similar issues in all other unexported functions. That will avoid similar confusion in the future.

Here's some code that lists the output of codetools::checkUsage() on the xts namespace.

xtsNamespace <- asNamespace("xts")
xtsNsNames <- ls(xtsNamespace, all = TRUE)
xtsNsObj <- setNames(lapply(xtsNsNames, get, xtsNamespace), xtsNsNames)
xtsNsFunc <- xtsNsObj[sapply(xtsNsObj, is.function)]
checkFunc <- function(fbody, fname) {
  capture.output(codetools::checkUsage(fbody, fname))
}
out <- Map(checkFunc, xtsNsFunc, names(xtsNsFunc))
toCheck <- out[sapply(out, length) > 0]

And here's the output.

R> toCheck
$.rbind.xts
[1] ".rbind.xts: local variable 'env' assigned but may not be used"

$`[<-.xts`
[1] "[<-.xts: local variable '.Class' assigned but may not be used"

$addEventLines
[1] "addEventLines : <anonymous>: local variable 'ta.x' assigned but may not be used"
[2] "addEventLines: local variable 'ind' assigned but may not be used"               

$addLegend
[1] "addLegend: local variable 'ind' assigned but may not be used"

$addPolygon
[1] "addPolygon : <anonymous>: local variable 'ta.x' assigned but may not be used"

$as.fts.xts
[1] "as.fts.xts: local variable 'fts' assigned but may not be used"

$as.timeSeries.xts
[1] "as.timeSeries.xts: local variable 'timeSeries' assigned but may not be used"

$merge.xts
[1] "merge.xts: local variable 'sfx' assigned but may not be used"

$new.replot_xts
[1] "new.replot_xts: local variable 'get_pad' assigned but may not be used"   
[2] "new.replot_xts: local variable 'move_frame' assigned but may not be used"

$re.fts
[1] "re.fts: local variable 'fts' assigned but may not be used"

$re.irts
[1] "re.irts: local variable 'irts' assigned but may not be used"

$re.timeSeries
[1] "re.timeSeries: local variable 'timeSeries' assigned but may not be used"

$re.ts
[1] "re.ts: local variable 'dn' assigned but may not be used"

$re.ts2
[1] "re.ts2 : na.replace: local variable 'ncols' assigned but may not be used"
[2] "re.ts2: local variable 'na.replace' assigned but may not be used"        

$rollcov.xts
[1] "rollcov.xts: local variable 'n1' assigned but may not be used"

$rollmax.xts
[1] "rollmax.xts: local variable 'n1' assigned but may not be used"

$rollmin.xts
[1] "rollmin.xts: local variable 'n1' assigned but may not be used"

$rollsum.xts
[1] "rollsum.xts: local variable 'n1' assigned but may not be used"

$`tzone<-.default`
[1] "tzone<-.default: local variable 'tzone' assigned but may not be used"

It looks like some of those may be bugs... so we should discuss here, and then open issues for the ones that are actually bugs and not false positives.

@harvey131
Copy link
Contributor

  • I saw the "n1" in the roll functions so those seem to be used.
  • The "sfx" in merge.xts seems like it can be removed.
  • Also separately relating to merge.xts, cbind.xts could be cleaned up to remove commented code since it now calls merge.xts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants