You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Dis)allow default args in functions based on their access level.
Why?
I've often run into cases where a bug slips in because a parameter is not properly forwarded down to the layer that needs it because the compiler doesn't inform me that the argument is necessary for a particular function.
To combat this, I've made a rule of thumb for myself not to use default arguments on private or internal functions so that the compiler will force me to be explicit about how the functions should be parameterized.
This works well internal to a package because I think it's reasonable to expect the maintainers/developers to know enough about the internals of the package to know how to parameterize functions appropriately. Default arguments are very useful for consumers of the public API though.
Which access levels to trigger for (private, internalpackage)
Opt In?
Yes - opt-in. It doesn't feel like a hard and fast swift convention - rather something that I've personally been bitten by after years of Swift development.
Activity
[-]Rule Request: default_arg_access_level[/-][+]Rule Request: disallow_default_args[/+][-]Rule Request: disallow_default_args[/-][+]Rule Request: disallow_default_parameter[/+]