Skip to content

object_length_linter should detect generics #871

Closed

Description

@AshesITR

As the object_name_linter already does, class suffixes for S3 generics shouldn't be part of the linted symbol.
That is, object_length_linter(30) (the default) shouldn't lint this example:

my_generic_function <- function(x, ...) {
  UseMethod("my_generic_function")
}

my_generic_function.my_cool_class <- function(x, ...) {
  cat("How cool and generic!\n")
}

Activity

  1. added
    bug
    on Oct 8, 2021
  2. stufield commented on Oct 9, 2021

    @stufield
    Contributor

    Yes! I've been bitten by this many times and have # nolint scattered throughout my generics definition files.
    Looking forward to this.

  3. AshesITR commented on Oct 9, 2021

    @AshesITR
    CollaboratorAuthor

    For now, I've even disabled the linter alltogether in the .lintr config because it didn't have any true positives in my project.

  4. added a commit that references this issue on Oct 9, 2021
    4d7a3b1
  5. MichaelChirico commented on Oct 9, 2021

    @MichaelChirico
    Collaborator

    Should this be an option?

  6. AshesITR commented on Oct 9, 2021

    @AshesITR
    CollaboratorAuthor

    I'd be happy to make it optional. What should the default be? The old behaviour?

  7. MichaelChirico commented on Oct 9, 2021

    @MichaelChirico
    Collaborator

    I think the new behavior is a happier default -- often it's out of your control if you're defining a method for someone else's class.

    WDYT about a third option -- enforce the length on two parts (class name and generic name)? not sure it's worth the implementation & maintenance effort but it does make some sense

  8. AshesITR commented on Oct 9, 2021

    @AshesITR
    CollaboratorAuthor

    We could combine both by specifying two maximum lengths?

  9. added a commit that references this issue on Mar 21, 2022
    8340014
  10. added a commit that references this issue on Mar 21, 2022
    0b93897
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions