Page MenuHomePhabricator

[ES-M5] [TECH] Add linting/static code analysis rules for EntitySchema hook handlers' naming conventions
Closed, ResolvedPublic5 Estimated Story Points

Description

It's decided to use <Hookname>HookHandler as a template for new hook handler classes in EntitySchema. We should add related linting/static code analysis to ensure that we follow this convention in the future.

Acceptance Criteria

  • A rule exists that validates the correct class name template for hook handlers
  • EntitySchema hook handler class names are all updated to match the new rule

Event Timeline

Prio Notes:

  • Impact areas: Analyzability
  • Does not affect end users / production
  • Does not affect monitoring efforts
  • Affects development efforts
  • Affects onboarding efforts
  • Does not affect additional stakeholders
ItamarWMDE renamed this task from [TECH] Add linting/static code analysis rules for EntitySchema hook handlers' naming conventions to [ES-M5] [TECH] Add linting/static code analysis rules for EntitySchema hook handlers' naming conventions.Jul 18 2023, 1:23 PM
ItamarWMDE moved this task from Incoming to [DOT] Prioritized on the wmde-wikidata-tech board.
ItamarWMDE renamed this task from [ES-M5] [TECH] Add linting/static code analysis rules for EntitySchema hook handlers' naming conventions to [SW] [ES-M5] [TECH] Add linting/static code analysis rules for EntitySchema hook handlers' naming conventions.Jul 18 2023, 1:25 PM

Since we were wondering about how to implement this (what’s a hook handler class anyway? how do we know which other class names should be blocked?), I just had an idea (cc @Michael): we could implement this based on the extension.json specification, and assert that all the hook handlers listed in there end in HookHandler. (This could be, for example, part of EntitySchema’s GlobalStateFactoryMethodsResourceTest, rather than a PHPCS sniff.)

Story writing notes:

  • Add clearer acceptance criteria
  • Make clear that finding a solution is part of the task (and if there is none, that is also alright)

Since we were wondering about how to implement this (what’s a hook handler class anyway? how do we know which other class names should be blocked?), I just had an idea (cc @Michael): we could implement this based on the extension.json specification, and assert that all the hook handlers listed in there end in HookHandler. (This could be, for example, part of EntitySchema’s GlobalStateFactoryMethodsResourceTest, rather than a PHPCS sniff.)

Mh, that sounds like it could work. Though if we wanted to upsream it into ExtensionJsonTestBase then we might need to allow for defining some exceptions, because Wikibase has things like \\Wikibase\\Lib\\LibHooks in its classes there which probably should not be renamed.

ItamarWMDE renamed this task from [SW] [ES-M5] [TECH] Add linting/static code analysis rules for EntitySchema hook handlers' naming conventions to [ES-M5] [TECH] Add linting/static code analysis rules for EntitySchema hook handlers' naming conventions.Aug 29 2023, 1:08 PM
ItamarWMDE updated the task description. (Show Details)
karapayneWMDE set the point value for this task to 5.Sep 19 2023, 9:29 AM

Change #1100095 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/EntitySchema@master] Enforce HookHandler naming convention

https://gerrit.wikimedia.org/r/1100095

Change #1100095 merged by jenkins-bot:

[mediawiki/extensions/EntitySchema@master] Enforce HookHandler naming convention

https://gerrit.wikimedia.org/r/1100095