-
-
Notifications
You must be signed in to change notification settings - Fork 133
feat: detect and report all Android resource references in Manifest files #1450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: detect and report all Android resource references in Manifest files #1450
Conversation
} | ||
|
||
private fun parse(manifest: String, dslNamespace: String = ""): ManifestParser.ParseResult { | ||
private fun parse(@Language("XML") manifest: String, dslNamespace: String = ""): ManifestParser.ParseResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this for syntax highlighting in the IDE
@@ -18,8 +19,8 @@ internal class ManifestParser( | |||
val packageName: String, | |||
/** The value of the `android:name` attribute. May be empty. */ | |||
val applicationName: String, | |||
/** The values of the `android:theme` attributes of application and activities. May be empty. */ | |||
val themes: Set<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merge the themes
inside a generic attrRefs
.
Also, I parsed it directly as AndroidResSource.AttrRef
to make tests more expressive (instead of in explodeAndroidResSource.kt
).
@@ -162,7 +161,7 @@ internal data class AndroidResSource( | |||
* | |||
* @see <a href="https://developer.android.com/guide/topics/resources/providing-resources#ResourcesFromXml">Accessing resources from XML</a> | |||
*/ | |||
private val TYPE_REGEX = Regex("""@(\w+:)?(?<type>\w+)/(\w+)""") | |||
private val TYPE_REGEX = Regex("""@(\w+:)?(?<type>\w+)/([\w.]+)""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
are actually used for styles/themes, otherwise it breaks detects theme set in manifest
and detects theme set in manifest on Activity
tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also added a unit test for this.
@@ -150,26 +152,60 @@ class ManifestParserTest { | |||
assertThat(manifest.applicationName).isEqualTo("mutual.aid.explode") | |||
} | |||
|
|||
@Test fun `parse themes`() { | |||
@Test fun `parse resource references`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this test, I added common references that we are using in our own app. This is definitely not an exhaustive list of all places where references are allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why it took me so long to get to this - sorry about that. This looks good, but there are some conflicts. Do you mind resolving? Happy to merge once that is done.
@autonomousapps i've resolved the conflicts 🫡 Edit: talked too soon, let me take care of the compilation issues. |
No description provided.