Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate the styler package with pre-commit #24

Open
stephaniereinders opened this issue Sep 30, 2022 · 1 comment
Open

Incorporate the styler package with pre-commit #24

stephaniereinders opened this issue Sep 30, 2022 · 1 comment
Labels
best practices Making changes to follow best practices

Comments

@stephaniereinders
Copy link
Member

https://github.com/lorenzwalthert/precommit

@stephaniereinders stephaniereinders added the documentation Changing or creating new documentation label Sep 30, 2022
@ahgamut
Copy link
Contributor

ahgamut commented Sep 30, 2022

The pre-commit R package mentioned in the above link uses Python in the background to do a bunch of things automatically whenever you do a git commit:

  • style your code using the styler package
  • lint your code using the lintr package (point out potential bugs/inconsistencies)
  • render vignettes
  • check your package has all dependencies listed out properly, etc.

pre-commit requires a simple yml configuration file, and it requires python to be installed on your computer.

I tried it out here: https://github.com/ahgamut/handwriter/commits/rearrange

The advantage of pre-commit is that it automatically enforces a consistent style and structure on the code in an R package.

One of the disadvantages is that if you introduce pre-commit after a while, it can add a lot of changes at once, which messes with git blame and the update history of the code.

Perhaps a pre-commit can be attempted after other updates to handwriter.

@stephaniereinders stephaniereinders added best practices Making changes to follow best practices and removed documentation Changing or creating new documentation labels Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
best practices Making changes to follow best practices
Projects
None yet
Development

No branches or pull requests

2 participants