Skip to content

Commit a00d129

Browse files
Add assets folder check for oversized images
- Add support for checking assets folder in ResourceAnalysisTask - Add 1.1MB oversized image example to test-app/assets - This triggers the Oversized Image detection in resource analysis Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 71994b1 commit a00d129

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/main/kotlin/com/davideagostini/analyzer/tasks/ResourceAnalysisTask.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ open class ResourceAnalysisTask : DefaultTask() {
160160
"src/main/res/mipmap-xxhdpi"
161161
)
162162

163+
// Also check assets folder for oversized images
164+
val assetsDir = project.file("src/main/assets")
165+
163166
val maxSizeBytes = 1024L * 1024L
164167

165168
drawableDirs.forEach { dirPath ->
@@ -180,6 +183,23 @@ open class ResourceAnalysisTask : DefaultTask() {
180183
}
181184
}
182185
}
186+
187+
// Check assets folder for oversized image files
188+
if (assetsDir.exists()) {
189+
assetsDir.walkTopDown().filter {
190+
it.extension in listOf("png", "jpg", "jpeg", "webp", "gif")
191+
}.filter { it.length() > maxSizeBytes }.forEach { file ->
192+
findings.add(
193+
ResourceFinding(
194+
type = ResourceIssueType.OVERSIZED_IMAGE,
195+
severity = Severity.MEDIUM,
196+
resourceName = file.name,
197+
message = "Image file exceeds 1MB (${formatSize(file.length())})",
198+
location = file.relativeTo(project.rootDir).path
199+
)
200+
)
201+
}
202+
}
183203
}
184204

185205
private fun formatSize(bytes: Long): String {
1.07 MB
Loading
-1.07 MB
Binary file not shown.

0 commit comments

Comments
 (0)