-
Notifications
You must be signed in to change notification settings - Fork 187
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
User-defined S3 methods & object_name_linter
#737
Comments
Cross-ref #223 |
Cross-ref #182 (Jim states that it's not possible to determine if a given function is an S3 method without loading all possible S3 generics) |
Could a simple solution be let the user provide a set of allowed-suffixes for function-names? eg, here (".default", ".data.frame", ".list") |
Is the |
I'm not sure what you mean by correctly detected. The resulting NAMESPACE file looks like this:
|
I wonder if lintr recognizes it, i.e. if If not, I'd consider that a bug, since Imagine defining
Not even that should lint IMO. |
|
Where
Should the generic or the method be greedy in this regex? Assuming the generic name does not have a dot in it, we can do:
This forces the user to disallow "." in the generic name; which would (detrimentally) prevent them from adding |
I think we should make the generic explictly and greedily match exactly what is in the A useful test case might be your suggestion
This should match the generic
(typo intended) |
* capture specifically generic names fixes #737 * add NEWS bullet * add regression test file * add anchors to regex remove empty string "generics" * add .lintr file to not exclude regression test file * improve generic detection * fix vapply * make s3 detection more robust * backwards compatible base s3 generics * try fixing compatibility issues with R 3.3 and 3.4 * typo * fix R CMD check warning (by wrapping) * remove dead code * de-lint * use nzchar * fix typo, improve style, fix compare_branches.R (forgot the fallback to UTF-8) Co-authored-by: Michael Chirico <chiricom@google.com> Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
This has been raised in a few issues (which I think have all been closed). But it isn't an issue that has really been solved.
If a newly minted package defines a generic and an S3-method based on that generic:
then, IMO, the expected behaviour when running
lint_package(linters = object_name_linter("snake_case"))
is for no lints to be thrown. Only the name of the generic should be subject to the snake-case linter.But the
.<className>
suffix throws a lint because of there being multiple dots in thedrink_me.data.frame
To reproduce
lint_package(linters = object_name_linter("snake_case"))
drink_me.data.frame
This is an issue that arose while experimenally running
lint_package(linters = object_name_linter(c("snake_case", "camelCase", "symbols")))
on {targets} (https://github.com/ropensci/targets)The text was updated successfully, but these errors were encountered: