-
Notifications
You must be signed in to change notification settings - Fork 950
Fixed some compiler warnings #2426
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
Conversation
This reverts commit 91f0480.
…creating a new one.
BOOL isEditing = self.editor.isEditing; | ||
[self updatedRightBarButtonItem:!isEditing]; | ||
[self.editor setEditing:!isEditing animated:YES]; | ||
if ([sender isEqual:self.navigationItem.rightBarButtonItem]) { |
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.
This seems strange to me. We are querying the sender, but it makes not difference in the body of the if clause. If another control were to use this action if would fail, which would be surprising.
If we don't care what the sender it, drop that parameter.
Here and below.
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.
Agreed that I'm not certain how important it is for us to be checking the sender in these methods. If the intent was simply to make use of the sender then I would encourage us to simply mark the sender as __unused
instead and keep the simpler logic we had before.
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.
ok im going to drop the sender.
For other cases that require the parameters I will be putting an NSLog statement to silence the warning.
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.
Nooooo. Mark the parameter as __unused.
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.
Why is NSLog
preferred over __unused
? Can't you at least do something less verbose, like:
(void)unusedVariable;
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.
We are intentionally trying to keep the examples 'simple'
Beginning engineers will likely know what NSLog() is. They are unlikely to be as familiar with __unused.
} | ||
|
||
- (IBAction)didTapShowAlert:(id)sender { | ||
- (IBAction)didTapShowAlert{ |
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.
super-nit: space after method name, here and below.
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.
vc.titleText = @"Shown views can be interactive"; | ||
vc.bodyText = @"The shown button has custom tap animations."; | ||
[self presentViewController:vc animated:YES completion:nil]; | ||
if ([sender isEqual:self.button]) { |
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.
Again, gating an action method on the sender, but not using the sender in the body of the method seems strange, and would make it harder to re-use this method in another control.
|
||
[self.navigationItem setLeftBarButtonItem:backItem animated:YES]; | ||
[self.navigationItem setRightBarButtonItem:doneItem animated:YES]; | ||
[navBar setItems:[NSArray arrayWithObject:self.navigationItem] animated:YES]; |
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.
Consider boxing the array init.
setItems @[self.navigationItem] animated:YES
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
@property MDCAppBar *_Nullable appBar; | ||
@property UIScrollView *_Nullable scrollView; | ||
@property UIView *_Nullable starPage; | ||
@property(nonatomic) MDCTabBar *_Nullable tabBar; |
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.
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.
view.transform = CGAffineTransformIdentity; | ||
} | ||
completion:nil]; | ||
if (finished) { |
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.
This is a change in behavior, and I'm not confident that it's a desirable one. Consider reverting and marking finished
as unused instead?
BOOL isEditing = self.editor.isEditing; | ||
[self updatedRightBarButtonItem:!isEditing]; | ||
[self.editor setEditing:!isEditing animated:YES]; | ||
if ([sender isEqual:self.navigationItem.rightBarButtonItem]) { |
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.
Agreed that I'm not certain how important it is for us to be checking the sender in these methods. If the intent was simply to make use of the sender then I would encourage us to simply mark the sender as __unused
instead and keep the simpler logic we had before.
It appears that many of the changes in this PR were initiated because of the unused arguments warning, sometimes subtly changing the behavior in ways that I think aren't desirable. It may be worth reconsidering whether each of the modifications would be better replaced with an |
We're killing the Wunused-parameter warning (see internal discussion), so we can we drop this PR? |
#2448 is the PR to remove unused parameter warnings. |
I can drop the unused edits but there are others that we still want. Type casting and others. |
Note: #2456 changes the warnings that we have. |
no addressing __unused warnings in this PR
handler:^(MDCAlertAction *action) { | ||
MDCAlertAction *okAction = [MDCAlertAction actionWithTitle:@"OK" | ||
handler:^(MDCAlertAction *action) { | ||
NSLog(@"%@", @"OK pressed"); |
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.
more spaces
handler:^(MDCAlertAction *action) { | ||
MDCAlertAction *okAction = [MDCAlertAction actionWithTitle:@"OK" | ||
handler:^(MDCAlertAction *action) { | ||
NSLog(@"%@", @"OK pressed"); |
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.
more spaces
|
||
[self.navigationItem setLeftBarButtonItem:backItem animated:YES]; | ||
[self.navigationItem setRightBarButtonItem:doneItem animated:YES]; | ||
[navBar setItems:[NSArray arrayWithObject:self.navigationItem] animated:YES]; |
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
@property MDCAppBar *_Nullable appBar; | ||
@property UIScrollView *_Nullable scrollView; | ||
@property UIView *_Nullable starPage; | ||
@property(nonatomic) MDCTabBar *_Nullable tabBar; |
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.
} | ||
|
||
- (IBAction)didTapShowAlert:(id)sender { | ||
- (IBAction)didTapShowAlert{ |
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.
Codecov Report
@@ Coverage Diff @@
## develop #2426 +/- ##
===========================================
- Coverage 45.02% 43.77% -1.25%
===========================================
Files 237 252 +15
Lines 23206 24039 +833
Branches 1999 2046 +47
===========================================
+ Hits 10448 10523 +75
- Misses 12748 13506 +758
Partials 10 10
Continue to review full report at Codecov.
|
PTAL |
I still need approval from someone. |
* Added warnings to examples. * fixed some warnings * using button sender parameter. * use button sender in example * use button sender in example * removed sender from methods that don’t use it. * removed sender from methods that don’t use it. * use button sender in example * use button sender in example * use button sender in example * use button sender in example * Fixed init of header configurator to use passed in parameter * removed unused API * use button sender in example * Revert "Added warnings to examples." This reverts commit 91f0480. * fixed example: Using the view controllers navigationItem rather than creating a new one. * removed finished checks from animation blocks in examples. * reverted id sender checks * revert id sender check for Flexible header UINavigationBar * revert clug * revert clug * addressing nits * removed sender check for FeatureHighlightTypicalUseView * more nits
I copied the warnings/errors for our components for our examples and fixed some errors.