Skip to content

Commit 949ad59

Browse files
Apply suggestions from code review
Co-authored-by: LucasZF <[email protected]>
1 parent 758b3d3 commit 949ad59

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

android/src/main/java/io/sentry/react/RNSentryBreadcrumb.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,23 @@ public class RNSentryBreadcrumb {
1414

1515
@Nullable
1616
public static String getCurrentScreenFrom(ReadableMap from) {
17-
final @Nullable String maybeCategory = from.hasKey("category") ? from.getString("category") : null;
18-
if (maybeCategory == null || !maybeCategory.equals("navigation")) {
17+
if (!from.hasKey("category")) {
1918
return null;
2019
}
20+
final @Nullable String category = from.getString("category") :
2121

22-
final @Nullable ReadableMap maybeData = from.hasKey("data") ? from.getMap("data") : null;
23-
if (maybeData == null) {
22+
if (!category.equals("navigation")) {
2423
return null;
2524
}
2625

26+
if (!from.hasKey("data")) {
27+
return null;
28+
}
29+
final @Nullable ReadableMap data = from.getMap("data");
30+
2731
try {
2832
// getString might throw if cast to string fails (data.to is not enforced by TS to be a string)
29-
return maybeData.hasKey("to") ? maybeData.getString("to") : null;
33+
return data.hasKey("to") ? data.getString("to") : null;
3034
} catch (Throwable exception) {
3135
return null;
3236
}

0 commit comments

Comments
 (0)