Skip to content

Third-party style guide for {styler}: Put a semi-colon after every expression

License

Unknown, MIT licenses found

Licenses found

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

lorenzwalthert/semicoloner

Repository files navigation

semicoloner

Lifecycle: experimental R-CMD-check

The goal of semicoloner is format code according to one rule: Put a semi-colon after every expression. It is an example for a custom {styler} style guide.

Installation

You can install the released version of semicoloner from CRAN with:

remotes::install_github("lorenzwalthert/semicoloner")

Example

This is a basic example which shows you how to solve a common problem:

library(semicoloner)
cache_deactivate()
#> Deactivated cache.
text <- 'communicate_warning <- function(changed, transformers) {
  if (any(changed, na.rm = TRUE) &&
    !can_verify_roundtrip(transformers) &&
    !getOption("styler.quiet", FALSE)
  ) {
    cat("Please review the changes carefully!", fill = TRUE)
  }
}
a
b
c /
  3
d + 3
'

style_text(text)
#> communicate_warning <- function(changed, transformers) {
#>   if (any(changed, na.rm = TRUE) &&
#>     !can_verify_roundtrip(transformers) &&
#>     !getOption("styler.quiet", FALSE)
#>   ) {
#>     cat("Please review the changes carefully!", fill = TRUE);
#>   };
#> };
#> a;
#> b;
#> c /
#>   3;
#> d + 3;

Principles

  • re-export all exported functions from {styler}, purrr::partial() style guide arguments with third-party style guide.
  • implement more_args and transformer_drop in create_style_guide().

About

Third-party style guide for {styler}: Put a semi-colon after every expression

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages