Skip to content

format: add checks for type aliases#12099

Closed
tomocy wants to merge 1 commit intoenvoyproxy:masterfrom
tomocy:format-add-check-tool-for-type-alias
Closed

format: add checks for type aliases#12099
tomocy wants to merge 1 commit intoenvoyproxy:masterfrom
tomocy:format-add-check-tool-for-type-alias

Conversation

@tomocy
Copy link
Contributor

@tomocy tomocy commented Jul 15, 2020

Signed-off-by: tomocy tomocy.dev@gmail.com

Commit Message: format: add checks for type aliases
Additional Description: N/A
Risk Level: Low
Testing: N/A
Docs Changes: N/A
Release Notes: N/A

Part of #11634

Signed-off-by: tomocy <tomocy.dev@gmail.com>
}

USING_TYPE_ALIAS_REGEX = re.compile("(using .* = .*;|typedef .* .*;)")
SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)")
Copy link
Member

@Shikugawa Shikugawa Jul 16, 2020

Choose a reason for hiding this comment

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

Should we introduce type alias for weak_ptr? This kind of smart pointer is partly used in envoyproxy/envoy and envoy/envoy-wasm. WDYT? cc. @jmarantz

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, but I'd recommend not expanding the scope of this series of PRs. Would be an easier follow-up, as there are relatively fewer weak_ptr uses I think.

Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

I have a high level question about the enforcement of this. It is very nice to use SharedPtr and ScopedPtr abbreviations. However, there is at least one scenario where spelling out the template is much better, even if a nickname exists, which is when the usage is templated.

I'm actually working on such a scenario now in https://github.com/envoyproxy/envoy/pull/12128/files though it uses RefcountPtr<T> rather than shared_ptr<T>.

There's also existing templatized code in

StatType& ThreadLocalStoreImpl::ScopeImpl::safeMakeStat(
which -- if this guideline was enforced with a format check, would need a ton of exceptions.

help="specify the header block include directory order.")
parser.add_argument("--aggressive",
action='store_true',
help="specify if it fixes formats making risky changes.")
Copy link
Contributor

Choose a reason for hiding this comment

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

help="makes risky format changes; re-testing needed after making aggressive fixes"

@jmarantz
Copy link
Contributor

Please see @snowp's comment in slack: https://envoyproxy.slack.com/archives/C78HA81DH/p1594908964168900

I'm not sure that deep-link works properly but it's in #envoy-dev and @snowp wrote it on July 16th, and it starts with "just a thought i had: would it make sense to be using templated "

@jmarantz
Copy link
Contributor

/wait

@stale
Copy link

stale bot commented Jul 25, 2020

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jul 25, 2020
@stale
Copy link

stale bot commented Aug 1, 2020

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale stalebot believes this issue/PR has not been touched recently waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants