README.md

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



lorenzwalthert/semicoloner documentation built on Dec. 21, 2021, 11:48 a.m.