bridgetown icon indicating copy to clipboard operation
bridgetown copied to clipboard

Kwargs conversion of many methods

Open neilvanbeinum opened this issue 3 years ago • 1 comments

Summary

Convert many methods and calls to use keyword arguments instead of hashes.

Methods which take a Configuration haven't been converted, such as Bridgetown::Site.new, or initializers of the Converter classes. I started to attempt this but then ran into difficulty, particularly with the converters. I think it's related to Configuration being a HashWithDotAccess::Hash. I didn't want to go too deep down the rabbit hole, especially as there's a comment suggesting the config may be refactored at some point.

Context

Supports resolving of #581

neilvanbeinum avatar Sep 19 '22 11:09 neilvanbeinum

Very cool @vvveebs, I appreciate your attention to detail! I should have time to review this after getting the first beta of v1.2 out the door.

jaredcwhite avatar Sep 23 '22 06:09 jaredcwhite

I've got into a tangle with failing ruby 3 tests. I'll promote this draft PR to ready to review if I can resolve these.

neilvanbeinum avatar Sep 24 '22 15:09 neilvanbeinum

I think we can punt on this and reevaluate for v1.3 or whatever…at this point I don't want to introduce any more major changes before the 1.2 release.

jaredcwhite avatar Nov 30 '22 20:11 jaredcwhite

Thanks @neilvanbeinum for working on this. I believe there are a number of places where we wouldn't want to make this change, particularly models and anything interfacing with Roda. I may want to back out of this for the time being and review such changes on a case-by-case basis.

jaredcwhite avatar Apr 12 '23 17:04 jaredcwhite

I agree with @jaredcwhite here.

I think keyword arguments is the way to go for new methods, but I wouldn't introduce them like this.

**options is mostly an anti-pattern. For internal APIs, one can convert from options to real keyword arguments when working on that specific code.

For public APIs, I'd do it full on, i.e. explicitly say which kwargs we are expecting for each method, and then treat it as a breaking change (since it's a public API).

sandstrom avatar Apr 19 '23 17:04 sandstrom