diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ab8e7405..ff350058 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,4 +20,4 @@ mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.37.0" spotlessPlugin = "com.diffplug.spotless:spotless-plugin-gradle:8.7.0" buildConfigPlugin = "com.github.gmazzo.buildconfig:plugin:6.0.10" pokoPlugin = "dev.drewhamilton.poko:dev.drewhamilton.poko.gradle.plugin:0.23.1" -ktfmt = "com.facebook:ktfmt:0.63" +ktfmt = "com.facebook:ktfmt:0.64" diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArchiveFilesDiff.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArchiveFilesDiff.kt index 93ddcdf0..aaf8d70b 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArchiveFilesDiff.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArchiveFilesDiff.kt @@ -97,142 +97,141 @@ internal fun ArchiveFilesDiff.toSummaryTable( name: String, displayTypes: List, skipIfEmptyTypes: Set = emptySet(), -) = - diffuseTable { +) = diffuseTable { + header { + if (includeCompressed) { + row { + cell(name) { + alignment = BottomLeft + rowSpan = 2 + } + cell("compressed") { + columnSpan = 3 + alignment = BottomCenter + } + cell("uncompressed") { + columnSpan = 3 + alignment = BottomCenter + } + } + row("old", "new", "diff", "old", "new", "diff") + } else { + row { + cell(name) { alignment = BottomLeft } + cell("old") + cell("new") + cell("diff") + } + } + } + + fun TableSectionDsl.addApkRow(name: String, type: Type? = null) { + val old = if (type != null) oldFiles.filterValues { it.type == type } else oldFiles + val new = if (type != null) newFiles.filterValues { it.type == type } else newFiles + val oldSize = old.values.fold(0.binaryBytes) { acc, file -> acc + file.size } + val newSize = new.values.fold(0.binaryBytes) { acc, file -> acc + file.size } + val oldUncompressedSize = + old.values.fold(0.binaryBytes) { acc, file -> acc + file.uncompressedSize } + val newUncompressedSize = + new.values.fold(0.binaryBytes) { acc, file -> acc + file.uncompressedSize } + if (oldSize != 0.binaryBytes || newSize != 0.binaryBytes || type !in skipIfEmptyTypes) { + val uncompressedDiff = (newUncompressedSize - oldUncompressedSize).toDiffString() + if (includeCompressed) { + row( + name, + oldSize, + newSize, + (newSize - oldSize).toDiffString(), + oldUncompressedSize, + newUncompressedSize, + uncompressedDiff, + ) + } else { + row(name, oldUncompressedSize, newUncompressedSize, uncompressedDiff) + } + } + } + + body { + cellStyle { alignment = MiddleRight } + for (type in displayTypes) { + addApkRow(type.displayName, type) + } + } + + footer { + cellStyle { alignment = MiddleRight } + addApkRow("total") + } +} + .renderText() + +internal fun ArchiveFilesDiff.toDetailReport() = buildString { + appendLine() + appendLine( + diffuseTable { header { if (includeCompressed) { row { - cell(name) { - alignment = BottomLeft - rowSpan = 2 - } cell("compressed") { - columnSpan = 3 - alignment = BottomCenter + columnSpan = 2 + alignment = MiddleCenter } cell("uncompressed") { - columnSpan = 3 - alignment = BottomCenter + columnSpan = 2 + alignment = MiddleCenter + } + cell("path") { + rowSpan = 2 + alignment = BottomLeft } } - row("old", "new", "diff", "old", "new", "diff") + row("size", "diff", "size", "diff") } else { row { - cell(name) { alignment = BottomLeft } - cell("old") - cell("new") + cell("size") cell("diff") + cell("path") { alignment = BottomLeft } } } } - - fun TableSectionDsl.addApkRow(name: String, type: Type? = null) { - val old = if (type != null) oldFiles.filterValues { it.type == type } else oldFiles - val new = if (type != null) newFiles.filterValues { it.type == type } else newFiles - val oldSize = old.values.fold(0.binaryBytes) { acc, file -> acc + file.size } - val newSize = new.values.fold(0.binaryBytes) { acc, file -> acc + file.size } - val oldUncompressedSize = - old.values.fold(0.binaryBytes) { acc, file -> acc + file.uncompressedSize } - val newUncompressedSize = - new.values.fold(0.binaryBytes) { acc, file -> acc + file.uncompressedSize } - if (oldSize != 0.binaryBytes || newSize != 0.binaryBytes || type !in skipIfEmptyTypes) { - val uncompressedDiff = (newUncompressedSize - oldUncompressedSize).toDiffString() + footer { + row { if (includeCompressed) { - row( - name, - oldSize, - newSize, - (newSize - oldSize).toDiffString(), - oldUncompressedSize, - newUncompressedSize, - uncompressedDiff, - ) - } else { - row(name, oldUncompressedSize, newUncompressedSize, uncompressedDiff) + val totalSize = changes.fold(0.binaryBytes) { acc, change -> acc + change.size } + val totalDiff = changes.fold(0.binaryBytes) { acc, change -> acc + change.sizeDiff } + cell(totalSize) { alignment = MiddleRight } + cell(totalDiff.toDiffString()) { alignment = MiddleRight } } + val totalUncompressedSize = + changes.fold(0.binaryBytes) { acc, change -> acc + change.uncompressedSize } + val totalUncompressedDiff = + changes.fold(0.binaryBytes) { acc, change -> acc + change.uncompressedSizeDiff } + cell(totalUncompressedSize) { alignment = MiddleRight } + cell(totalUncompressedDiff.toDiffString()) { alignment = MiddleRight } + cell("(total)") } } - - body { - cellStyle { alignment = MiddleRight } - for (type in displayTypes) { - addApkRow(type.displayName, type) - } - } - - footer { - cellStyle { alignment = MiddleRight } - addApkRow("total") - } - } - .renderText() - -internal fun ArchiveFilesDiff.toDetailReport() = buildString { - appendLine() - appendLine( - diffuseTable { - header { - if (includeCompressed) { - row { - cell("compressed") { - columnSpan = 2 - alignment = MiddleCenter - } - cell("uncompressed") { - columnSpan = 2 - alignment = MiddleCenter - } - cell("path") { - rowSpan = 2 - alignment = BottomLeft - } - } - row("size", "diff", "size", "diff") - } else { - row { - cell("size") - cell("diff") - cell("path") { alignment = BottomLeft } - } + for ((path, size, sizeDiff, uncompressedSize, uncompressedSizeDiff, type) in changes) { + val typeChar = + when (type) { + Change.Type.Added -> '+' + Change.Type.Removed -> '-' + Change.Type.Changed -> '∆' } - } - footer { - row { - if (includeCompressed) { - val totalSize = changes.fold(0.binaryBytes) { acc, change -> acc + change.size } - val totalDiff = changes.fold(0.binaryBytes) { acc, change -> acc + change.sizeDiff } - cell(totalSize) { alignment = MiddleRight } - cell(totalDiff.toDiffString()) { alignment = MiddleRight } - } - val totalUncompressedSize = - changes.fold(0.binaryBytes) { acc, change -> acc + change.uncompressedSize } - val totalUncompressedDiff = - changes.fold(0.binaryBytes) { acc, change -> acc + change.uncompressedSizeDiff } - cell(totalUncompressedSize) { alignment = MiddleRight } - cell(totalUncompressedDiff.toDiffString()) { alignment = MiddleRight } - cell("(total)") + row { + if (includeCompressed) { + cell(if (type != Change.Type.Removed) size else "") { alignment = MiddleRight } + cell(sizeDiff.toDiffString()) { alignment = MiddleRight } } - } - for ((path, size, sizeDiff, uncompressedSize, uncompressedSizeDiff, type) in changes) { - val typeChar = - when (type) { - Change.Type.Added -> '+' - Change.Type.Removed -> '-' - Change.Type.Changed -> '∆' - } - row { - if (includeCompressed) { - cell(if (type != Change.Type.Removed) size else "") { alignment = MiddleRight } - cell(sizeDiff.toDiffString()) { alignment = MiddleRight } - } - cell(if (type != Change.Type.Removed) uncompressedSize else "") { - alignment = MiddleRight - } - cell(uncompressedSizeDiff.toDiffString()) { alignment = MiddleRight } - cell("$typeChar $path") + cell(if (type != Change.Type.Removed) uncompressedSize else "") { + alignment = MiddleRight } + cell(uncompressedSizeDiff.toDiffString()) { alignment = MiddleRight } + cell("$typeChar $path") } } + } .renderText() ) } diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArscDiff.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArscDiff.kt index 66a71e1e..d2821687 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArscDiff.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ArscDiff.kt @@ -20,68 +20,67 @@ internal class ArscDiff(val oldArsc: Arsc, val newArsc: Arsc) { entriesRemoved.isNotEmpty() } -internal fun ArscDiff.toSummaryTable() = - diffuseTable { - header { - row { - cell("ARSC") - cell("old") - cell("new") - cell("diff") { columnSpan = 2 } - } - } +internal fun ArscDiff.toSummaryTable() = diffuseTable { + header { + row { + cell("ARSC") + cell("old") + cell("new") + cell("diff") { columnSpan = 2 } + } + } - body { - cellStyle { alignment = MiddleRight } + body { + cellStyle { alignment = MiddleRight } - row { - cell("configs") - cell(oldArsc.configs.size) - cell(newArsc.configs.size) + row { + cell("configs") + cell(oldArsc.configs.size) + cell(newArsc.configs.size) - val configsDelta = configsAdded.size - configsRemoved.size - cell(configsDelta.toDiffString()) { borderRight = false } + val configsDelta = configsAdded.size - configsRemoved.size + cell(configsDelta.toDiffString()) { borderRight = false } - val delta = - if (configsAdded.isNotEmpty() || configsRemoved.isNotEmpty()) { - val added = configsAdded.size.toDiffString(zeroSign = '+') - val removed = (-configsRemoved.size).toDiffString(zeroSign = '-') - "($added $removed)" - } else { - "" - } - cell(delta) { - borderLeft = false - paddingLeft = 0 - alignment = MiddleLeft - } + val delta = + if (configsAdded.isNotEmpty() || configsRemoved.isNotEmpty()) { + val added = configsAdded.size.toDiffString(zeroSign = '+') + val removed = (-configsRemoved.size).toDiffString(zeroSign = '-') + "($added $removed)" + } else { + "" } + cell(delta) { + borderLeft = false + paddingLeft = 0 + alignment = MiddleLeft + } + } - row { - cell("entries") - cell(oldArsc.entries.size) - cell(newArsc.entries.size) + row { + cell("entries") + cell(oldArsc.entries.size) + cell(newArsc.entries.size) - val entriesDelta = entriesAdded.size - entriesRemoved.size - cell(entriesDelta.toDiffString()) { borderRight = false } + val entriesDelta = entriesAdded.size - entriesRemoved.size + cell(entriesDelta.toDiffString()) { borderRight = false } - val delta = - if (entriesAdded.isNotEmpty() || entriesRemoved.isNotEmpty()) { - val added = entriesAdded.size.toDiffString(zeroSign = '+') - val removed = (-entriesRemoved.size).toDiffString(zeroSign = '-') - "($added $removed)" - } else { - "" - } - cell(delta) { - borderLeft = false - paddingLeft = 0 - alignment = MiddleLeft - } + val delta = + if (entriesAdded.isNotEmpty() || entriesRemoved.isNotEmpty()) { + val added = entriesAdded.size.toDiffString(zeroSign = '+') + val removed = (-entriesRemoved.size).toDiffString(zeroSign = '-') + "($added $removed)" + } else { + "" } + cell(delta) { + borderLeft = false + paddingLeft = 0 + alignment = MiddleLeft } } - .renderText() + } +} + .renderText() internal fun ArscDiff.toDetailReport() = buildString { fun appendComponentDiff( @@ -98,23 +97,23 @@ internal fun ArscDiff.toDetailReport() = buildString { buildString { appendLine( diffuseTable { - header { - row { - cell("old") - cell("new") - cell("diff") - } + header { + row { + cell("old") + cell("new") + cell("diff") } - - val diffSize = (added.size - removed.size).toDiffString() - val addedSize = added.size.toDiffString(zeroSign = '+') - val removedSize = (-removed.size).toDiffString(zeroSign = '-') - row( - componentSelector(oldArsc).size, - componentSelector(newArsc).size, - "$diffSize ($addedSize $removedSize)", - ) } + + val diffSize = (added.size - removed.size).toDiffString() + val addedSize = added.size.toDiffString(zeroSign = '+') + val removedSize = (-removed.size).toDiffString(zeroSign = '-') + row( + componentSelector(oldArsc).size, + componentSelector(newArsc).size, + "$diffSize ($addedSize $removedSize)", + ) + } .renderText() ) added.forEach { appendLine("+ $it") } diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt index f7d0af9b..27d2064c 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt @@ -39,19 +39,19 @@ internal fun StringBuilder.appendComponentDiff(name: String, diff: ComponentDiff buildString { appendLine( diffuseTable { - header { - row { - cell("old") - cell("new") - cell("diff") - } + header { + row { + cell("old") + cell("new") + cell("diff") } - - val diffSize = (diff.added.size - diff.removed.size).toDiffString() - val addedSize = diff.added.size.toDiffString(zeroSign = '+') - val removedSize = (-diff.removed.size).toDiffString(zeroSign = '-') - row(diff.oldCount, diff.newCount, "$diffSize ($addedSize $removedSize)") } + + val diffSize = (diff.added.size - diff.removed.size).toDiffString() + val addedSize = diff.added.size.toDiffString(zeroSign = '+') + val removedSize = (-diff.removed.size).toDiffString(zeroSign = '-') + row(diff.oldCount, diff.newCount, "$diffSize ($addedSize $removedSize)") + } .renderText() ) if (diff.added.isNotEmpty()) { diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/DexDiff.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/DexDiff.kt index 15bdd38b..887f654b 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/DexDiff.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/DexDiff.kt @@ -35,87 +35,86 @@ internal class DexDiff(val oldDexes: List, val newDexes: List) : Binar override fun toTextReport(summaryOnly: Boolean): Report = DexDiffTextReport(this, summaryOnly) } -internal fun DexDiff.toSummaryTable() = - diffuseTable { - header { - if (isMultidex) { - row { - cell("DEX") { - rowSpan = 2 - alignment = BottomLeft - } - cell("raw") { - columnSpan = 3 - alignment = BottomCenter - } - cell("unique") { - columnSpan = 4 - alignment = BottomCenter - } - } +internal fun DexDiff.toSummaryTable() = diffuseTable { + header { + if (isMultidex) { + row { + cell("DEX") { + rowSpan = 2 + alignment = BottomLeft } - row { - if (!isMultidex) { - cell("DEX") - } else { - cell("old") - cell("new") - cell("diff") - } - cell("old") - cell("new") - cell("diff") { columnSpan = 2 } + cell("raw") { + columnSpan = 3 + alignment = BottomCenter } + cell("unique") { + columnSpan = 4 + alignment = BottomCenter + } + } + } + row { + if (!isMultidex) { + cell("DEX") + } else { + cell("old") + cell("new") + cell("diff") } + cell("old") + cell("new") + cell("diff") { columnSpan = 2 } + } + } - body { - cellStyle { alignment = MiddleRight } + body { + cellStyle { alignment = MiddleRight } - row { - cell("files") - cell(oldDexes.size) - cell(newDexes.size) - cell((newDexes.size - oldDexes.size).toDiffString()) { - if (!isMultidex) { - borderRight = false - } - } - if (isMultidex) { - // Add empty cells to ensure borders get drawn - cell("") - cell("") - cell("") { columnSpan = 2 } - } + row { + cell("files") + cell(oldDexes.size) + cell(newDexes.size) + cell((newDexes.size - oldDexes.size).toDiffString()) { + if (!isMultidex) { + borderRight = false } + } + if (isMultidex) { + // Add empty cells to ensure borders get drawn + cell("") + cell("") + cell("") { columnSpan = 2 } + } + } - fun addDexRow(name: String, diff: ComponentDiff<*>) = row { - cell(name) - if (isMultidex) { - cell(diff.oldRawCount) - cell(diff.newRawCount) - cell((diff.newRawCount - diff.oldRawCount).toDiffString()) - } - cell(diff.oldCount) - cell(diff.newCount) - cell((diff.added.size - diff.removed.size).toDiffString()) { borderRight = false } - - val addedSize = diff.added.size.toDiffString(zeroSign = '+') - val removedSize = (-diff.removed.size).toDiffString(zeroSign = '-') - cell("($addedSize $removedSize)") { - borderLeft = false - paddingLeft = 0 - alignment = MiddleLeft - } - } + fun addDexRow(name: String, diff: ComponentDiff<*>) = row { + cell(name) + if (isMultidex) { + cell(diff.oldRawCount) + cell(diff.newRawCount) + cell((diff.newRawCount - diff.oldRawCount).toDiffString()) + } + cell(diff.oldCount) + cell(diff.newCount) + cell((diff.added.size - diff.removed.size).toDiffString()) { borderRight = false } - addDexRow("strings", strings) - addDexRow("types", types) - addDexRow("classes", classes) - addDexRow("methods", methods) - addDexRow("fields", fields) + val addedSize = diff.added.size.toDiffString(zeroSign = '+') + val removedSize = (-diff.removed.size).toDiffString(zeroSign = '-') + cell("($addedSize $removedSize)") { + borderLeft = false + paddingLeft = 0 + alignment = MiddleLeft } } - .renderText() + + addDexRow("strings", strings) + addDexRow("types", types) + addDexRow("classes", classes) + addDexRow("methods", methods) + addDexRow("fields", fields) + } +} + .renderText() internal fun DexDiff.toDetailReport() = buildString { appendComponentDiff("STRINGS", strings) diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/JarsDiff.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/JarsDiff.kt index b402e235..39ceb4cf 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/JarsDiff.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/JarsDiff.kt @@ -36,42 +36,41 @@ internal class JarsDiff( val changed = bytecodeVersions.changed || methods.changed || fields.changed } -internal fun JarsDiff.toSummaryTable(name: String) = - diffuseTable { - header { - row { - cell(name) - cell("old") - cell("new") - cell("diff") { columnSpan = 2 } - } - } - - body { - cellStyle { alignment = MiddleRight } +internal fun JarsDiff.toSummaryTable(name: String) = diffuseTable { + header { + row { + cell(name) + cell("old") + cell("new") + cell("diff") { columnSpan = 2 } + } + } - fun addRow(name: String, diff: ComponentDiff<*>) = row { - cell(name) - cell(diff.oldCount) - cell(diff.newCount) - cell((diff.added.size - diff.removed.size).toDiffString()) { borderRight = false } + body { + cellStyle { alignment = MiddleRight } - val addedSize = diff.added.size.toDiffString(zeroSign = '+') - val removedSize = (-diff.removed.size).toDiffString(zeroSign = '-') - cell("($addedSize $removedSize)") { - borderLeft = false - paddingLeft = 0 - alignment = MiddleLeft - } - } + fun addRow(name: String, diff: ComponentDiff<*>) = row { + cell(name) + cell(diff.oldCount) + cell(diff.newCount) + cell((diff.added.size - diff.removed.size).toDiffString()) { borderRight = false } - // TODO addRow("strings", strings)? - addRow("classes", classes) - addRow("methods", methods) - addRow("fields", fields) + val addedSize = diff.added.size.toDiffString(zeroSign = '+') + val removedSize = (-diff.removed.size).toDiffString(zeroSign = '-') + cell("($addedSize $removedSize)") { + borderLeft = false + paddingLeft = 0 + alignment = MiddleLeft } } - .renderText() + + // TODO addRow("strings", strings)? + addRow("classes", classes) + addRow("methods", methods) + addRow("fields", fields) + } +} + .renderText() internal fun JarsDiff.toDetailReport() = buildString { // TODO appendComponentDiff("STRINGS", strings)? diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArchiveFilesInfo.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArchiveFilesInfo.kt index 21b76875..8a0a9a4e 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArchiveFilesInfo.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArchiveFilesInfo.kt @@ -13,47 +13,46 @@ internal fun ArchiveFiles.toSummaryTable( displayTypes: List, skipIfEmptyTypes: Set = emptySet(), includeCompressed: Boolean = true, -) = - diffuseTable { - header { - if (includeCompressed) { - row { - cell(name) { alignment = TextAlignment.BottomLeft } - cell("compressed") { alignment = TextAlignment.BottomCenter } - cell("uncompressed") { alignment = TextAlignment.BottomCenter } - } - } else { - row { - cell(name) { alignment = TextAlignment.BottomLeft } - cell("size") - } - } +) = diffuseTable { + header { + if (includeCompressed) { + row { + cell(name) { alignment = TextAlignment.BottomLeft } + cell("compressed") { alignment = TextAlignment.BottomCenter } + cell("uncompressed") { alignment = TextAlignment.BottomCenter } } - - fun TableSectionDsl.addApkRow(name: String, type: ArchiveFile.Type? = null) { - val old = if (type != null) filterValues { it.type == type } else this@toSummaryTable - val oldSize = old.values.fold(0.binaryBytes) { acc, file -> acc + file.size } - val oldUncompressedSize = - old.values.fold(0.binaryBytes) { acc, file -> acc + file.uncompressedSize } - if (oldSize != 0.binaryBytes || type !in skipIfEmptyTypes) { - if (includeCompressed) { - row(name, oldSize, oldUncompressedSize) - } else { - row(name, oldUncompressedSize) - } - } + } else { + row { + cell(name) { alignment = TextAlignment.BottomLeft } + cell("size") } + } + } - body { - cellStyle { alignment = TextAlignment.MiddleRight } - for (type in displayTypes) { - addApkRow(type.displayName, type) - } + fun TableSectionDsl.addApkRow(name: String, type: ArchiveFile.Type? = null) { + val old = if (type != null) filterValues { it.type == type } else this@toSummaryTable + val oldSize = old.values.fold(0.binaryBytes) { acc, file -> acc + file.size } + val oldUncompressedSize = + old.values.fold(0.binaryBytes) { acc, file -> acc + file.uncompressedSize } + if (oldSize != 0.binaryBytes || type !in skipIfEmptyTypes) { + if (includeCompressed) { + row(name, oldSize, oldUncompressedSize) + } else { + row(name, oldUncompressedSize) } + } + } - footer { - cellStyle { alignment = TextAlignment.MiddleRight } - addApkRow("total") - } + body { + cellStyle { alignment = TextAlignment.MiddleRight } + for (type in displayTypes) { + addApkRow(type.displayName, type) } - .renderText() + } + + footer { + cellStyle { alignment = TextAlignment.MiddleRight } + addApkRow("total") + } +} + .renderText() diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArscInfo.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArscInfo.kt index 7b40bc6b..c3e20070 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArscInfo.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/info/ArscInfo.kt @@ -5,15 +5,14 @@ import com.jakewharton.diffuse.format.Arsc import com.jakewharton.picnic.TextAlignment import com.jakewharton.picnic.renderText -internal fun Arsc.toSummaryTable() = - diffuseTable { - header { row("ARSC", "count") } +internal fun Arsc.toSummaryTable() = diffuseTable { + header { row("ARSC", "count") } - body { - cellStyle { alignment = TextAlignment.MiddleRight } + body { + cellStyle { alignment = TextAlignment.MiddleRight } - row("configs", configs.size) - row("entries", entries.size) - } - } - .renderText() + row("configs", configs.size) + row("entries", entries.size) + } +} + .renderText() diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/info/DexesInfo.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/info/DexesInfo.kt index 99094acc..2078968e 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/info/DexesInfo.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/info/DexesInfo.kt @@ -7,47 +7,46 @@ import com.jakewharton.diffuse.format.Method import com.jakewharton.picnic.TextAlignment import com.jakewharton.picnic.renderText -internal fun List.toSummaryTable() = - diffuseTable { - val isMultidex = size > 1 +internal fun List.toSummaryTable() = diffuseTable { + val isMultidex = size > 1 - header { - row { - cell("DEX") { alignment = TextAlignment.BottomLeft } - if (isMultidex) { - cell("raw") - cell("unique") - } else { - cell("count") - } - } + header { + row { + cell("DEX") { alignment = TextAlignment.BottomLeft } + if (isMultidex) { + cell("raw") + cell("unique") + } else { + cell("count") } + } + } - body { - cellStyle { alignment = TextAlignment.MiddleRight } - - row { - cell("files") - cell(size) - if (isMultidex) { - // Add empty cell to ensure borders get drawn - cell("") - } - } + body { + cellStyle { alignment = TextAlignment.MiddleRight } - fun addDexRow(name: String, selector: (Dex) -> List) = row { - cell(name) - if (isMultidex) { - cell(sumOf { selector(it).size }) - } - cell(flatMapTo(LinkedHashSet(), selector).size) - } + row { + cell("files") + cell(size) + if (isMultidex) { + // Add empty cell to ensure borders get drawn + cell("") + } + } - addDexRow("strings") { it.strings } - addDexRow("types") { it.types } - addDexRow("classes") { it.classes } - addDexRow("methods") { it.members.filterIsInstance() } - addDexRow("fields") { it.members.filterIsInstance() } + fun addDexRow(name: String, selector: (Dex) -> List) = row { + cell(name) + if (isMultidex) { + cell(sumOf { selector(it).size }) } + cell(flatMapTo(LinkedHashSet(), selector).size) } - .renderText() + + addDexRow("strings") { it.strings } + addDexRow("types") { it.types } + addDexRow("classes") { it.classes } + addDexRow("methods") { it.members.filterIsInstance() } + addDexRow("fields") { it.members.filterIsInstance() } + } +} + .renderText() diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/info/JarsInfo.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/info/JarsInfo.kt index d8248b6a..9aca19e2 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/info/JarsInfo.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/info/JarsInfo.kt @@ -7,21 +7,20 @@ import com.jakewharton.diffuse.format.Method import com.jakewharton.picnic.TextAlignment import com.jakewharton.picnic.renderText -internal fun List.toSummaryTable(name: String) = - diffuseTable { - header { row(name, "count") } +internal fun List.toSummaryTable(name: String) = diffuseTable { + header { row(name, "count") } - body { - cellStyle { alignment = TextAlignment.MiddleRight } + body { + cellStyle { alignment = TextAlignment.MiddleRight } - fun addRow(name: String, selector: (Jar) -> List) { - row(name, flatMap(selector).size) - } - - // TODO addRow("strings", strings)? - addRow("classes", Jar::classes) - addRow("methods") { it.members.filterIsInstance() } - addRow("fields") { it.members.filterIsInstance() } - } + fun addRow(name: String, selector: (Jar) -> List) { + row(name, flatMap(selector).size) } - .renderText() + + // TODO addRow("strings", strings)? + addRow("classes", Jar::classes) + addRow("methods") { it.members.filterIsInstance() } + addRow("fields") { it.members.filterIsInstance() } + } +} + .renderText() diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabDiffTextReport.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabDiffTextReport.kt index e5bd4b27..f8ad37aa 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabDiffTextReport.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabDiffTextReport.kt @@ -21,31 +21,31 @@ internal class AabDiffTextReport(private val aabDiff: AabDiff, private val summa appendLine() appendLine( diffuseTable { - cellStyle { alignment = MiddleCenter } - - header { - cellStyle { alignment = BottomLeft } - row { - cell("MODULES") - cell("old") - cell("new") - } - } + cellStyle { alignment = MiddleCenter } + header { + cellStyle { alignment = BottomLeft } row { - cell("base") { alignment = MiddleRight } - cell("✓") - cell("✓") + cell("MODULES") + cell("old") + cell("new") } + } - for (name in aabDiff.featureModuleNames) { - row { - cell(name) { alignment = MiddleRight } - cell(if (name in aabDiff.oldAab.featureModules) "✓" else "") - cell(if (name in aabDiff.newAab.featureModules) "✓" else "") - } + row { + cell("base") { alignment = MiddleRight } + cell("✓") + cell("✓") + } + + for (name in aabDiff.featureModuleNames) { + row { + cell(name) { alignment = MiddleRight } + cell(if (name in aabDiff.oldAab.featureModules) "✓" else "") + cell(if (name in aabDiff.newAab.featureModules) "✓" else "") } } + } .toString() ) diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabInfoTextReport.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabInfoTextReport.kt index d39a1ab2..ea8afaf9 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabInfoTextReport.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/AabInfoTextReport.kt @@ -13,14 +13,14 @@ internal class AabInfoTextReport(private val aab: Aab) : Report { appendLine() appendLine( diffuseTable { - header { row("MODULES") } + header { row("MODULES") } - row("base") + row("base") - for (name in aab.featureModules.keys) { - row(name) - } + for (name in aab.featureModules.keys) { + row(name) } + } .toString() ) diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/ApkDiffTextReport.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/ApkDiffTextReport.kt index 8c55aa09..36dfef51 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/ApkDiffTextReport.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/report/text/ApkDiffTextReport.kt @@ -29,25 +29,25 @@ internal class ApkDiffTextReport(private val apkDiff: ApkDiff, private val summa if (apkDiff.lintMessages.isNotEmpty()) { appendLine( diffuseTable { - header { row("NOTICES") } - body { - apkDiff.lintMessages.sorted().forEach { notice -> - row( - buildString { - append( - when (notice.type) { - Notice.Type.Informational -> 'i' - Notice.Type.Warning -> '!' - Notice.Type.Resolution -> '✓' - } - ) - append(" ") - append(notice.message) - } - ) - } + header { row("NOTICES") } + body { + apkDiff.lintMessages.sorted().forEach { notice -> + row( + buildString { + append( + when (notice.type) { + Notice.Type.Informational -> 'i' + Notice.Type.Warning -> '!' + Notice.Type.Resolution -> '✓' + } + ) + append(" ") + append(notice.message) + } + ) } } + } .toString() ) appendLine()