Skip to content

Commit 06d8f96

Browse files
davidaureliofacebook-github-bot
authored andcommitted
Inline format strings in DevServerHelper
Summary: Having format strings and values to interpolate separated makes reading the respective calls difficult. It has also led to situations where format strings were reused with slightly different values, instead of creating a parameterized method. Reviewed By: pakoito Differential Revision: D6900905 fbshipit-source-id: 68b56af6a86c0b46bc8cf9c44fbe0fb93ee151ac
1 parent d3db764 commit 06d8f96

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@
6565
public class DevServerHelper {
6666
public static final String RELOAD_APP_EXTRA_JS_PROXY = "jsproxy";
6767

68-
private static final String BUNDLE_URL_FORMAT =
69-
"http://%s/%s.%s?platform=android&dev=%s&minify=%s";
70-
private static final String RESOURCE_URL_FORMAT = "http://%s/%s";
71-
private static final String LAUNCH_JS_DEVTOOLS_COMMAND_URL_FORMAT =
72-
"http://%s/launch-js-devtools";
73-
private static final String ONCHANGE_ENDPOINT_URL_FORMAT =
74-
"http://%s/onchange";
75-
private static final String WEBSOCKET_PROXY_URL_FORMAT = "ws://%s/debugger-proxy?role=client";
76-
private static final String PACKAGER_STATUS_URL_FORMAT = "http://%s/status";
77-
private static final String INSPECTOR_DEVICE_URL_FORMAT = "http://%s/inspector/device?name=%s&app=%s";
78-
private static final String INSPECTOR_ATTACH_URL_FORMAT = "http://%s/nuclide/attach-debugger-nuclide?title=%s&app=%s&device=%s";
79-
private static final String SYMBOLICATE_URL_FORMAT = "http://%s/symbolicate";
80-
private static final String OPEN_STACK_FRAME_URL_FORMAT = "http://%s/open-stack-frame";
81-
8268
private static final String PACKAGER_OK_STATUS = "packager-status:running";
8369

8470
private static final int LONG_POLL_KEEP_ALIVE_DURATION_MS = 2 * 60 * 1000; // 2 mins
@@ -365,14 +351,14 @@ public void onResponse(Call call, final Response response) throws IOException {
365351
public String getWebsocketProxyURL() {
366352
return String.format(
367353
Locale.US,
368-
WEBSOCKET_PROXY_URL_FORMAT,
354+
"ws://%s/debugger-proxy?role=client",
369355
mSettings.getPackagerConnectionSettings().getDebugServerHost());
370356
}
371357

372358
private String getInspectorDeviceUrl() {
373359
return String.format(
374360
Locale.US,
375-
INSPECTOR_DEVICE_URL_FORMAT,
361+
"http://%s/inspector/device?name=%s&app=%s",
376362
mSettings.getPackagerConnectionSettings().getInspectorServerHost(),
377363
AndroidInfoHelpers.getFriendlyDeviceName(),
378364
mPackageName);
@@ -381,7 +367,7 @@ private String getInspectorDeviceUrl() {
381367
private String getInspectorAttachUrl(String title) {
382368
return String.format(
383369
Locale.US,
384-
INSPECTOR_ATTACH_URL_FORMAT,
370+
"http://%s/nuclide/attach-debugger-nuclide?title=%s&app=%s&device=%s",
385371
AndroidInfoHelpers.getServerHost(),
386372
title,
387373
mPackageName,
@@ -426,7 +412,7 @@ private boolean getJSMinifyMode() {
426412
private String createBundleURL(String mainModuleID, BundleType type, String host) {
427413
return String.format(
428414
Locale.US,
429-
BUNDLE_URL_FORMAT,
415+
"http://%s/%s.%s?platform=android&dev=%s&minify=%s",
430416
host,
431417
mainModuleID,
432418
type.typeID(),
@@ -440,15 +426,15 @@ private String createBundleURL(String mainModuleID, BundleType type) {
440426
}
441427

442428
private static String createResourceURL(String host, String resourcePath) {
443-
return String.format(Locale.US, RESOURCE_URL_FORMAT, host, resourcePath);
429+
return String.format(Locale.US, "http://%s/%s", host, resourcePath);
444430
}
445431

446432
private static String createSymbolicateURL(String host) {
447-
return String.format(Locale.US, SYMBOLICATE_URL_FORMAT, host);
433+
return String.format(Locale.US, "http://%s/symbolicate", host);
448434
}
449435

450436
private static String createOpenStackFrameURL(String host) {
451-
return String.format(Locale.US, OPEN_STACK_FRAME_URL_FORMAT, host);
437+
return String.format(Locale.US, "http://%s/open-stack-frame", host);
452438
}
453439

454440
public String getDevServerBundleURL(final String jsModulePath) {
@@ -508,7 +494,7 @@ public void onResponse(Call call, Response response) throws IOException {
508494
}
509495

510496
private static String createPackagerStatusURL(String host) {
511-
return String.format(Locale.US, PACKAGER_STATUS_URL_FORMAT, host);
497+
return String.format(Locale.US, "http://%s/status", host);
512498
}
513499

514500
public void stopPollingOnChangeEndpoint() {
@@ -583,14 +569,14 @@ public void onResponse(Call call, Response response) throws IOException {
583569
private String createOnChangeEndpointUrl() {
584570
return String.format(
585571
Locale.US,
586-
ONCHANGE_ENDPOINT_URL_FORMAT,
572+
"http://%s/onchange",
587573
mSettings.getPackagerConnectionSettings().getDebugServerHost());
588574
}
589575

590576
private String createLaunchJSDevtoolsCommandUrl() {
591577
return String.format(
592578
Locale.US,
593-
LAUNCH_JS_DEVTOOLS_COMMAND_URL_FORMAT,
579+
"http://%s/launch-js-devtools",
594580
mSettings.getPackagerConnectionSettings().getDebugServerHost());
595581
}
596582

0 commit comments

Comments
 (0)