Skip to content

Dev Analyzer: "Anonymous Class" naming and visibility rules #1402

Description

@paulirwin

Is there an existing issue for this?

  • I have searched the existing issues

Task description

We should add dev analyzer rules to help contributors catch issues around classes that were anonymous classes in Java in our codebase.

  1. Per our project naming conventions, the type name should end in "AnonymousClass", optionally followed by one or more digits. i.e. ThreadAnonymousClass, ThreadAnonymousClass1, and ThreadAnonymousClass123 are all valid, but AnonymousClassThread and ThreadAnonymousClassForSomeTest are not valid.
  2. The type should be private and sealed (unless there is some good reason otherwise which could be suppressed).
  3. All fields on this type should be private.

These rules should fire if "AnonymousClass" appears anywhere in the type name.

(Another option, and could be broken out separately: we could also have a custom attribute that indicates that it maps to an anonymous class in Java. This would help us apply extra scrutiny in analysis to these types, and might even let us drop the conventional name suffix at a later time if we wanted.)

Related: #666, #715

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:taskA chore to be done

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions