Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
40.07k stars 9.4k forks source link

Remove most global "monkey-patches" #17471

Open MikeMcQuaid opened 2 weeks ago

MikeMcQuaid commented 2 weeks ago

Verification

Provide a detailed description of the proposed feature

We should clean up extend/ to remove most monkey-patches (i.e. overriding/adding existing functionality) from core Ruby classes like e.g. String, Pathname, etc.

The exceptions should be:

For monkey-patches used in formulae and/or casks: we should instead have modules included in e.g. Formula/Cask or refinements on e.g. Pathname so that they can be used as custom DSLs when possible rather than globally overriding methods.

What is the motivation for the feature?

How will the feature be relevant to at least 90% of Homebrew users?

It won't be.

What alternatives to the feature have been considered?

Doing nothing.

apainintheneck commented 2 weeks ago

Good idea! IMO we should prefer modules over refinements but either is better than what we have now.

MikeMcQuaid commented 2 weeks ago

@apainintheneck Yeh, I'm not up-to-date with the best approach there but, in general, "monkeypatch instances rather than classes" feels like it's a better fit for us (and much easier than for other projects given how we load Formula/Casks).