Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS: restore Generic.CodeAnalysis.UnusedFunctionParameter smell #2925

Open
justlevine opened this issue Sep 6, 2023 · 2 comments
Open
Assignees
Labels
Compat: Breaking Change This is a breaking change to existing functionality scope: code quality Affects codebase complexity and maintainability Status: Discussion Requires a discussion to proceed Type: Chore (updating CI tasks etc; no production code change)

Comments

@justlevine
Copy link
Collaborator

justlevine commented Sep 6, 2023

Per #2924 (comment)_ we should remove Generic.CodeAnalysis.UnusedFunctionParameter from our list of excluded PHPCS rules and any unused parameters from our method signatures.

Pros

  • improves readability (it's clear what parameters are actually necessary)
  • reduces code debt and future-compat ( lot easier to add a parameter than remove one that's not even in use).
  • (premature) performance optimization (since params don't always get garbage collected well).
  • brings us in line with the ecosystem coding standards.
  • (...suggest more in the comments)

Cons

  • Reduces self-documentation (since functions now show what is being passed to the method and no longer what can be passed, live code is no longer a "complete" example.
  • (...suggest more in the comments)
@justlevine justlevine self-assigned this Sep 7, 2023
@justlevine justlevine added Status: 🚀 Actionable Issues that have been curated, have enough info to take action, and are ready to be worked on Type: Chore (updating CI tasks etc; no production code change) scope: code quality Affects codebase complexity and maintainability labels Sep 7, 2023
@justlevine
Copy link
Collaborator Author

justlevine commented Sep 17, 2023

As of #2933 unused parameters inside a 'resolve' callback function have been removed.

Remaining smells in this sniff are for the most part limited to actual methods (either public or a protected method on an abstract class). These would be technically breaking to remove (even if IRL most of them are only intended to be used internally, e.g. BuiltInType::register_type( TypeRegistry $registry ) ).

A path forward would be to deprecate the unused parameters and remove them entirely in a future (breaking) release. This is the "proper" thing to do, but is a bit of an undertaking comes with significant code debt.

Alternatively, we could skip the deprecation step, and leave the smell silenced until it can be remediated in v2.0.

@jasonbahl thoughts?

image

@justlevine justlevine added Status: Discussion Requires a discussion to proceed Compat: Breaking Change This is a breaking change to existing functionality Status: Blocked Issue or pull request that can't be resolved at the moment and removed Status: 🚀 Actionable Issues that have been curated, have enough info to take action, and are ready to be worked on Status: Blocked Issue or pull request that can't be resolved at the moment labels Sep 17, 2023
@jasonbahl
Copy link
Collaborator

@justlevine I think silencing for now works.

I'm not opposed to the intermediate deprecation path and full removal in a breaking release later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat: Breaking Change This is a breaking change to existing functionality scope: code quality Affects codebase complexity and maintainability Status: Discussion Requires a discussion to proceed Type: Chore (updating CI tasks etc; no production code change)
Projects
Status: 💬 In Discussion
Development

No branches or pull requests

2 participants