Skip to content

Conversation

randallli
Copy link
Contributor

I copied the warnings/errors for our components for our examples and fixed some errors.

BOOL isEditing = self.editor.isEditing;
[self updatedRightBarButtonItem:!isEditing];
[self.editor setEditing:!isEditing animated:YES];
if ([sender isEqual:self.navigationItem.rightBarButtonItem]) {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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;

Copy link
Contributor

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{
Copy link
Contributor

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.

Copy link
Contributor Author

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]) {
Copy link
Contributor

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];
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

super-nit: If we are touching these lines, can we move _Nullable into the @Property annotation?
@Property(nonatomic, nullable) MDCTabBar *tabBar;

Copy link
Contributor Author

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) {
Copy link
Contributor

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]) {
Copy link
Contributor

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.

@jverkoey
Copy link
Contributor

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 __unused annotation.

@ajsecord
Copy link
Contributor

We're killing the Wunused-parameter warning (see internal discussion), so we can we drop this PR?

@ajsecord
Copy link
Contributor

#2448 is the PR to remove unused parameter warnings.

@randallli
Copy link
Contributor Author

I can drop the unused edits but there are others that we still want. Type casting and others.

@randallli randallli dismissed ianegordon’s stale review November 17, 2017 21:08

addressed all concernes

@randallli
Copy link
Contributor Author

randallli commented Nov 17, 2017

Note: #2456 changes the warnings that we have.

@randallli randallli dismissed jverkoey’s stale review November 17, 2017 21:10

no addressing __unused warnings in this PR

handler:^(MDCAlertAction *action) {
MDCAlertAction *okAction = [MDCAlertAction actionWithTitle:@"OK"
handler:^(MDCAlertAction *action) {
NSLog(@"%@", @"OK pressed");
Copy link
Contributor Author

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");
Copy link
Contributor Author

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];
Copy link
Contributor Author

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;
Copy link
Contributor Author

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{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@codecov-io
Copy link

codecov-io commented Nov 18, 2017

Codecov Report

Merging #2426 into develop will decrease coverage by 1.24%.
The diff coverage is n/a.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
components/Tabs/src/private/MDCItemBarCell.m 34.74% <0%> (-1.22%) ⬇️
components/NavigationBar/src/MDCNavigationBar.m 73.73% <0%> (-0.33%) ⬇️
...nents/ActivityIndicator/src/MDCActivityIndicator.m 17.61% <0%> (-0.18%) ⬇️
...te/Icons/icons/ic_info/src/MaterialIcons+ic_info.m 71.42% <0%> (ø) ⬆️
components/ButtonBar/src/MDCButtonBar.m 50.86% <0%> (ø) ⬆️
...xtFields/src/private/MDCTextInputCommonFundament.h 33.33% <0%> (ø) ⬆️
...xtFields/src/private/MDCTextInputCommonFundament.m 90.62% <0%> (ø) ⬆️
components/BottomAppBar/src/MDCBottomAppBarView.m 0% <0%> (ø) ⬆️
...te/ShapeLibrary/src/MDCSlantedRectShapeGenerator.m 0% <0%> (ø) ⬆️
...rivate/ShapeLibrary/src/MDCCurvedCornerTreatment.m 0% <0%> (ø) ⬆️
... and 73 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30c9fcb...e6dda25. Read the comment docs.

@randallli randallli requested a review from a team November 21, 2017 21:44
@randallli
Copy link
Contributor Author

PTAL

@randallli
Copy link
Contributor Author

I still need approval from someone.
ping @ianegordon @jverkoey who requested changes.

@ianegordon ianegordon merged commit 2f29f00 into material-components:develop Nov 22, 2017
yarneo pushed a commit to yarneo/material-components-ios that referenced this pull request Dec 1, 2017
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants