Skip to content

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

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

Activity

  1. added 2 commits that reference this issue on Dec 13, 2022
    67bd22d
    79848fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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