Skip to content

Commit 632e1cd

Browse files
authored
[CQ] cleanup dead/redundant code (#8367)
Some opportunistic cleanup. Removing: * redundant semi-colons * redundant suppressions * an unused Import Fixed static member via instance accesses Fixed an unchecked call to `put(K, V)` --- - [ ] 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 1b2fa45 commit 632e1cd

File tree

9 files changed

+73
-52
lines changed

9 files changed

+73
-52
lines changed

src/io/flutter/FlutterProjectActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ abstract class FlutterProjectActivity : ProjectActivity {
2525
}
2626

2727
protected fun log(): Logger {
28-
return log;
28+
return log
2929
}
3030
}

src/io/flutter/actions/AttachDebuggerAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ private static class SelectConfigDialog extends DialogWrapper {
226226
//noinspection DataFlowIssue
227227
myPanel.add(myTextPane);
228228
init();
229-
//noinspection ConstantConditions
230229
getButton(getCancelAction()).setVisible(false);
231230
}
232231

src/io/flutter/android/AndroidEmulator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public int hashCode() {
140140
// This is: EmulatorSettings.getInstance().getLaunchInToolWindow();
141141
// Beginning in 2022.2, Android Studio moved this class to a different package.
142142
// IntelliJ did not adopt that change, and we cannot build separate plugins for the two.
143-
@SuppressWarnings("ConstantConditions")
144143
private boolean getLaunchInToolWindow() {
145144
Class<?> aClass;
146145
try {

src/io/flutter/jxbrowser/JxBrowserManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.flutter.jxbrowser;
77

88
import com.google.common.annotations.VisibleForTesting;
9-
import com.intellij.openapi.application.ApplicationInfo;
109
import com.intellij.openapi.application.PathManager;
1110
import com.intellij.openapi.diagnostic.Logger;
1211
import com.intellij.openapi.progress.ProgressIndicator;

src/io/flutter/run/bazelTest/BazelTestLaunchState.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
/**
3434
* The Bazel version of the {@link io.flutter.run.test.TestLaunchState}.
3535
*/
36-
@SuppressWarnings("JavadocReference")
3736
public class BazelTestLaunchState extends CommandLineState {
3837
@NotNull
3938
private final BazelTestConfig config;

src/io/flutter/test/DartTestEventsConverterZ.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public class DartTestEventsConverterZ extends OutputToGeneralTestEventsConverter
9090
private String myLocation;
9191
private Key myCurrentOutputType;
9292
private ServiceMessageVisitor myCurrentVisitor;
93-
private final HashMap myTestIdToTimestamp;
93+
private final HashMap<Integer, Long> myTestIdToTimestamp;
9494
private final Map<Integer, Test> myTestData;
9595
private final Map<Integer, Group> myGroupData;
9696
private final Map<Integer, Suite> mySuiteData;

src/io/flutter/utils/GradleUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ private static GradleSettingsFile parseSettings(Project project) {
211211
}
212212
}
213213

214-
@SuppressWarnings("rawtypes")
215214
private static BuildModelContext makeBuildModelContext(Project project) {
216215
return BuildModelContext.create(project, new AndroidLocationProvider());
217216
}

src/io/flutter/vmService/frame/DartVmServiceValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
public class DartVmServiceValue extends XNamedValue {
3333
private static final LayeredIcon FINAL_FIELD_ICON =
34-
new LayeredIcon().layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, AllIcons.Nodes.FinalMark});
34+
LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, AllIcons.Nodes.FinalMark});
3535
private static final LayeredIcon STATIC_FIELD_ICON =
36-
new LayeredIcon().layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, AllIcons.Nodes.StaticMark});
36+
LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, AllIcons.Nodes.StaticMark});
3737
private static final LayeredIcon STATIC_FINAL_FIELD_ICON =
38-
new LayeredIcon().layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, AllIcons.Nodes.StaticMark, AllIcons.Nodes.FinalMark});
38+
LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, AllIcons.Nodes.StaticMark, AllIcons.Nodes.FinalMark});
3939
private static final String JSON_STRING_TEMPLATE =
4040
"'{'\"type\":\"@Instance\",\"class\":'{'\"type\":\"@Class\",\"fixedId\":\"true\",\"id\":\"classes/91\"," +
4141
"\"name\":\"_OneByteString\"'}',\"kind\":\"String\",\"length\":\"{0}\",\"valueAsString\":\"{1}\"'}'";

third_party/vmServiceDrivers/org/dartlang/vm/service/VmServiceBase.java

Lines changed: 68 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public static VmService connect(final String url) throws IOException {
5353
URI uri;
5454
try {
5555
uri = new URI(url);
56-
} catch (URISyntaxException e) {
56+
}
57+
catch (URISyntaxException e) {
5758
throw new IOException("Invalid URL: " + url, e);
5859
}
5960
String wsScheme = uri.getScheme();
@@ -65,7 +66,8 @@ public static VmService connect(final String url) throws IOException {
6566
WebSocket webSocket;
6667
try {
6768
webSocket = new WebSocket(uri);
68-
} catch (WebSocketException e) {
69+
}
70+
catch (WebSocketException e) {
6971
throw new IOException("Failed to create websocket: " + url, e);
7072
}
7173
final VmService vmService = new VmService();
@@ -84,7 +86,8 @@ public void onMessage(WebSocketMessage message) {
8486
Logging.getLogger().logInformation("VM message: " + message.getText());
8587
try {
8688
vmService.processMessage(message.getText());
87-
} catch (Exception e) {
89+
}
90+
catch (Exception e) {
8891
Logging.getLogger().logError(e.getMessage(), e);
8992
}
9093
}
@@ -106,12 +109,13 @@ public void onPong() {
106109
});
107110

108111
// Establish WebSocket Connection
109-
//noinspection TryWithIdenticalCatches
110112
try {
111113
webSocket.connect();
112-
} catch (WebSocketException e) {
114+
}
115+
catch (WebSocketException e) {
113116
throw new IOException("Failed to connect: " + url, e);
114-
} catch (ArrayIndexOutOfBoundsException e) {
117+
}
118+
catch (ArrayIndexOutOfBoundsException e) {
115119
// The weberknecht can occasionally throw an array index exception if a connect terminates on initial connect
116120
// (de.roderick.weberknecht.WebSocket.connect, WebSocket.java:126).
117121
throw new IOException("Failed to connect: " + url, e);
@@ -125,7 +129,7 @@ public void onPong() {
125129
@Override
126130
public void onError(RPCError error) {
127131
String msg = "Failed to determine protocol version: " + error.getCode() + "\n message: "
128-
+ error.getMessage() + "\n details: " + error.getDetails();
132+
+ error.getMessage() + "\n details: " + error.getDetails();
129133
Logging.getLogger().logInformation(msg);
130134
errMsg[0] = msg;
131135
}
@@ -145,7 +149,8 @@ public void received(Version version) {
145149
if (errMsg[0] != null) {
146150
throw new IOException(errMsg[0]);
147151
}
148-
} catch (InterruptedException e) {
152+
}
153+
catch (InterruptedException e) {
149154
throw new RuntimeException("Interrupted while waiting for response", e);
150155
}
151156

@@ -156,7 +161,6 @@ public void received(Version version) {
156161
* Connect to the VM observatory service on the given local port.
157162
*
158163
* @return an API object for interacting with the VM service (not {@code null}).
159-
*
160164
* @deprecated prefer the Url based constructor {@link VmServiceBase#connect}
161165
*/
162166
@Deprecated
@@ -253,8 +257,9 @@ public void onError(RPCError error) {
253257
@Override
254258
public void received(Obj response) {
255259
if (response instanceof Instance) {
256-
consumer.received((Instance) response);
257-
} else {
260+
consumer.received((Instance)response);
261+
}
262+
else {
258263
onError(RPCError.unexpected("Instance", response));
259264
}
260265
}
@@ -280,8 +285,9 @@ public void onError(RPCError error) {
280285
@Override
281286
public void received(Obj response) {
282287
if (response instanceof Library) {
283-
consumer.received((Library) response);
284-
} else {
288+
consumer.received((Library)response);
289+
}
290+
else {
285291
onError(RPCError.unexpected("Library", response));
286292
}
287293
}
@@ -343,7 +349,8 @@ public void connectionOpened() {
343349
for (VmServiceListener listener : new ArrayList<>(vmListeners)) {
344350
try {
345351
listener.connectionOpened();
346-
} catch (Exception e) {
352+
}
353+
catch (Exception e) {
347354
Logging.getLogger().logError("Exception notifying listener", e);
348355
}
349356
}
@@ -353,7 +360,8 @@ private void forwardEvent(String streamId, Event event) {
353360
for (VmServiceListener listener : new ArrayList<>(vmListeners)) {
354361
try {
355362
listener.received(streamId, event);
356-
} catch (Exception e) {
363+
}
364+
catch (Exception e) {
357365
Logging.getLogger().logError("Exception processing event: " + streamId + ", " + event.getJson(), e);
358366
}
359367
}
@@ -363,7 +371,8 @@ public void connectionClosed() {
363371
for (VmServiceListener listener : new ArrayList<>(vmListeners)) {
364372
try {
365373
listener.connectionClosed();
366-
} catch (Exception e) {
374+
}
375+
catch (Exception e) {
367376
Logging.getLogger().logError("Exception notifying listener", e);
368377
}
369378
}
@@ -394,8 +403,9 @@ void processMessage(String jsonText) {
394403
// Decode the JSON
395404
JsonObject json;
396405
try {
397-
json = (JsonObject) JsonParser.parseString(jsonText);
398-
} catch (Exception e) {
406+
json = (JsonObject)JsonParser.parseString(jsonText);
407+
}
408+
catch (Exception e) {
399409
Logging.getLogger().logError("Parse message failed: " + jsonText, e);
400410
return;
401411
}
@@ -415,12 +425,15 @@ void processMessage(String jsonText) {
415425
}
416426
if (json.has("id")) {
417427
processRequest(json);
418-
} else {
428+
}
429+
else {
419430
processNotification(json);
420431
}
421-
} else if (json.has("result") || json.has("error")) {
432+
}
433+
else if (json.has("result") || json.has("error")) {
422434
processResponse(json);
423-
} else {
435+
}
436+
else {
424437
Logging.getLogger().logError("Malformed message");
425438
}
426439
}
@@ -433,7 +446,8 @@ void processRequest(JsonObject json) {
433446
String id;
434447
try {
435448
id = json.get(ID).getAsString();
436-
} catch (Exception e) {
449+
}
450+
catch (Exception e) {
437451
final String message = "Request malformed " + ID;
438452
Logging.getLogger().logError(message, e);
439453
final JsonObject error = new JsonObject();
@@ -449,7 +463,8 @@ void processRequest(JsonObject json) {
449463
String method;
450464
try {
451465
method = json.get(METHOD).getAsString();
452-
} catch (Exception e) {
466+
}
467+
catch (Exception e) {
453468
final String message = "Request malformed " + METHOD;
454469
Logging.getLogger().logError(message, e);
455470
final JsonObject error = new JsonObject();
@@ -463,7 +478,8 @@ void processRequest(JsonObject json) {
463478
JsonObject params;
464479
try {
465480
params = json.get(PARAMS).getAsJsonObject();
466-
} catch (Exception e) {
481+
}
482+
catch (Exception e) {
467483
final String message = "Request malformed " + METHOD;
468484
Logging.getLogger().logError(message, e);
469485
final JsonObject error = new JsonObject();
@@ -504,7 +520,8 @@ public void error(int code, String message, JsonObject data) {
504520
requestSink.add(response);
505521
}
506522
});
507-
} catch (Exception e) {
523+
}
524+
catch (Exception e) {
508525
final String message = "Internal Server Error";
509526
Logging.getLogger().logError(message, e);
510527
final JsonObject error = new JsonObject();
@@ -516,48 +533,53 @@ public void error(int code, String message, JsonObject data) {
516533
}
517534

518535
private static final RemoteServiceCompleter ignoreCallback =
519-
new RemoteServiceCompleter() {
520-
public void result(JsonObject result) {
521-
// ignore
522-
}
536+
new RemoteServiceCompleter() {
537+
public void result(JsonObject result) {
538+
// ignore
539+
}
523540

524-
public void error(int code, String message, JsonObject data) {
525-
// ignore
526-
}
527-
};
541+
public void error(int code, String message, JsonObject data) {
542+
// ignore
543+
}
544+
};
528545

529546
void processNotification(JsonObject json) {
530547
String method;
531548
try {
532549
method = json.get(METHOD).getAsString();
533-
} catch (Exception e) {
550+
}
551+
catch (Exception e) {
534552
Logging.getLogger().logError("Request malformed " + METHOD, e);
535553
return;
536554
}
537555
JsonObject params;
538556
try {
539557
params = json.get(PARAMS).getAsJsonObject();
540-
} catch (Exception e) {
558+
}
559+
catch (Exception e) {
541560
Logging.getLogger().logError("Event missing " + PARAMS, e);
542561
return;
543562
}
544563
if ("streamNotify".equals(method)) {
545564
String streamId;
546565
try {
547566
streamId = params.get(STREAM_ID).getAsString();
548-
} catch (Exception e) {
567+
}
568+
catch (Exception e) {
549569
Logging.getLogger().logError("Event missing " + STREAM_ID, e);
550570
return;
551571
}
552572
Event event;
553573
try {
554574
event = new Event(params.get(EVENT).getAsJsonObject());
555-
} catch (Exception e) {
575+
}
576+
catch (Exception e) {
556577
Logging.getLogger().logError("Event missing " + EVENT, e);
557578
return;
558579
}
559580
forwardEvent(streamId, event);
560-
} else {
581+
}
582+
else {
561583
if (!remoteServiceRunners.containsKey(method)) {
562584
Logging.getLogger().logError("Unknown service " + method);
563585
return;
@@ -566,7 +588,8 @@ void processNotification(JsonObject json) {
566588
final RemoteServiceRunner runner = remoteServiceRunners.get(method);
567589
try {
568590
runner.run(params, ignoreCallback);
569-
} catch (Exception e) {
591+
}
592+
catch (Exception e) {
570593
Logging.getLogger().logError("Internal Server Error", e);
571594
}
572595
}
@@ -587,7 +610,8 @@ void processResponse(JsonObject json) {
587610
String id;
588611
try {
589612
id = idElem.getAsString();
590-
} catch (Exception e) {
613+
}
614+
catch (Exception e) {
591615
Logging.getLogger().logError("Response missing " + ID, e);
592616
return;
593617
}
@@ -603,7 +627,8 @@ void processResponse(JsonObject json) {
603627
JsonObject result;
604628
try {
605629
result = resultElem.getAsJsonObject();
606-
} catch (Exception e) {
630+
}
631+
catch (Exception e) {
607632
Logging.getLogger().logError("Response has invalid " + RESULT, e);
608633
return;
609634
}
@@ -626,7 +651,8 @@ else if (!(consumer instanceof ServiceExtensionConsumer)) {
626651
JsonObject error;
627652
try {
628653
error = resultElem.getAsJsonObject();
629-
} catch (Exception e) {
654+
}
655+
catch (Exception e) {
630656
Logging.getLogger().logError("Response has invalid " + RESULT, e);
631657
return;
632658
}

0 commit comments

Comments
 (0)