-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: introduce lintr #70
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see this.
Do we like this formatting style?
Yes, though I wish it allowed =
instead of <-
. Surprisingly no one has asked for that in lintr's issues.
Should I add a pre-commit hook for styler? Currently the use of styler is not enforced anywhere.
Maybe wait on this and see how it goes? I don't love pre-commit hooks because they slow things down. It would be nice if styler could run in a "report-only" mode.
.lintr
Outdated
object_name_linter = object_name_linter("camelCase"), | ||
open_curly_linter = NULL, | ||
closed_curly_linter = NULL, | ||
object_usage_linter = NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also looks like it can be left enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's left enabled, I get the following errors:
R/util.R:91:11: warning: no visible binding for global variable ‘lastError’
pkg.env$lastError
^~~~~~~~~
R/util.R:146:16: warning: no visible binding for global variable ‘_id’
val <- vals$`_id`
^~~
The first I can fix by adding pkg.env$lastError <- NULL
at the top of util.R
. The second I could just skip with # nolint
.
But one of the biggest reasons to use lintr
is for IDE integration, imho, and unfortunately any package-internal functions (i.e. those that aren't included in the roxygen
-generated NAMESPACE
) will threw an error (see r-lib/lintr#482).
Additionally, object_usage_linter
executes package code with eval
during checks, which is potentially a bit dangerous (although there aren't any other contributors to the package, so it's probably not a huge concern).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, fine to leave it then.
(I'd like to get rid of getLastError
btw. R has better facilities with try/catch I think.)
Just for my understanding, is the second one a false-positive? We have other code like getStatistics.R:161 percentOf <- serverPops$`_id`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering as well if it was a false positive. At any rate, I managed to quiet the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does indeed appear to be a bug in lintr. I haven't tried to make a minimal repro to open an issue there. How'd you quiet the error?
Also: need to build the .Rd files! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one tiny comment below and another above. ⬆️
80de747
to
33e08b0
Compare
Here we go, it's CRAN's policy. https://cran.r-project.org/doc/manuals/r-release/R-exts.html
So maybe it will be happy with |
Confirmed, single quotes make it happy. I don't care if it's |
This was formatted with the
styler
/tidyverse
defaults (https://styler.r-lib.org/index.html).Q's:
styler
? Currently the use ofstyler
is not enforced anywhere.