Skip to content

Commit

Permalink
fix: remove unused parantheses (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
arifBurakDemiray authored Jan 16, 2024
1 parent abdf629 commit 73d5862
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public static void main(String[] args) throws Exception {
String[] sdkStorageRootPath = { System.getProperty("user.home"), "__COUNTLY", "java_test" };
File sdkStorageRootDirectory = new File(String.join(File.separator, sdkStorageRootPath));

if ((!(sdkStorageRootDirectory.exists() && sdkStorageRootDirectory.isDirectory())) && !sdkStorageRootDirectory.mkdirs()) {
if (!(sdkStorageRootDirectory.exists() && sdkStorageRootDirectory.isDirectory()) && !sdkStorageRootDirectory.mkdirs()) {
DemoUtils.println("Directory creation failed");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ public static void main(String[] args) throws Exception {
case 2:
performLargeEventQueueTest();
running = false;
DemoUtils.printf("Time spent: %dms%n", (System.currentTimeMillis() - startTime));
DemoUtils.printf("Time spent: %dms%n", System.currentTimeMillis() - startTime);
break;
case 3:
startTime = System.currentTimeMillis();
recordBulkDataAndSendToServer();
running = false;
DemoUtils.printf("Time spent: %dms%n", (System.currentTimeMillis() - startTime));
DemoUtils.printf("Time spent: %dms%n", System.currentTimeMillis() - startTime);
break;
default:
break;
Expand Down
4 changes: 2 additions & 2 deletions sdk-java/src/main/java/ly/count/sdk/java/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public boolean equals(Object obj) {
return false;
}
DID did = (DID) obj;
return did.strategy == strategy && (Objects.equals(did.id, id));
return did.strategy == strategy && Objects.equals(did.id, id);
}

@Override
Expand Down Expand Up @@ -379,7 +379,7 @@ public Config disableUnhandledCrashReporting() {
this.unhandledCrashReportingEnabled = false;
return this;
}

protected String location = null;
protected String ip = null;
protected String city = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ public boolean equals(Object obj) {
if (count != event.count) {
return false;
}
if ((sum != null && !sum.equals(event.sum) || (event.sum != null && !event.sum.equals(sum)))) {
if (sum != null && !sum.equals(event.sum) || (event.sum != null && !event.sum.equals(sum))) {
return false;
}
if ((duration != null && !duration.equals(event.duration) || (event.duration != null && !event.duration.equals(duration)))) {
if (duration != null && !duration.equals(event.duration) || (event.duration != null && !event.duration.equals(duration))) {
return false;
}
if ((segmentation != null && !segmentation.equals(event.segmentation) || (event.segmentation != null && !event.segmentation.equals(segmentation)))) {
if (segmentation != null && !segmentation.equals(event.segmentation) || (event.segmentation != null && !event.segmentation.equals(segmentation))) {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,12 @@ protected Map<String, Object> removeInvalidDataFromSegments(Map<String, Object>
for (Map.Entry<String, Object> item : segments.entrySet()) {
Object type = item.getValue();

boolean isValidDataType = (type instanceof Boolean
boolean isValidDataType = type instanceof Boolean
|| type instanceof Integer
|| type instanceof Long
|| type instanceof String
|| type instanceof Double
|| type instanceof Float
);
|| type instanceof Float;

if (!isValidDataType) {
toRemove.add(item.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public void deviceIdChanged(String oldDeviceId, boolean withMerge) {

// this part is to end and record the current view if exists
Session session = Countly.session();
if ((session != null && session.isActive())) {
if (session != null && session.isActive()) {
View currentView = ((SessionImpl) session).currentView;
if (currentView != null) {
currentView.stop(true);
} else {
Storage.pushAsync(internalConfig, ((SessionImpl) Countly.session()));
Storage.pushAsync(internalConfig, (SessionImpl) Countly.session());
}
}

Expand Down Expand Up @@ -126,7 +126,7 @@ private void addEventToQueue(EventImpl event) {

private void checkEventQueueToSend(boolean forceSend) {
L.d("[ModuleEvents] queue size:[" + eventQueue.eqSize() + "] || forceSend: " + forceSend);
if (forceSend || (eventQueue.eqSize() >= internalConfig.getEventsBufferSize())) {
if (forceSend || eventQueue.eqSize() >= internalConfig.getEventsBufferSize()) {
addEventsToRequestQ(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void sendLocation() {
void setLocationInternal(@Nullable String countryCode, @Nullable String cityName, @Nullable String gpsCoordinates, @Nullable String ipAddress) {
L.d("[ModuleLocation] setLocationInternal, Setting location parameters, cc[" + countryCode + "] cy[" + city + "] gps[" + gpsCoordinates + "] ip[" + ipAddress + "]");

if ((countryCode == null && city != null) || (city == null && countryCode != null)) {
if (countryCode != null ^ city != null) {
L.w("[ModuleLocation] setLocationInternal, both city and country code need to be set at the same time to be sent");
}
country = countryCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum Op {
object.put("$max", Math.max(object.optDouble("$max", (Double) value), (Double) value));
json.put(key, object);
}),
SET_ONCE(((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).put("$setOnce", value)))),
SET_ONCE((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).put("$setOnce", value))),
PULL((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).accumulate("$pull", value))),
PUSH((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).accumulate("$push", value))),
PUSH_UNIQUE((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).accumulate("$addToSet", value)));
Expand Down
12 changes: 6 additions & 6 deletions sdk-java/src/main/java/ly/count/sdk/java/internal/Params.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public Params add() {

public Params(Object... objects) {
params = new StringBuilder();
if (objects != null && objects.length == 1 && (objects[0] instanceof Object[])) {
if (objects != null && objects.length == 1 && objects[0] instanceof Object[]) {
addObjects((Object[]) objects[0]);
} else if (objects != null && objects.length == 1 && (objects[0] instanceof Params)) {
params.append(objects[0].toString());
} else if (objects != null && objects.length == 1 && (objects[0] instanceof String)) {
params.append(objects[0].toString());
} else if (objects != null && objects.length == 1 && objects[0] instanceof Params) {
params.append(objects[0]);
} else if (objects != null && objects.length == 1 && objects[0] instanceof String) {
params.append(objects[0]);
} else {
addObjects(objects);
}
Expand Down Expand Up @@ -276,7 +276,7 @@ private Params addObjects(Object[] objects) {
L.e("Bad number of parameters");
} else {
for (int i = 0; i < objects.length; i += 2) {
add(objects[i] == null ? ("unknown" + i) : objects[i].toString(), objects.length > i + 1 ? objects[i + 1] : null);
add(objects[i] == null ? "unknown" + i : objects[i].toString(), objects.length > i + 1 ? objects[i + 1] : null);
}
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,13 @@ public boolean equals(Object obj) {
if (!id.equals(session.id)) {
return false;
}
if ((began != null && !began.equals(session.began) || (session.began != null && !session.began.equals(began)))) {
if (began != null && !began.equals(session.began) || (session.began != null && !session.began.equals(began))) {
return false;
}
if ((updated != null && !updated.equals(session.updated) || (session.updated != null && !session.updated.equals(updated)))) {
if (updated != null && !updated.equals(session.updated) || (session.updated != null && !session.updated.equals(updated))) {
return false;
}
if ((ended != null && !ended.equals(session.ended) || (session.ended != null && !session.ended.equals(ended)))) {
if (ended != null && !ended.equals(session.ended) || (session.ended != null && !session.ended.equals(ended))) {
return false;
}
if (!params.equals(session.params)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public UserEditor setPicture(byte[] picture) {
@Override
public UserEditor setPicturePath(String picturePath) {
L.d("[UserEditorImpl] setPicturePath, picturePath = " + picturePath);
if (picturePath == null || Utils.isValidURL(picturePath) || (new File(picturePath)).isFile()) {
if (picturePath == null || Utils.isValidURL(picturePath) || new File(picturePath).isFile()) {
//if it is a thing we can use, continue
return set(PredefinedUserPropertyKeys.PICTURE_PATH, picturePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void beforeTest() {
private void initStorage() {
InternalConfig config = (new InternalConfig(TestUtils.getBaseConfig()));
config.setLogger(mock(Log.class));
storageProvider = (new SDKStorage()).init(config);
storageProvider = new SDKStorage().init(config);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void stop() {
//doing all of this just to stop the Task
//todo eliminate this
InternalConfig config = TestUtils.getInternalConfigWithLogger(TestUtils.getBaseConfig());
SDKStorage storageProvider = (new SDKStorage()).init(config);
SDKStorage storageProvider = new SDKStorage().init(config);
storageProvider.stop(config, true);
}

Expand All @@ -41,7 +41,7 @@ public void stop() {
*/
@Test
public void getDeviceID() {
SDKStorage storageProvider = (new SDKStorage()).init(TestUtils.getInternalConfigWithLogger(TestUtils.getBaseConfig()));
SDKStorage storageProvider = new SDKStorage().init(TestUtils.getInternalConfigWithLogger(TestUtils.getBaseConfig()));
Assert.assertNull(storageProvider.getDeviceID());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ public void equals_notInstanceOf() {
*/
@Test
public void equals_differentId() {
validateNotEquals(1, ((session, session2) -> ts -> {
}));
validateNotEquals(1, (session, session2) -> ts -> {
});
}

/**
Expand Down

0 comments on commit 73d5862

Please sign in to comment.