Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions bugsnag-android-core/api/bugsnag-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -458,28 +458,33 @@ public final class com/bugsnag/android/FeatureFlag : java/util/Map$Entry {
public fun toString ()Ljava/lang/String;
}

public class com/bugsnag/android/JsonStream {
public final class com/bugsnag/android/JsonStream : java/io/Closeable, java/io/Flushable {
public fun <init> (Ljava/io/Writer;)V
public synthetic fun beginArray ()Lcom/bugsnag/android/JsonWriter;
public synthetic fun beginObject ()Lcom/bugsnag/android/JsonWriter;
public synthetic fun close ()V
public synthetic fun endArray ()Lcom/bugsnag/android/JsonWriter;
public synthetic fun endObject ()Lcom/bugsnag/android/JsonWriter;
public synthetic fun flush ()V
public synthetic fun isLenient ()Z
public synthetic fun jsonValue (Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
public fun name (Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
public synthetic fun name (Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
public synthetic fun nullValue ()Lcom/bugsnag/android/JsonWriter;
public synthetic fun value (D)Lcom/bugsnag/android/JsonWriter;
public synthetic fun value (J)Lcom/bugsnag/android/JsonWriter;
public fun value (Ljava/io/File;)V
public synthetic fun value (Ljava/lang/Boolean;)Lcom/bugsnag/android/JsonWriter;
public synthetic fun value (Ljava/lang/Number;)Lcom/bugsnag/android/JsonWriter;
public fun value (Ljava/lang/Object;)V
public fun value (Ljava/lang/Object;Z)V
public synthetic fun value (Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
public synthetic fun value (Z)Lcom/bugsnag/android/JsonWriter;
public final fun beginArray ()Lcom/bugsnag/android/JsonStream;
public final fun beginObject ()Lcom/bugsnag/android/JsonStream;
public fun close ()V
public final fun endArray ()Lcom/bugsnag/android/JsonStream;
public final fun endObject ()Lcom/bugsnag/android/JsonStream;
public fun flush ()V
public static final fun getHTML_SAFE_REPLACEMENT_CHARS$bugsnag_android_core_release ()[Ljava/lang/String;
public static final fun getREPLACEMENT_CHARS$bugsnag_android_core_release ()[Ljava/lang/String;
public final fun isHtmlSafe ()Z
public final fun isLenient ()Z
public final fun jsonValue (Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
public final fun name (Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
public final fun nullValue ()Lcom/bugsnag/android/JsonStream;
public final fun setHtmlSafe (Z)V
public final fun setIndent (Ljava/lang/String;)V
public final fun setLenient (Z)V
public final fun value (D)Lcom/bugsnag/android/JsonStream;
public final fun value (J)Lcom/bugsnag/android/JsonStream;
public final fun value (Ljava/io/File;)Lcom/bugsnag/android/JsonStream;
public final fun value (Ljava/lang/Boolean;)Lcom/bugsnag/android/JsonStream;
public final fun value (Ljava/lang/Number;)Lcom/bugsnag/android/JsonStream;
public final fun value (Ljava/lang/Object;)Lcom/bugsnag/android/JsonStream;
public final fun value (Ljava/lang/Object;Z)Lcom/bugsnag/android/JsonStream;
public final fun value (Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
public final fun value (Z)Lcom/bugsnag/android/JsonStream;
}

public abstract interface class com/bugsnag/android/JsonStream$Streamable {
Expand Down
7 changes: 7 additions & 0 deletions bugsnag-android-core/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>ComplexCondition:JsonStream.kt$JsonStream$!this.isLenient &amp;&amp; (string == "-Infinity" || string == "Infinity" || string == "NaN")</ID>
<ID>CyclomaticComplexMethod:AppDataCollector.kt$AppDataCollector$@SuppressLint("SwitchIntDef") @Suppress("DEPRECATION") private fun getProcessImportance(): String?</ID>
<ID>CyclomaticComplexMethod:ConfigInternal.kt$ConfigInternal$fun getConfigDifferences(): Map&lt;String, Any></ID>
<ID>CyclomaticComplexMethod:JsonCollectionParser.kt$JsonCollectionParser$private fun parseNumber(): Number</ID>
Expand All @@ -26,6 +27,7 @@
<ID>LongParameterList:StateEvent.kt$StateEvent.Install$( @JvmField val apiKey: String, @JvmField val autoDetectNdkCrashes: Boolean, @JvmField val appVersion: String?, @JvmField val buildUuid: String?, @JvmField val releaseStage: String?, @JvmField val lastRunInfoPath: String, @JvmField val consecutiveLaunchCrashes: Int, @JvmField val sendThreads: ThreadSendPolicy, @JvmField val maxBreadcrumbs: Int )</ID>
<ID>LongParameterList:ThreadState.kt$ThreadState$( allThreads: List&lt;JavaThread>, currentThread: JavaThread, exc: Throwable?, isUnhandled: Boolean, maxThreadCount: Int, threadCollectionTimeLimitMillis: Long, projectPackages: Collection&lt;String>, logger: Logger )</ID>
<ID>LoopWithTooManyJumpStatements:JsonCollectionParser.kt$JsonCollectionParser$while</ID>
<ID>LoopWithTooManyJumpStatements:JsonStream.kt$JsonStream$for</ID>
<ID>MagicNumber:BugsnagEventMapper.kt$BugsnagEventMapper$16</ID>
<ID>MagicNumber:BugsnagEventMapper.kt$BugsnagEventMapper$32</ID>
<ID>MagicNumber:BugsnagEventMapper.kt$BugsnagEventMapper$56</ID>
Expand Down Expand Up @@ -60,6 +62,9 @@
<ID>MagicNumber:JsonHelper.kt$JsonHelper$19</ID>
<ID>MagicNumber:JsonHelper.kt$JsonHelper$3</ID>
<ID>MagicNumber:JsonHelper.kt$JsonHelper$8</ID>
<ID>MagicNumber:JsonStream.kt$JsonStream$128</ID>
<ID>MagicNumber:JsonStream.kt$JsonStream$32</ID>
<ID>MagicNumber:JsonStream.kt$JsonStream.Companion$128</ID>
<ID>MagicNumber:LastRunInfoStore.kt$LastRunInfoStore$3</ID>
<ID>MagicNumber:SessionStore.kt$SessionStore$60</ID>
<ID>MaxLineLength:LastRunInfo.kt$LastRunInfo$return "LastRunInfo(consecutiveLaunchCrashes=$consecutiveLaunchCrashes, crashed=$crashed, crashedDuringLaunch=$crashedDuringLaunch)"</ID>
Expand Down Expand Up @@ -94,10 +99,12 @@
<ID>TooManyFunctions:ConfigInternal.kt$ConfigInternal : CallbackAwareMetadataAwareUserAwareFeatureFlagAware</ID>
<ID>TooManyFunctions:DeviceDataCollector.kt$DeviceDataCollector</ID>
<ID>TooManyFunctions:EventInternal.kt$EventInternal : FeatureFlagAwareStreamableMetadataAwareUserAware</ID>
<ID>TooManyFunctions:JsonStream.kt$JsonStream : CloseableFlushable</ID>
<ID>UnusedPrivateProperty:ManifestConfigLoader.kt$ManifestConfigLoader.Companion$private const val LAUNCH_CRASH_THRESHOLD_MS = "$BUGSNAG_NS.LAUNCH_CRASH_THRESHOLD_MS"</ID>
<ID>UnusedPrivateProperty:ThreadStateTest.kt$ThreadStateTest$private val configuration = generateImmutableConfig()</ID>
<ID>UseCheckOrError:BackgroundRunnableProviderServiceTest.kt$BackgroundRunnableProviderServiceTest$throw IllegalStateException()</ID>
<ID>UseCheckOrError:BugsnagEventMapper.kt$BugsnagEventMapper$throw IllegalStateException("cannot find json property '$key'")</ID>
<ID>UseCheckOrError:JsonStream.kt$JsonStream$throw IllegalStateException("Nesting problem.")</ID>
<ID>UseCheckOrError:StacktraceSerializationTest.kt$StacktraceSerializationTest.Companion$throw IllegalStateException()</ID>
<ID>UseCheckOrError:SynchronizedStreamableStoreTest.kt$CrashyStreamable$throw IllegalStateException()</ID>
<ID>UseCheckOrError:SynchronizedStreamableStoreTest.kt$CrashyStreamable.Companion$throw IllegalStateException()</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CustomDelegate : FileStore.Delegate {
}

class CustomStreamable(private val exc: Throwable) : JsonStream.Streamable {
override fun toStream(stream: JsonStream) = throw exc
override fun toStream(writer: JsonStream) = throw exc
}

internal class CustomFileStore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ internal class ThreadTestStreamable(
val writeCallback: () -> Unit = {}
) : JsonStream.Streamable {

override fun toStream(stream: JsonStream) {
with(stream) {
override fun toStream(writer: JsonStream) {
with(writer) {
beginObject()
name("test")
writeCallback()
Expand All @@ -134,7 +134,7 @@ internal class ThreadTestStreamable(
}

internal class CrashyStreamable : JsonStream.Streamable {
override fun toStream(stream: JsonStream) = throw IllegalStateException()
override fun toStream(writer: JsonStream) = throw IllegalStateException()

companion object : JsonReadable<CrashyStreamable> {
override fun fromReader(reader: JsonReader) = throw IllegalStateException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class DeviceIdFilePersistence(
*/
private class DeviceId(val id: String?) : JsonStream.Streamable {

override fun toStream(stream: JsonStream) {
with(stream) {
override fun toStream(writer: JsonStream) {
with(writer) {
beginObject()
name(KEY_ID)
value(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,72 +149,72 @@ internal class EventInternal : FeatureFlagAware, JsonStream.Streamable, Metadata
}

@Throws(IOException::class)
override fun toStream(parentWriter: JsonStream) {
val writer = JsonStream(parentWriter, jsonStreamer)
override fun toStream(writer: JsonStream) {
val childWriter = JsonStream(writer, jsonStreamer)
// Write error basics
writer.beginObject()
writer.name("context").value(context)
writer.name("groupingDiscriminator").value(groupingDiscriminator)
writer.name("metaData").value(metadata)
childWriter.beginObject()
childWriter.name("context").value(context)
childWriter.name("groupingDiscriminator").value(groupingDiscriminator)
childWriter.name("metaData").value(metadata)

writer.name("severity").value(severity)
writer.name("severityReason").value(severityReason)
writer.name("unhandled").value(severityReason.unhandled)
childWriter.name("severity").value(severity)
childWriter.name("severityReason").value(severityReason)
childWriter.name("unhandled").value(severityReason.unhandled)

// Write exception info
writer.name("exceptions")
writer.beginArray()
errors.forEach { writer.value(it) }
writer.endArray()
childWriter.name("exceptions")
childWriter.beginArray()
errors.forEach { childWriter.value(it) }
childWriter.endArray()

// Write project packages
writer.name("projectPackages")
writer.beginArray()
projectPackages.forEach { writer.value(it) }
writer.endArray()
childWriter.name("projectPackages")
childWriter.beginArray()
projectPackages.forEach { childWriter.value(it) }
childWriter.endArray()

// Write user info
writer.name("user").value(userImpl)
childWriter.name("user").value(userImpl)

// Write diagnostics
writer.name("app").value(app)
writer.name("device").value(device)
writer.name("breadcrumbs").value(breadcrumbs)
writer.name("groupingHash").value(groupingHash)
childWriter.name("app").value(app)
childWriter.name("device").value(device)
childWriter.name("breadcrumbs").value(breadcrumbs)
childWriter.name("groupingHash").value(groupingHash)
val usage = internalMetrics.toJsonableMap()
if (usage.isNotEmpty()) {
writer.name("usage")
writer.beginObject()
childWriter.name("usage")
childWriter.beginObject()
usage.forEach { entry ->
writer.name(entry.key).value(entry.value)
childWriter.name(entry.key).value(entry.value)
}
writer.endObject()
childWriter.endObject()
}

writer.name("threads")
writer.beginArray()
threads.forEach { writer.value(it) }
writer.endArray()
childWriter.name("threads")
childWriter.beginArray()
threads.forEach { childWriter.value(it) }
childWriter.endArray()

writer.name("featureFlags").value(featureFlags)
childWriter.name("featureFlags").value(featureFlags)

traceCorrelation?.let { correlation ->
writer.name("correlation").value(correlation)
childWriter.name("correlation").value(correlation)
}

if (session != null) {
val copy = Session.copySession(session)
writer.name("session").beginObject()
writer.name("id").value(copy.id)
writer.name("startedAt").value(copy.startedAt)
writer.name("events").beginObject()
writer.name("handled").value(copy.handledCount.toLong())
writer.name("unhandled").value(copy.unhandledCount.toLong())
writer.endObject()
writer.endObject()
childWriter.name("session").beginObject()
childWriter.name("id").value(copy.id)
childWriter.name("startedAt").value(copy.startedAt)
childWriter.name("events").beginObject()
childWriter.name("handled").value(copy.handledCount.toLong())
childWriter.name("unhandled").value(copy.unhandledCount.toLong())
childWriter.endObject()
childWriter.endObject()
}

writer.endObject()
childWriter.endObject()
}

internal fun getErrorTypesFromStackframes(): Set<ErrorType> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ internal class FeatureFlags private constructor(
}

@Throws(IOException::class)
override fun toStream(stream: JsonStream) {
override fun toStream(writer: JsonStream) {
val storeCopy = flags
stream.beginArray()
writer.beginArray()
storeCopy.forEach { (name, variant) ->
stream.beginObject()
stream.name("featureFlag").value(name)
writer.beginObject()
writer.name("featureFlag").value(name)
if (variant != null) {
stream.name("variant").value(variant)
writer.name("variant").value(variant)
}
stream.endObject()
writer.endObject()
}
stream.endArray()
writer.endArray()
}

fun toList(): List<FeatureFlag> = flags.map { (name, variant) -> FeatureFlag(name, variant) }
Expand Down

This file was deleted.

Loading
Loading