Skip to content

Generics defined in other files not detected by object_name_linter() and object_length_linter() #1808

@AshesITR

Description

@AshesITR

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    false-positivecode that shouldn't lint, but does

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions