Skip to content

Improve consistency of naming internal functions #6072

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

Merged
merged 18 commits into from
Jan 27, 2025

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Sep 3, 2024

This PR aims to fix #6024.

Briefly, it enforces some consistency on the various check_*() and validate_*() functions in ggplot2's unexported functions.

Check functions:

  • Check input verbatim
  • Their purpose is to throw conditions when input is unexpected
  • Return nothing (that is, invisible(NULL))

Validator functions:

  • Can take different variants of input
  • Their purpose is to converge output from input
  • Return a single type of output

In addition, a smaller category are functions that take possibly deprecated values and restore it to valid values. I've named these update_*() functions here, but that might be confusing and perhaps we could choose a better name.

@thomasp85
Copy link
Member

An alternative name to update_*() would be fix_*() since it implies something is wrong and that this function will do something about it and return a usable version?

Merge branch 'main' into internal_naming

# Conflicts:
#	R/geom-crossbar.R
#	R/geom-errorbarh.R
#	R/scale-colour.R
#	R/scale-hue.R
#	R/utilities-checks.R
#	tests/testthat/_snaps/facet-.md
#	tests/testthat/test-ggsave.R
@teunbrand
Copy link
Collaborator Author

I like it, good call

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit 9eeeafe into tidyverse:main Jan 27, 2025
13 checks passed
@teunbrand teunbrand deleted the internal_naming branch January 27, 2025 11:24
teunbrand added a commit to teunbrand/ggplot2 that referenced this pull request Jan 27, 2025
teunbrand added a commit that referenced this pull request Jan 27, 2025
* bump NA to back of key

* add test

* add news bullet

* Fix interaction between #5912 and #6072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Naming of internal helper functions
2 participants