R/generic.R
my_generic <- function(x, ...) {
UseMethod("my_generic")
}
R/other.R
my_generic.other <- function(x, ...) {
# code
}
Should not be linted by object_name_linter(), and object_length_linter() should only consider "other" for length computations.
I can see multiple options here:
- Inspect all visible functions whether they are generics
- Inspect the Package
NAMESPACE file for S3method(my_generic,<anything>) to deduce my_generic must be an S3 generic
The former also works for non packages but is more expensive.
The latter should be easier, using unique(parseNamespaceFile("package", "..")$S3methods[, 1L]) similar to namespace_imports().
R/generic.R
R/other.R
Should not be linted by
object_name_linter(), andobject_length_linter()should only consider"other"for length computations.I can see multiple options here:
NAMESPACEfile forS3method(my_generic,<anything>)to deducemy_genericmust be an S3 genericThe former also works for non packages but is more expensive.
The latter should be easier, using
unique(parseNamespaceFile("package", "..")$S3methods[, 1L])similar tonamespace_imports().