Skip to content
/ pedant Public

Transform code from using implicit function calls to explicit using the double-colon operator.

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

wurli/pedant

Repository files navigation

R-CMD-check

{pedant}

{pedant} lets you quickly transform R code to pedantically use explicit function calls instead of implicit, either by running add_double_colons() or using the handy RStudio addin "Make function calls explicit".

RStudio addin demo

RStudio addin demo

Installation

You can install the development version using

remotes::install_github("wurli/pedant")

Usage

If you’re developing a package, {pedant} will look at the DESCRIPTION and NAMESPACE files to work out which packages to use when making functions explicit. Otherwise it will use the currently attached packages, i.e. the ones already loaded using library(). You can manually specify the packages to look in using the use_packages argument to add_double_colons():

library(dplyr, warn.conflicts = FALSE)

code <- 
 "mtcars %>%
    filter(mpg > 20) %>%
    summarise(across(everything(), n_distinct))"

# Code will be transformed to use the double-colon operator, but notice
# that `n_distinct` is not transformed as it is not followed by `()`
cat(add_double_colons(code))
## mtcars %>%
##     dplyr::filter(mpg > 20) %>%
##     dplyr::summarise(dplyr::across(dplyr::everything(), n_distinct))

Why?

Often, during package development I forget to use explicit function calls and am then faced with the onerous task of cleaning up my own code. I wrote this package so I can continue this bad habit.

Bug reports / feature requests

Please post these as issues on github

About

Transform code from using implicit function calls to explicit using the double-colon operator.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages