Skip to content

Commit 4e2c22c

Browse files
committed
fix: SpotlessJavaCheck Violations (#1168)
1 parent a03b49e commit 4e2c22c

File tree

5 files changed

+199
-177
lines changed

5 files changed

+199
-177
lines changed

parse/src/main/java/com/parse/Parse.java

Lines changed: 54 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
import android.content.pm.PackageManager;
1313
import android.content.pm.ResolveInfo;
1414
import android.util.Log;
15-
1615
import androidx.annotation.NonNull;
1716
import androidx.annotation.Nullable;
18-
1917
import com.parse.boltsinternal.Continuation;
2018
import com.parse.boltsinternal.Task;
21-
2219
import java.io.File;
2320
import java.io.FileOutputStream;
2421
import java.io.IOException;
@@ -29,7 +26,6 @@
2926
import java.util.List;
3027
import java.util.Set;
3128
import java.util.concurrent.Callable;
32-
3329
import okhttp3.OkHttpClient;
3430

3531
/**
@@ -79,8 +75,8 @@ private Parse() {
7975
* }
8076
* }
8177
* </pre>
82-
* <p>
83-
* See <a
78+
*
79+
* <p>See <a
8480
* href="https://github.com/parse-community/Parse-SDK-Android/issues/279">https://github.com/parse-community/Parse-SDK-Android/issues/279</a>
8581
* for a discussion on performance of local datastore, and if it is right for your project.
8682
*
@@ -89,8 +85,8 @@ private Parse() {
8985
public static void enableLocalDatastore(Context context) {
9086
if (isInitialized()) {
9187
throw new IllegalStateException(
92-
"`Parse#enableLocalDatastore(Context)` must be invoked "
93-
+ "before `Parse#initialize(Context)`");
88+
"`Parse#enableLocalDatastore(Context)` must be invoked "
89+
+ "before `Parse#initialize(Context)`");
9490
}
9591
isLocalDatastoreEnabled = true;
9692
}
@@ -117,7 +113,7 @@ public static boolean isLocalDatastoreEnabled() {
117113

118114
/**
119115
* @return {@code True} if {@link Configuration.Builder#allowCustomObjectId()} has been called,
120-
* otherwise {@code false}.
116+
* otherwise {@code false}.
121117
*/
122118
public static boolean isAllowCustomObjectId() {
123119
return allowCustomObjectId;
@@ -183,32 +179,32 @@ static void initialize(Configuration configuration, ParsePlugins parsePlugins) {
183179
checkCacheApplicationId();
184180
final Context context = configuration.context;
185181
Task.callInBackground(
186-
(Callable<Void>)
187-
() -> {
188-
getEventuallyQueue(context);
189-
return null;
190-
});
182+
(Callable<Void>)
183+
() -> {
184+
getEventuallyQueue(context);
185+
return null;
186+
});
191187

192188
ParseFieldOperations.registerDefaultDecoders();
193189

194190
if (!allParsePushIntentReceiversInternal()) {
195191
throw new SecurityException(
196-
"To prevent external tampering to your app's notifications, "
197-
+ "all receivers registered to handle the following actions must have "
198-
+ "their exported attributes set to false: com.parse.push.intent.RECEIVE, "
199-
+ "com.parse.push.intent.OPEN, com.parse.push.intent.DELETE");
192+
"To prevent external tampering to your app's notifications, "
193+
+ "all receivers registered to handle the following actions must have "
194+
+ "their exported attributes set to false: com.parse.push.intent.RECEIVE, "
195+
+ "com.parse.push.intent.OPEN, com.parse.push.intent.DELETE");
200196
}
201197

202198
ParseUser.getCurrentUserAsync()
203-
.makeVoid()
204-
.continueWith(
205-
(Continuation<Void, Void>)
206-
task -> {
207-
// Prime config in the background
208-
ParseConfig.getCurrentConfig();
209-
return null;
210-
},
211-
Task.BACKGROUND_EXECUTOR);
199+
.makeVoid()
200+
.continueWith(
201+
(Continuation<Void, Void>)
202+
task -> {
203+
// Prime config in the background
204+
ParseConfig.getCurrentConfig();
205+
return null;
206+
},
207+
Task.BACKGROUND_EXECUTOR);
212208

213209
dispatchOnParseInitialized();
214210

@@ -220,11 +216,8 @@ static void initialize(Configuration configuration, ParsePlugins parsePlugins) {
220216

221217
// region Server URL
222218

223-
/**
224-
* Returns the current server URL.
225-
*/
226-
public static @Nullable
227-
String getServer() {
219+
/** Returns the current server URL. */
220+
public static @Nullable String getServer() {
228221
URL server = ParseRESTCommand.server;
229222
return server == null ? null : server.toString();
230223
}
@@ -258,8 +251,7 @@ public static void setServer(@NonNull String server) {
258251
* @param server The server URL to validate.
259252
* @return The validated server URL.
260253
*/
261-
private static @Nullable
262-
String validateServerUrl(@Nullable String server) {
254+
private static @Nullable String validateServerUrl(@Nullable String server) {
263255

264256
// Add an extra trailing slash so that Parse REST commands include
265257
// the path as part of the server URL (i.e. http://api.myhost.com/parse)
@@ -296,9 +288,7 @@ public static void destroy() {
296288
allowCustomObjectId = false;
297289
}
298290

299-
/**
300-
* @return {@code True} if {@link #initialize} has been called, otherwise {@code false}.
301-
*/
291+
/** @return {@code True} if {@link #initialize} has been called, otherwise {@code false}. */
302292
static boolean isInitialized() {
303293
return ParsePlugins.get() != null;
304294
}
@@ -321,10 +311,10 @@ public static Context getApplicationContext() {
321311
*/
322312
private static boolean allParsePushIntentReceiversInternal() {
323313
List<ResolveInfo> intentReceivers =
324-
ManifestInfo.getIntentReceivers(
325-
ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE,
326-
ParsePushBroadcastReceiver.ACTION_PUSH_DELETE,
327-
ParsePushBroadcastReceiver.ACTION_PUSH_OPEN);
314+
ManifestInfo.getIntentReceivers(
315+
ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE,
316+
ParsePushBroadcastReceiver.ACTION_PUSH_DELETE,
317+
ParsePushBroadcastReceiver.ACTION_PUSH_OPEN);
328318

329319
for (ResolveInfo resolveInfo : intentReceivers) {
330320
if (resolveInfo.activityInfo.exported) {
@@ -427,15 +417,15 @@ private static ParseEventuallyQueue getEventuallyQueue(Context context) {
427417
synchronized (MUTEX) {
428418
boolean isLocalDatastoreEnabled = Parse.isLocalDatastoreEnabled();
429419
if (eventuallyQueue == null
430-
|| (isLocalDatastoreEnabled && eventuallyQueue instanceof ParseCommandCache)
431-
|| (!isLocalDatastoreEnabled
432-
&& eventuallyQueue instanceof ParsePinningEventuallyQueue)) {
420+
|| (isLocalDatastoreEnabled && eventuallyQueue instanceof ParseCommandCache)
421+
|| (!isLocalDatastoreEnabled
422+
&& eventuallyQueue instanceof ParsePinningEventuallyQueue)) {
433423
checkContext();
434424
ParseHttpClient httpClient = ParsePlugins.get().restClient();
435425
eventuallyQueue =
436-
isLocalDatastoreEnabled
437-
? new ParsePinningEventuallyQueue(context, httpClient)
438-
: new ParseCommandCache(context, httpClient);
426+
isLocalDatastoreEnabled
427+
? new ParsePinningEventuallyQueue(context, httpClient)
428+
: new ParseCommandCache(context, httpClient);
439429

440430
// We still need to clear out the old command cache even if we're using Pinning in
441431
// case
@@ -449,35 +439,33 @@ private static ParseEventuallyQueue getEventuallyQueue(Context context) {
449439
}
450440
}
451441

452-
/**
453-
* Used by Parse LiveQuery
454-
*/
442+
/** Used by Parse LiveQuery */
455443
public static void checkInit() {
456444
if (ParsePlugins.get() == null) {
457445
throw new RuntimeException(
458-
"You must call Parse.initialize(Context)" + " before using the Parse library.");
446+
"You must call Parse.initialize(Context)" + " before using the Parse library.");
459447
}
460448

461449
if (ParsePlugins.get().applicationId() == null) {
462450
throw new RuntimeException(
463-
"applicationId is null. "
464-
+ "You must call Parse.initialize(Context)"
465-
+ " before using the Parse library.");
451+
"applicationId is null. "
452+
+ "You must call Parse.initialize(Context)"
453+
+ " before using the Parse library.");
466454
}
467455
}
468456

469457
static void checkContext() {
470458
if (ParsePlugins.get().applicationContext() == null) {
471459
throw new RuntimeException(
472-
"applicationContext is null. "
473-
+ "You must call Parse.initialize(Context)"
474-
+ " before using the Parse library.");
460+
"applicationContext is null. "
461+
+ "You must call Parse.initialize(Context)"
462+
+ " before using the Parse library.");
475463
}
476464
}
477465

478466
static boolean hasPermission(String permission) {
479467
return (getApplicationContext().checkCallingOrSelfPermission(permission)
480-
== PackageManager.PERMISSION_GRANTED);
468+
== PackageManager.PERMISSION_GRANTED);
481469
}
482470

483471
// endregion
@@ -487,10 +475,10 @@ static boolean hasPermission(String permission) {
487475
static void requirePermission(String permission) {
488476
if (!hasPermission(permission)) {
489477
throw new IllegalStateException(
490-
"To use this functionality, add this to your AndroidManifest.xml:\n"
491-
+ "<uses-permission android:name=\""
492-
+ permission
493-
+ "\" />");
478+
"To use this functionality, add this to your AndroidManifest.xml:\n"
479+
+ "<uses-permission android:name=\""
480+
+ permission
481+
+ "\" />");
494482
}
495483
}
496484

@@ -504,7 +492,7 @@ static void requirePermission(String permission) {
504492
static void registerParseCallbacks(ParseCallbacks listener) {
505493
if (isInitialized()) {
506494
throw new IllegalStateException(
507-
"You must register callbacks before Parse.initialize(Context)");
495+
"You must register callbacks before Parse.initialize(Context)");
508496
}
509497

510498
synchronized (MUTEX_CALLBACKS) {
@@ -552,9 +540,7 @@ private static ParseCallbacks[] collectParseCallbacks() {
552540
return callbacks;
553541
}
554542

555-
/**
556-
* Returns the level of logging that will be displayed.
557-
*/
543+
/** Returns the level of logging that will be displayed. */
558544
public static int getLogLevel() {
559545
return PLog.getLogLevel();
560546
}
@@ -586,9 +572,7 @@ interface ParseCallbacks {
586572
void onParseInitialized();
587573
}
588574

589-
/**
590-
* Represents an opaque configuration for the {@code Parse} SDK configuration.
591-
*/
575+
/** Represents an opaque configuration for the {@code Parse} SDK configuration. */
592576
public static final class Configuration {
593577
final Context context;
594578
final String applicationId;
@@ -610,9 +594,7 @@ private Configuration(Builder builder) {
610594
this.maxRetries = builder.maxRetries;
611595
}
612596

613-
/**
614-
* Allows for simple constructing of a {@code Configuration} object.
615-
*/
597+
/** Allows for simple constructing of a {@code Configuration} object. */
616598
public static final class Builder {
617599
private final Context context;
618600
private String applicationId;

0 commit comments

Comments
 (0)