Skip to content

Ensure ggproto methods start with { #6460

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 8 commits into from
May 27, 2025

Conversation

yjunechoe
Copy link
Contributor

As discussed in #6459, this PR changes instances of function() ... into function() { ... } for ggproto methods.

There was one not-so-trivial case of ScaleDiscrete$transform:

ggplot2/R/scale-.R

Lines 981 to 983 in 86b32ce

transform = identity,

Because base::identity() is a one-liner without {, this fails the test:

identity
#> function (x) 
#> x
#> <bytecode: 0x000001b6a4393740>
#> <environment: namespace:base>

In this PR, ScaleDiscrete$transform is now the spelled-out version:

  transform = function(self, x) {
    x
  },

@teunbrand teunbrand linked an issue May 15, 2025 that may be closed by this pull request
teunbrand added 4 commits May 27, 2025 09:16
Merge branch 'main' into yjunechoe-curly-braces-ggproto-methods

# Conflicts:
#	R/coord-.R
#	R/coord-cartesian-.R
#	R/coord-transform.R
#	R/facet-.R
#	R/geom-.R
#	R/stat-unique.R
@teunbrand
Copy link
Collaborator

Sorry for assuming a little bit of control over the PR, but some gnarly merge conflicts had emerged that were my fault. I also tweaked the test a little bit so that now it'll report which ggprotos and which method is failing.

Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

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

Yeah I think this is harmless enough to be included in this stage. Thanks for the contribution June!

@teunbrand teunbrand merged commit 7798431 into tidyverse:main May 27, 2025
13 checks passed
@yjunechoe yjunechoe deleted the curly-braces-ggproto-methods branch May 27, 2025 16:50
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.

Chore: standardize one-liner ggproto methods to use {
2 participants