Skip to content

Commit c0be4f1

Browse files
authored
[CQ] suppress ignored results (#8142)
These unused results can be safely ignored. (The latch case took some thinking through so I added a comment.) ![image](https://github.com/user-attachments/assets/e4c9d047-59a6-44c9-a47a-b9991e19113a) --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](#8098)). </details>
1 parent e26ffb3 commit c0be4f1

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

flutter-idea/src/io/flutter/logging/DiagnosticsNode.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
import org.jetbrains.annotations.Nullable;
2020

2121
import javax.swing.*;
22-
import java.util.*;
22+
import java.util.ArrayList;
23+
import java.util.Map;
24+
import java.util.Objects;
25+
import java.util.Set;
2326
import java.util.concurrent.CompletableFuture;
2427

2528
/**
@@ -488,7 +491,7 @@ private boolean getBooleanMember(String memberName, boolean defaultValue) {
488491
return value.getAsBoolean();
489492
}
490493

491-
private DiagnosticLevel getLevelMember(String memberName, DiagnosticLevel defaultValue) {
494+
private DiagnosticLevel getLevelMember(String memberName, @NotNull DiagnosticLevel defaultValue) {
492495
if (!json.has(memberName)) {
493496
return defaultValue;
494497
}

flutter-idea/src/io/flutter/logging/FlutterConsoleLogManager.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545

4646
import java.util.ArrayList;
4747
import java.util.Collections;
48-
import java.util.concurrent.*;
48+
import java.util.concurrent.CompletableFuture;
49+
import java.util.concurrent.CountDownLatch;
50+
import java.util.concurrent.Executors;
51+
import java.util.concurrent.TimeUnit;
4952
import java.util.concurrent.atomic.AtomicInteger;
5053

5154
/**
@@ -516,8 +519,8 @@ private String formatTruncatedString(InstanceRef ref) {
516519
return ref.getValueAsString() + "...";
517520
}
518521

519-
private String getFullStringValue(@NotNull VmService service, String isolateId, @Nullable InstanceRef ref) {
520-
if (ref == null) return null;
522+
private @Nullable String getFullStringValue(@NotNull VmService service, @Nullable String isolateId, @Nullable InstanceRef ref) {
523+
if (ref == null || isolateId == null) return null;
521524

522525
if (!ref.getValueAsStringIsTruncated()) {
523526
return ref.getValueAsString();
@@ -553,10 +556,12 @@ public void received(Sentinel response) {
553556
});
554557

555558
try {
559+
// The return can be safely ignored. An unset result will just return 0.
560+
//noinspection ResultOfMethodCallIgnored
556561
latch.await(1, TimeUnit.SECONDS);
557562
}
558563
catch (InterruptedException e) {
559-
return null;
564+
// Fall through to returning an empty result.
560565
}
561566

562567
return result[0];

flutter-idea/testSrc/unit/io/flutter/view/FlutterViewTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.intellij.openapi.project.Project;
1111
import com.intellij.openapi.wm.ToolWindow;
1212
import com.intellij.ui.content.ContentFactory;
13+
import com.intellij.ui.content.ContentManager;
1314
import io.flutter.ObservatoryConnector;
1415
import io.flutter.devtools.DevToolsIdeFeature;
1516
import io.flutter.jxbrowser.FailureType;
@@ -22,8 +23,10 @@
2223
import org.junit.Before;
2324
import org.junit.Ignore;
2425
import org.junit.Test;
25-
import org.mockito.*;
26-
import com.intellij.ui.content.ContentManager;
26+
import org.mockito.Mock;
27+
import org.mockito.MockedStatic;
28+
import org.mockito.Mockito;
29+
import org.mockito.MockitoAnnotations;
2730

2831
import java.util.concurrent.TimeoutException;
2932

@@ -53,6 +56,7 @@ public void setUp() throws Exception {
5356

5457
// Static mocking for ApplicationManager.
5558
mockedStaticApplicationManager = Mockito.mockStatic(ApplicationManager.class);
59+
//noinspection ResultOfMethodCallIgnored
5660
mockedStaticApplicationManager.when(ApplicationManager::getApplication).thenReturn(mockApplication);
5761
doAnswer(invocation -> {
5862
Runnable runnable = invocation.getArgument(0);
@@ -167,7 +171,8 @@ public void testWaitForJxBrowserInstallationWithoutTimeout() throws TimeoutExcep
167171

168172
spy.waitForJxBrowserInstallation(mockApp, mockToolWindow, DevToolsIdeFeature.TOOL_WINDOW);
169173
verify(spy, times(1))
170-
.handleUpdatedJxBrowserStatusOnEventThread(mockApp, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED, DevToolsIdeFeature.TOOL_WINDOW);
174+
.handleUpdatedJxBrowserStatusOnEventThread(mockApp, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED,
175+
DevToolsIdeFeature.TOOL_WINDOW);
171176
}
172177

173178
@Ignore
@@ -193,7 +198,8 @@ public void testHandleUpdatedJxBrowserStatusWithFailure() {
193198
final FlutterView partialMockFlutterView = mock(FlutterView.class);
194199
doCallRealMethod().when(partialMockFlutterView)
195200
.handleUpdatedJxBrowserStatus(mockApp, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED, DevToolsIdeFeature.TOOL_WINDOW);
196-
partialMockFlutterView.handleUpdatedJxBrowserStatus(mockApp, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED, DevToolsIdeFeature.TOOL_WINDOW);
201+
partialMockFlutterView.handleUpdatedJxBrowserStatus(mockApp, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED,
202+
DevToolsIdeFeature.TOOL_WINDOW);
197203
verify(partialMockFlutterView, times(1)).handleJxBrowserInstallationFailed(mockApp, mockToolWindow, DevToolsIdeFeature.TOOL_WINDOW);
198204
}
199205

@@ -213,7 +219,8 @@ public void testHandleUpdatedJxBrowserStatusWithOtherstatus() {
213219
final FlutterView partialMockFlutterView = mock(FlutterView.class);
214220
doCallRealMethod().when(partialMockFlutterView)
215221
.handleUpdatedJxBrowserStatus(mockApp, mockToolWindow, JxBrowserStatus.NOT_INSTALLED, DevToolsIdeFeature.TOOL_WINDOW);
216-
partialMockFlutterView.handleUpdatedJxBrowserStatus(mockApp, mockToolWindow, JxBrowserStatus.NOT_INSTALLED, DevToolsIdeFeature.TOOL_WINDOW);
222+
partialMockFlutterView.handleUpdatedJxBrowserStatus(mockApp, mockToolWindow, JxBrowserStatus.NOT_INSTALLED,
223+
DevToolsIdeFeature.TOOL_WINDOW);
217224
verify(partialMockFlutterView, times(1))
218225
.presentOpenDevToolsOptionWithMessage(mockApp, mockToolWindow, INSTALLATION_WAIT_FAILED, DevToolsIdeFeature.TOOL_WINDOW);
219226
}

0 commit comments

Comments
 (0)