nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

[Bug]: functions with the signature toggle(isOn: Boolean) should be renamed

Open dturner opened this issue 3 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is there a StackOverflow question about this issue?

  • [X] I have searched StackOverflow

What happened?

We have several instances of functions with this signature:

fun toggleX(isOn: Boolean)

This is incorrect naming. You can either toggle something, in which case it flips its current state. Or you can set something to a new state.

These functions should be renamed to:

fun setX(isOn: Boolean)

Example: https://github.com/android/nowinandroid/blob/61c2377430e97df55be2d479cae838290f570015/core/data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt#L49

Relevant logcat output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

dturner avatar Oct 21 '22 15:10 dturner