Styler Versions Save

Non-invasive pretty printing of R code

v1.10.3

1 month ago

This release was requested by the CRAN team since parser error messages changed, which were hard-coded in some unit tests (#1180).

Minor changes

  • Add a package sticker (#1172, #1173).
  • Improve error message for scope (#1176).
  • Update lintr config and address newly found lints (#1158).
  • Fix new lints about implicit return (#1166).
  • Clean new lints (#1149).
  • Clean up unnecessary YAML front matter in README (#1165).

CI

  • Update pre-commit and GitHub Actions (#1177, #1175, #1171, #1171, #1164, #1152, #1148).
  • Delete URL check workflow (#1160).

Testing

  • Suppress warning in io tests (#1169).
  • Ensure unit tests check for appropriate error messages in the R parser for R > 4.3 (#1180).
  • Remove outdated test about repeated parsing (#1163).
  • Update roxygen test comments (#1162).
  • Delete unused snapshot (#1159).

We thank everyone who helped making this release possible: @AshesITR, @averissimo, @IndrajeetPatil, @lorenzwalthert, @mcanouil, @moodymudskipper, @olivroy, @sbanville-delfi, @sorhawell, @ssh352, @swo, and @vertesy.

v1.10.2

8 months ago

This release was requested by the CRAN team to fix CRAN warning on invalid numeric version inputs (#1143).

Minor changes

  • Use cli messaging for cache (#1127).
  • Use latest (and stable!) pre-commit (#1144).
  • Fix CRAN warning on invalid numeric version inputs (#1143).
  • Bump JamesIves/github-pages-deploy-action from 4.4.2 to 4.4.3 (#1139).
  • fix pre-commit (#1132).
  • Don't require dplyr anywhere (#1131).

We thank everyone who helped making this release possible.

@krlmlr, @lorenzwalthert, @MichaelChirico, @olivroy, @rkrug, and @rossdrucker.

v1.10.1

11 months ago

This release was requested by CRAN due to accidentally populating a user cache while building vignettes for R >= 4.3.0.

  • Deactivate caching in vignette creation (#1124).
  • Code quality improvements (#1122).
  • Use {cli} message for cache (#1127).
  • Use tempdir() to get temporary directory instead of own unreliable heuristic (#1126).
  • Bump JamesIves/github-pages-deploy-action from 4.4.1 to 4.4.2 (#1123).

Thanks to everyone who contributed to this release: @olivroy and @krlmlr.

v1.10.0

11 months ago

This release contains speed-ups between 20% and 40% depending on your use case thanks to replacing {base} functionality with {vctrs} (#1114). With the speed boost introduced in version 1.8.0 in Oct. 2022, {styler} is now up to 2x as fast as before release 1.8.0.

This release was created upon a request by the CRAN team to actively manage not just cached files but also the potentially empty cache directories they live in (#1118). Here are the changes in detail:

  • Require at least R 3.6 (#1101).
  • Prefer {vctrs} functions over slower {base} equivalents (#1114).
  • Replace deprecated use of rlang::with_handlers() (#1103).
  • Remove tail recursion in favor of repeat (#1113).
  • split test-public_api.R for better sharding (#1109).
  • 0-pad filenames for sharding (#1110)
  • add missing {testthat} snapshots (#1115).
  • Bump {touchstone} config (#1104, #1107).
  • Bump actions/checkout to version 3 in GitHub Actions (#1098).

Thanks for everyone contributing to this release:

@IndrajeetPatil, @krlmlr, @kyleam, @MichaelChirico, @mvanaman, @olivroy, and @vvarik.

v1.9.1

1 year ago

Bug fixes

  • Fix interaction between cache and stylerignore that could produce invalid code (#1072).
  • Don't remove line break around {{ and comments that can yield invalid code (#1070).
  • Styling empty roxygen code examples don't cause errors anymore (#1096).
  • Double indent is also kept if there is only one argument (#1094).
  • Improved blank lines handling for roxygen examples (#1085).
  • style roxygen examples even if nothing comes after (#1089).

Other

  • Document "qmd" as a valid filetype (#1091).

Thanks for everyone who contributed to this release:

@dpprdan, @flying-sheep, @giocomai and @MichaelChirico.

v1.9.0

1 year ago

Features

  • The tidyverse recently introduced double-indention for function declarations that don't fit on one line. It indents two levels, i.e. 4 spaces if you indent_by two spaces.
# old style: remains compliant and won't be re-styled
my_fun <- function(long_argument = 2,
                   indent_up_to_first = "x") {
  # ...
}

# new style: now also compliant and won't be re-styled
my_fun <- function(
    long_argument = 2,
    indent_double = "x") {
  # ...
}

You can also use the R package {codegrip} to toggle between the two modes (#1083).

Bug fixes

  • Previously styled code that is now stylerignored should always be formatted correctly. It boils down to the requirement that stylerignore sequences must always be in the same block (#1082).
  • styling around {{ and comments now yields parsable output (#1088).
  • trailing blank lines in roxygen code examples are removed (#1085).
  • roxygen code examples that don't have any code following after them are now also styled (#1067).

Other user-facing changes

  • Less noisy communication if R option styler.cache_root is not set (#1063).

Infrastructure

  • use {lintr} config (#1057, #1059) and pre-commit hook (#1064).
  • use new {pkgdown} hook, check for parsable yaml and mixed line ending (#1080, #1081).
  • update GitHub Actions workflow versions one time (#1073) and add dependabot for the future (#1974).
  • bdr test for additional examples (#1068).
  • check for link rot regularly (#1077, #1086).

Internals

  • replace retired purrr::when() with if statements (#1066).
  • more integer literals (#1054).
  • Consistently use @examplesIf for conditionally running examples (#1071).
  • document imports in a single file (#1060).
  • format YAML files (#1061).

A big shout out to anyone who contributed to this release:

@balthasars, @hadley, @IndrajeetPatil, @juliangrimm225 and @krlmlr.

v1.8.1

1 year ago

Features

  • Expose internals used with other style guides (@Robinlovelace + collaborators, #1043, #1052).

Other

  • Bump minimal version requirement on {withr} as ... in withr::local_options() was introduced only in v.2.3.0 (#1051).
  • Rename internal function set_linebreak_after_ggplot2_plus() to set_line_break_after_ggplot2_plus() for consistency (@Polkas, #1049).
  • Reformat contributing guidelines (#1047).
  • Improve YAML formatting for pkgdown (#1042).
  • Simplify caching internal's conditionals with rlang::%||% (#1041).
  • Only run {pkgapi} if available (#1039).
  • Typos (@MichaelChirico, #1038)

This release was requested by CRAN to resolve an R CMD Check note (#1044). A big hand to everyone who made this release possible:

@DaveJarvis, @IndrajeetPatil, @lorenzwalthert, @MichaelChirico, @Polkas and @Robinlovelace.

v1.8.0

1 year ago

{styler} 1.8.0 comes with a host of new features like support for quarto documents, around 40% speed improvement, bug fixes and the removal of 8 recursive dependencies. We also welcome @IndrajeetPatil as a new contributor to {styler}, who has contributed significantly to this and and previous releases.

Features

  • style_dir() and style_pkg() now default to styling all supported file formats (.R, .Rmd, .Rmarkdown, .Rnw, and .qmd) in the (package) directory (#965, #931, #1033).
  • style_pkg() now excludes the auto-generated R/cpp11.R file (#977).
  • alignment is now detected for function declaration in a similar way as for function calls (#968).
  • new R option styler.ignore_alignment controls if alignment should be detected (and preserved) or not (#932).

Bug Fixes

  • alignment is detected in tibble::tribble() (and similar) calls with more than 3 columns when left aligned (#945).

  • fix alignment detection for one column, mixed named/unnamed (#1035).

  • if there are only empty lines in a code chunk, they are all removed (#936).

  • apply rules for [ to [[ and its closing counterpair (#1030)

  • there is now at most one line break after { and before # (#952, #1022).

  • line breaks may be added to function calls to ensure indention symmetry for round braces (#975).

  • the cache is also invalidated on changing the stylerignore markers (#932).

  • { is not put on a new line after = and in function() { for some edge cases (#939).

  • while ({}) statements are now handled the same way as function statements with regards to breaking lines (#967).

  • parsing of {roxygen2} example comments now also works for edge cases when there is no literal code immediately following after the end of the example section (#940).

  • files with no tokens in it are now transformed into zero-byte files (#962).

Documentation

  • old (and outdated) vignettes have been removed (#955). To access them, do git checkout v1.0.0.
  • minor improvements to the documentation (#958).
  • turned off styler.colored_print.vertical in vignettes so ANSI output of {prettycode} not messing with {pkgdown} (#956, #957).

Performance and code quality improvements

  • use integer literals and avoid coercions where needed (#994).
  • don't preserve names for unlist() (#998).
  • remove unused variables (#999).
  • get rid of lints with performance implications (#1000).
  • use more efficient match() alternative (#1001).
  • don't use nrow arg in new_tibble() calls (#1003).
  • performance improvements with if() + else() instead of ifelse() (#1006).
  • replace tibbles with data frames to improve performance (#1007).
  • simplify styler_df() signature (#1009).
  • minor cleanup (#1016).
  • non-exported and unused functions odd() and even() were removed (#989).
  • all (R)md files in this project's source code are now formatted with default pandoc markdown formatter. This conversion is required when using the visual mode in RStudio (#941).
  • improved code quality by fixing {lintr} warnings (#960, #1028).

In total, 8 recursive dependencies are removed: {ellipsis}, {pillar}, {rematch2}, {tibble}, {utf8}, {fansi}, {lifecycle}, {pkgconfig}.

  • don't import entire tibble package (#1007).
  • drop {rematch2} dependency (#1011).
  • minimum needed R version is now bumped to 3.5 (#986).

Infrastructure

  • upgrade testing infra to testthat 3e (#949).
  • run tests in parallel (#978).
  • run some tests sequentially (#1031)
  • better stack tracing for profiling (#979, #980).
  • add flags to skip code coverage for zzz.R (#1005).
  • error now on R CMD note (#987).
  • test on latest Ubuntu instead of Ubuntu 18.04 (#982).
  • use latest GitHub Actions for R (#1034).
  • update {pkgdown} action to always build, but only deploy on default branch (#946).
  • remove pre-commit push hook for news entry (#1023).

A big hand to everyone who made this release possible:

@behrman, @EngineerDanny, @gavinsimpson, @IndrajeetPatil, @jabenninghoff, @krlmlr, @lorenzwalthert, @MichaelChirico, @moodymudskipper, @RaymondBalise, @Robinlovelace, @sebffischer, @sgorm123, @stefanoborini, @wdkrnls.

v1.7.0

2 years ago

API changes

  • new R option styler.cache_root (defaulting to "styler") that determines the sub-directory under the {R.cache} cache directory that {styler} uses. Non-default caches won't be cleaned up by {styler}. We suggest "styler-perm" (also used by {precommit}).

  • stylerignore markers are now interpreted as regular expressions instead of comments that must match exactly. This allows to specify multiple markers in one regular expression for styler.ignore_start and styler.ignore_stop, e.g. to use markers for lintr and styler on the same line, you can use options(styler.ignore_start = "nolint start|styler: off":

    # nolint start, styler: off
    1 +1
    # nolint end
    # styler: on
    

    As a consequence of this approach, the defaults for styler.ignore_start and styler.ignore_stop omit the # (#849).

Features

  • {styler} can be ran via GitHub Actions using usethis::use_github_action("style") (#914).
  • added guarantee that styled code is parsable (#892).
  • Developers can now create style guides with indention characters other than spaces (#916).

Documentation

  • Add vignette on distributing style guide (#846, #861).
  • Fix argument name filetype in Example for style_dir() (#855).

Bug fixes

  • Piped function without brackets substitute(x %>% y) don't get () added anymore for one level deep (not more yet, see #889), as this can change outcome of the code (#876).
  • .onLoad() method no longer broken with {cli} >= 3.1 (#893).
  • Function calls containing + should no longer give any error on styling when there are comments and line breaks under certain circumstances (#905).
  • rules that add tokens don't break stylerignore sequences anymore (#891).
  • Alignment detection respects stylerignore (#850).
  • Unaligned expressions with quoted key (e.g. c("x" = 2)) are now correctly detected (#881).
  • ~ causes now indention, like +, -, | etc. (#902).
  • Warning: Unknown or uninitialised column: was fixed (#885).
  • function calls with unequal number of token on different lines are no longer deemed aligned if there are arbitrary spaces around the tokens on the lines with most tokens (#902).
  • if a line starts with EQ_SUB (=), the corresponding key is moved to that line too (#923).
  • ensure a trailing blank line also if the input is cached (#867).
  • Preserve trailing blank line in roxygen examples to simplify concatenation of examples (#880).
  • indenty_by is now also respected when curly braces are added to an if statement by {styler} (#915).
  • An error is now thrown on styling if input unicode characters can't be correctly parsed for Windows and R < 4.2 (#883).
  • styling of text does not error anymore when the R option OutDec is set to a non-default value (#912).

Infrastructure

  • Remove dependency on {xfun} (#866).
  • Remove {glue} dependency that was only used by {touchstone} script and is declared as a dependency already in the respective action (#910).
  • Bump minimal R requirement to 3.4 in line with the tidyverse, which allowed to remove the dependency at {backports} and some exception handling.
  • rename default branch to main (#859).
  • the built package size has been reduced by ~50% by listing *-in_tree files in .Rbuildignore (#879).
  • Enable pre-commit.ci (#843).
  • use pre-commit via GitHub Actions (#872).
  • terminate running jobs on new push to save resources (#888).
  • Use the {touchstone} GitHub Action instead of the literal script (#889).
  • upgrade R CMD check Github Actions to use v2.
  • {styler} test are relaxed to not assume a specific error message on the wrong usage of _ (#929).

Thanks to all contributors that made this release possible:

@bersbersbers, @daniel-wrench, @dbykova, @EngrStudent, @hadley, @IndrajeetPatil, @jam1015, @jooyoungseo, @kalaschnik, @kaytif, @kpagacz, @krlmlr, @lionel-, @lorenzwalthert, @maelle, @MichaelChirico, @mine-cetinkaya-rundel, @neuwirthe, @Polkas, @pwang2, @sebffischer, @ShixiangWang, @ssh352, and @xjtusjtu.

v1.6.2

2 years ago
  • clean up cache files older than one week (#842).