Skip to content

Commit

Permalink
[ios]fix unused variable clang tidy warning (#56637)
Browse files Browse the repository at this point in the history
Spot another clang-tidy linter failure from: #56631

In release mode, if we remove NSAssert, then weakFlutterEngine is not used at all. This should have been an XCTAssert rather than NSAssert in the first place. 

```
� Failures for clang-tidy on /Volumes/Work/s/w/ir/cache/builder/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm:
/Volumes/Work/s/w/ir/cache/builder/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm:239:5: error: Value stored to 'weakFlutterEngine' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
  239 |     weakFlutterEngine = flutterEngine;
      |     ^                   ~~~~~~~~~~~~~
/Volumes/Work/s/w/ir/cache/builder/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm:239:5: note: Value stored to 'weakFlutterEngine' is never read
  239 |     weakFlutterEngine = flutterEngine;
      |     ^                   ~~~~~~~~~~~~~
Suppressed 9240 warnings (9111 in non-user code, 129 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```

*List which issues are fixed by this PR. You must list at least one issue.*
flutter/flutter#157837

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
hellohuanlin authored Nov 16, 2024
1 parent ca683bb commit 9080611
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ - (void)testNoDanglingEnginePointer {
@autoreleasepool {
FlutterEngine* flutterEngine = OCMClassMock([FlutterEngine class]);
weakFlutterEngine = flutterEngine;
NSAssert(weakFlutterEngine, @"flutter engine must not be nil");
XCTAssertNotNil(weakFlutterEngine, @"flutter engine must not be nil");
FlutterTextInputPlugin* flutterTextInputPlugin = [[FlutterTextInputPlugin alloc]
initWithDelegate:(id<FlutterTextInputDelegate>)flutterEngine];
weakFlutterTextInputPlugin = flutterTextInputPlugin;
Expand All @@ -254,8 +254,8 @@ - (void)testNoDanglingEnginePointer {
currentView = flutterTextInputPlugin.activeView;
}

NSAssert(!weakFlutterEngine, @"flutter engine must be nil");
NSAssert(currentView, @"current view must not be nil");
XCTAssertNil(weakFlutterEngine, @"flutter engine must be nil");
XCTAssertNotNil(currentView, @"current view must not be nil");

XCTAssertNil(weakFlutterTextInputPlugin);
// Verify that the view can no longer access the deallocated engine/text input plugin
Expand Down

0 comments on commit 9080611

Please sign in to comment.