-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add java lint (google-java-format)
- Loading branch information
1 parent
7ba218b
commit ed9294c
Showing
15 changed files
with
1,767 additions
and
1,656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 63 additions & 66 deletions
129
packages/core/android/src/main/java/io/sentry/react/RNSentryBreadcrumb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,84 @@ | ||
package io.sentry.react; | ||
|
||
import com.facebook.react.bridge.ReadableMap; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Map; | ||
|
||
import io.sentry.Breadcrumb; | ||
import io.sentry.SentryLevel; | ||
import java.util.Map; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class RNSentryBreadcrumb { | ||
|
||
@Nullable | ||
public static String getCurrentScreenFrom(ReadableMap from) { | ||
final @Nullable String maybeCategory = from.hasKey("category") ? from.getString("category") : null; | ||
if (maybeCategory == null || !maybeCategory.equals("navigation")) { | ||
return null; | ||
} | ||
|
||
final @Nullable ReadableMap maybeData = from.hasKey("data") ? from.getMap("data") : null; | ||
if (maybeData == null) { | ||
return null; | ||
} | ||
@Nullable | ||
public static String getCurrentScreenFrom(ReadableMap from) { | ||
final @Nullable String maybeCategory = | ||
from.hasKey("category") ? from.getString("category") : null; | ||
if (maybeCategory == null || !maybeCategory.equals("navigation")) { | ||
return null; | ||
} | ||
|
||
try { | ||
// getString might throw if cast to string fails (data.to is not enforced by TS to be a string) | ||
return maybeData.hasKey("to") ? maybeData.getString("to") : null; | ||
} catch (Throwable exception) { | ||
return null; | ||
} | ||
final @Nullable ReadableMap maybeData = from.hasKey("data") ? from.getMap("data") : null; | ||
if (maybeData == null) { | ||
return null; | ||
} | ||
|
||
@NotNull | ||
public static Breadcrumb fromMap(ReadableMap from) { | ||
final @NotNull Breadcrumb breadcrumb = new Breadcrumb(); | ||
try { | ||
// getString might throw if cast to string fails (data.to is not enforced by TS to be a | ||
// string) | ||
return maybeData.hasKey("to") ? maybeData.getString("to") : null; | ||
} catch (Throwable exception) { | ||
return null; | ||
} | ||
} | ||
|
||
if (from.hasKey("message")) { | ||
breadcrumb.setMessage(from.getString("message")); | ||
} | ||
@NotNull | ||
public static Breadcrumb fromMap(ReadableMap from) { | ||
final @NotNull Breadcrumb breadcrumb = new Breadcrumb(); | ||
|
||
if (from.hasKey("type")) { | ||
breadcrumb.setType(from.getString("type")); | ||
} | ||
if (from.hasKey("message")) { | ||
breadcrumb.setMessage(from.getString("message")); | ||
} | ||
|
||
if (from.hasKey("category")) { | ||
breadcrumb.setCategory(from.getString("category")); | ||
} | ||
if (from.hasKey("type")) { | ||
breadcrumb.setType(from.getString("type")); | ||
} | ||
|
||
if (from.hasKey("level")) { | ||
switch (from.getString("level")) { | ||
case "fatal": | ||
breadcrumb.setLevel(SentryLevel.FATAL); | ||
break; | ||
case "warning": | ||
breadcrumb.setLevel(SentryLevel.WARNING); | ||
break; | ||
case "debug": | ||
breadcrumb.setLevel(SentryLevel.DEBUG); | ||
break; | ||
case "error": | ||
breadcrumb.setLevel(SentryLevel.ERROR); | ||
break; | ||
case "info": | ||
default: | ||
breadcrumb.setLevel(SentryLevel.INFO); | ||
break; | ||
} | ||
} | ||
if (from.hasKey("category")) { | ||
breadcrumb.setCategory(from.getString("category")); | ||
} | ||
|
||
if (from.hasKey("level")) { | ||
switch (from.getString("level")) { | ||
case "fatal": | ||
breadcrumb.setLevel(SentryLevel.FATAL); | ||
break; | ||
case "warning": | ||
breadcrumb.setLevel(SentryLevel.WARNING); | ||
break; | ||
case "debug": | ||
breadcrumb.setLevel(SentryLevel.DEBUG); | ||
break; | ||
case "error": | ||
breadcrumb.setLevel(SentryLevel.ERROR); | ||
break; | ||
case "info": | ||
default: | ||
breadcrumb.setLevel(SentryLevel.INFO); | ||
break; | ||
} | ||
} | ||
|
||
if (from.hasKey("data")) { | ||
final ReadableMap data = from.getMap("data"); | ||
for (final Map.Entry<String, Object> entry : data.toHashMap().entrySet()) { | ||
final Object value = entry.getValue(); | ||
// data is ConcurrentHashMap and can't have null values | ||
if (value != null) { | ||
breadcrumb.setData(entry.getKey(), entry.getValue()); | ||
} | ||
} | ||
if (from.hasKey("data")) { | ||
final ReadableMap data = from.getMap("data"); | ||
for (final Map.Entry<String, Object> entry : data.toHashMap().entrySet()) { | ||
final Object value = entry.getValue(); | ||
// data is ConcurrentHashMap and can't have null values | ||
if (value != null) { | ||
breadcrumb.setData(entry.getKey(), entry.getValue()); | ||
} | ||
|
||
return breadcrumb; | ||
} | ||
} | ||
|
||
return breadcrumb; | ||
} | ||
} |
Oops, something went wrong.