Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Enforce asterisk alignment for C++ and ObjC pointers #4703

Merged
merged 4 commits into from
Jan 26, 2022

Conversation

stuartmorgan-g
Copy link
Contributor

So far we've been using the default mode of prevailing-in-file, which
means we aren't consistent within each language what mode we use. Now
that clang-format can identify ObjC headers (which didn't used to be the
case), we can enforce different styles for the two languages.

This sets left-aligned for C++ to match the Flutter engine, and
right-aligned for ObjC to match the prevaling Apple style.

No version change: automated whitespace-only change with no actual effect on clients.

No CHANGELOG change: uninteresting mechanical change.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

So far we've been using the default mode of prevailing-in-file, which
means we aren't consistent within each language what mode we use. Now
that clang-format can identify ObjC headers (which didn't used to be the
case), we can enforce different styles for the two languages.

This sets left-aligned for C++ to match the Flutter engine, and
right-aligned for ObjC to match the prevaling Apple style.
@stuartmorgan-g
Copy link
Contributor Author

stuartmorgan-g commented Jan 26, 2022

@jmagman A lot more ObjC code here was using left-aligned than I expected. I assumed we'd want to follow Apple's usual style, but we could also use left-aligned for everything (or as I like to think of it "correct" 😁 ); I leave it entirely up to you.

@gaaclarke
Copy link
Member

FWIW the google style guides for objc and c++ are agnostic to the placement of the asterisks.

@stuartmorgan-g
Copy link
Contributor Author

FWIW the google style guides for objc and c++ are agnostic to the placement of the asterisks.

Google style is agnostic, but I've never been on a team that doesn't have a team-level convention for this in order to have local consistency.

@gaaclarke gaaclarke changed the title Enfore pointer alignment for C++ and ObjC Enforce asterisk alignment for C++ and ObjC pointers Jan 26, 2022
@gaaclarke
Copy link
Member

sgtm, whatever you all want to do. I renamed the PR since it sounded very scary, potentially having to do with memory alignment instead of code formatting =)

@stuartmorgan-g
Copy link
Contributor Author

🤷🏻 "pointer alignment" is the name of the clang-format setting.

@gaaclarke
Copy link
Member

In the context of formatting code "pointer alignment" makes sense in the context of making changes to a codebase it is ambiguous and scary. I imaging someone investigating a mysterious crash and that PR title jumping out at them.

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

@jmagman A lot more ObjC code here was using left-aligned than I expected. I assumed we'd want to follow Apple's usual style, but we could also use left-aligned for everything (or as I like to think of it "correct" 😁 ); I leave it entirely up to you.

Let's keep right-alignment to match the Apple style. As long as it's consistent, and better if a formatter can fix it for me, I can live with either.

LGTM

@stuartmorgan-g stuartmorgan-g added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants