-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Turned "unnecessary value" and "move of const" lints to errors on mac #36910
Conversation
510654c
to
814d8f9
Compare
Re: #36885 Here we can turn this on selectively as an error and I think we should keep the check in |
814d8f9
to
eab8459
Compare
eab8459
to
aad8d17
Compare
/// Adds warnings as errors for only specific runs. This is helpful if migrating one platform at a time. | ||
String? _platformSpecificWarningsAsErrors(String targetVariant) { | ||
if (targetVariant == 'host_debug' && io.Platform.isMacOS) { | ||
return 'performance-move-const-arg,performance-unnecessary-value-param'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do in fact need this, I'd prefer hoisting this logic out into the lint.sh
script to make it more visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I didn't do that is because it's really ugly doing the same logic in sh
. The thought being that having dart code is easier to get right and maintain instead of sh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could make another flag --mac-host-warnings-as-errors=foobar
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this PR, these lints are added, like, three layers deep (.clang-tidy
-> lint.sh
-> options.dart
), so I'm more concerned that people are going to get confused about how/why they're enabled than I am about adding logic to the shell script. --mac-host-warnings-as-errors
is kind of oddly specific, but at least makes the additional lints easier to find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is really buried. I think I should merge #36885 and then either
- Add these two lints back to the checks when all the platforms issues are resolved, as was done with the other linters.
or - Create override
.clang-tidy
files in the different embedder directories so we can add linter checks to different platforms without needing to fix them everywhere. I believeclang-tidy
will prefer the.clang-tidy
file closest to the file being linted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--mac-host-warnings-as-errors is kind of oddly specific, but at least makes the additional lints easier to find.
Yea it's weird. Once we get a solid foothold it should be easier to land the other platforms in another PR while this one holds the line for the most part. I'll make that change.
I think I should merge #36885 and then either
I just don't understand how that is helping anyone. The thesis for removing it was that it was confusing and it wasn't benefiting anyone. I've shown that it is doing what I expected and it is beneficial in limited cases (albeit not as many as I had hoped). I agree we need to make it better by turning it into an error on ci.
Add these two lints back to the checks when all the platforms issues are resolved, as was done with the other linters.
That needlessly makes the task hard for no reason. In order to do it all at once I need to run clang-tidy-fix 5 times on 3 different platforms, hand fix the automated fix since it isn't 100% perfect, get it all reviewed and landed all within the span of no one introducing another violation. Otherwise have to start the process all over again.
Having multiple .clang-tidy
files also has it's own problems where managing multiple files is a pain and the hope is that this is a special case and a transitory one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, moved the warnings-as-errors declaration to lint.sh
. Leaving the thread unresolved since there was some other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just don't understand how that is helping anyone.
It helps because the expected behavior that adding a check to the .clang-tidy file will surface regressions to that lint... somewhere. Without needing to set up an IDE with clang-tidy, if anyone does this, and without needing to know to run --fix
. If we don't merge #36885 then also need to move modernize-use-default-member-init
to WarningsAsErrors
as that's a pretty clear example of the confusion. Generally when we add new lints, errors or warnings, in other linter systems, it also involves fixing the existing violations of that lint. I know these two lints aren't totally cleaned up though on all platforms, and that's the issue here.
However we obviously disagree here, so I hope people notice the behavior of --mac-host-warnings-as-errors
and any similar platform-specific lints going forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm w/ issue to track cleanup.
@@ -32,6 +32,7 @@ SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)" | |||
FLUTTER_DIR="$(cd "$SCRIPT_DIR/.."; pwd -P)" | |||
DART_BIN="${SRC_DIR}/third_party/dart/tools/sdks/dart-sdk/bin" | |||
DART="${DART_BIN}/dart" | |||
MAC_HOST_WARNINGS_AS_ERRORS="performance-move-const-arg,performance-unnecessary-value-param" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a TODO and file an issue to clean this up when done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaaclarke These migrations are difficult, so it makes sense to me that we're having this discussion. Another way to slice up the work, rather than platform-by-platform, is to use the |
@zanderso that makes sense. What we've done in the past with the formatter is print out the patch that will fix the issue so you don't have to recalculate it on your own machine. I think that's what we should do since here too since it's unreasonable to make people run N instances of clang tidy on 3 different machines to duplicate work that's being done on a bot already. |
That will not work in conjunction with this PR, as @gaaclarke pointed out in #36885 (review). Either all warnings are errors, or we prefer this pattern where only checks in |
Or you meant land that PR after these two lint can be turned on for all platforms? |
Yes. |
Fixed up some new violations to the "move const values" lint and the "unnecessary value" lint and made it an error on CI for host_debug on mac.
If this fails in Post submit checks let me know, it's possible a violation was introduced between authoring and landing the check
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.