Skip to content

Conversation

@BjarkeHautop
Copy link
Contributor

@BjarkeHautop BjarkeHautop commented Nov 13, 2025

This changes the snippet_generate('additional-deps-lintr') to also include suggested dependencies, so {lintr} works on vignettes, README, etc. Modifed default hook to include args: [--load_package] for lintr.

These changes prevents the default hooks from automatically failing when calling use_precommit() on a package, since {lintr} would fail if the package had any dependencies (or simply when the package calls its own function from another file).

Also removed an old print about roxygenize that always appeared.

@BjarkeHautop BjarkeHautop marked this pull request as draft November 13, 2025 13:48
@BjarkeHautop BjarkeHautop marked this pull request as ready for review November 13, 2025 14:03
@lorenzwalthert
Copy link
Owner

Hi @BjarkeHautop, thanks for your contributions. Before you spend time on code changes, let's discuss them in an issue as per the CONTRIBUTING.md. The --load-package is not the default and I'd like to keep it that way. The reason for it is that it won't be compatible with pre-commit.ci since installing the whole dependency tree would most likely trigger a timeout there. Also, I am not sure I'd agree with your statement that --load-package is required for the hooks to work on packages. {styler} does not have it and things seem to work fine.

@BjarkeHautop
Copy link
Contributor Author

BjarkeHautop commented Nov 21, 2025

I originally mentioned the motivation here: #648 (I realize that isn’t an issue).

For {styler}, things work because the config excludes all the locations where it would otherwise fail, so it doesn't actually run on the whole package:

exclude: >
          (?x)^(
          inst/.*|
          man/.*|
          tests/.*|
          touchstone/.*|
          vignettes/.*|
          )$

My concern is that a user sees the package, tries the default hooks on their own (non-trivial) package, and lintr-hook will fail with no clear way to address it. So, the user now needs to look at github issues and/or go through documentation to find out why (in particular that happend to me at #647), or they may simply decide not to use the package at all.

That said, the part of the PR in commit 1aa1ff5 (possibly with a small modification) still addresses the issue that adding only hard dependencies via snippet_generate("additional-deps-lintr") is not enough to make lintr-hook work out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants