Skip to content

Recommend styler over formatR suggestion #57

@lcolladotor

Description

@lcolladotor

Hi,

Based on my recent work for r-lib/actions#84 and at https://github.com/leekgroup/derfinderPlot/blob/master/dev/02_update.R, I want to make a small PR to BiocCheck and http://www.bioconductor.org/developers/how-to/coding-style/. This is directly related to r-lib/styler#636.

While formatR has been really helpful, in my experience when I use it, I need to double check very carefully all the code as it might change the meaning of some of it. My understanding is that styler is the package that is best maintained now for styling code (you still need to check your code! but styler seems to do a better job) and I quickly stumbled upon it yesterday on a Google search. Unlike formatR, it's compatible with tidyverse code (magrittr pipes and multi-line piped code), it also updates the example code in roxygen2-formatted examples. For my derfinderPlot package (a small one I was testing things with), it didn't break any code unlike formatR (see r-lib/styler#636 for the quotes issue).

styler has a styler::tidyverse_style() function and at r-lib/styler#636 I'm suggesting creating a styler::bioc_style() or styler::bioc_like_style() function that builds upon their styler::tidyverse_function(). Even without such a function, you can currently use styler like I did so at https://github.com/leekgroup/derfinderPlot/blob/master/dev/02_update.R#L2-L12 when updating my derfinderPlot package. Hopefully they like the idea, at which point, I would make a PR in styler. Probably styler::bioc_like_style() is the better name since I wouldn't want the function to enforce things like camelCase, somefunc(a=1, b=2) over somefunc(a = 1, b = 2), but well, those aren't really checked by BiocCheck anyway.

Both styler and formatR have issues with line lengths as noted in r-lib/styler#247, but from what I read there, it's a very complicated problem.

For BiocCheck, if you like the idea, I'm suggesting making a PR that either recommends styler first and formatR second, or only recommends styler (given that styler seems to me more actively maintained). I would also like to make the same suggestion for http://www.bioconductor.org/developers/how-to/coding-style/ though I don't know if there's a GitHub repo for the Bioc website.

Best,
Leo

Metadata

Metadata

Assignees

Labels

BeginnerBeginner level Hackathon project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions