Skip to content

Commit

Permalink
add enabled property to lint options
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadkahelghi-grabtaxi committed Mar 11, 2024
1 parent 3ce0892 commit e05e0f8
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 5 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "grab_bazel_common",
commit = "1e751cfd185fd205555f50a5ea6e6c1b52dcdc63",
commit = "fe47feaee47d9f872514d29ca4ac4c462e1811eb",
remote = "https://github.com/grab/grab-bazel-common.git",
)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ grazel {
rules {
bazelCommon {
gitRepository {
commit = "1e751cfd185fd205555f50a5ea6e6c1b52dcdc63"
commit = "fe47feaee47d9f872514d29ca4ac4c462e1811eb"
remote = "https://github.com/grab/grab-bazel-common.git"
}
toolchains {
Expand Down
2 changes: 1 addition & 1 deletion constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
ext {
groupId = "com.grab.grazel"
versionName = "0.4.1-alpha.22"
versionName = "0.4.1-alpha.23"

website = "https://grab.github.io/Grazel/"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@

package com.grab.grazel.bazel.starlark

data class LintConfigs(val configPath: String? = null, val baselinePath: String? = null) {
data class LintConfigs(
val enabled: Boolean = true,
val configPath: String? = null,
val baselinePath: String? = null
) {
val merged: Map<String, String> = mapOf(
"enabled" to enabled.toString(),
"config" to configPath,
"baseline" to baselinePath
).filterValues { it != null } as Map<String, String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ private fun lintConfigs(
lintOptions: LintOptions,
project: Project
): LintConfigs {
// enable lint for all targets by default
val enabled = true

val configPath = if (lintOptions.lintConfig?.absolutePath != null) {
project.relativePath(lintOptions.lintConfig!!.absolutePath)
} else {
Expand All @@ -177,7 +180,7 @@ private fun lintConfigs(
} else {
null
}
return LintConfigs(configPath, baseLinePath)
return LintConfigs(enabled, configPath, baseLinePath)
}

internal interface AndroidBinaryDataExtractor : AndroidExtractor<AndroidBinaryData>
Expand Down
12 changes: 12 additions & 0 deletions sample-android-flavor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ android_library(
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
res_values = {
"strings": {
Expand Down Expand Up @@ -44,6 +47,9 @@ android_library(
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
res_values = {
"strings": {
Expand Down Expand Up @@ -79,6 +85,9 @@ android_library(
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
res_values = {
"strings": {
Expand Down Expand Up @@ -114,6 +123,9 @@ android_library(
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
res_values = {
"strings": {
Expand Down
12 changes: 12 additions & 0 deletions sample-android-library/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ android_library(
]),
custom_package = "com.grab.grazel.android.sample.lib",
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
visibility = [
"//visibility:public",
Expand All @@ -23,6 +26,9 @@ android_library(
]),
custom_package = "com.grab.grazel.android.sample.lib",
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
visibility = [
"//visibility:public",
Expand All @@ -39,6 +45,9 @@ android_library(
]),
custom_package = "com.grab.grazel.android.sample.lib",
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
visibility = [
"//visibility:public",
Expand All @@ -55,6 +64,9 @@ android_library(
]),
custom_package = "com.grab.grazel.android.sample.lib",
enable_data_binding = True,
lint_options = {
"enabled": "true",
},
manifest = "src/main/AndroidManifest.xml",
visibility = [
"//visibility:public",
Expand Down
4 changes: 4 additions & 0 deletions sample-android/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android_binary(
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"enabled": "true",
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
Expand Down Expand Up @@ -125,6 +126,7 @@ android_binary(
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"enabled": "true",
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
Expand Down Expand Up @@ -215,6 +217,7 @@ android_binary(
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"enabled": "true",
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
Expand Down Expand Up @@ -305,6 +308,7 @@ android_binary(
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"enabled": "true",
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
Expand Down
44 changes: 44 additions & 0 deletions sample-android/lint_baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
column="13"/>
</issue>

<issue
id="MissingVersion"
message="Should set `android:versionCode` to specify the application version"
errorLine1="&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;"
errorLine2=" ~~~~~~~~">
<location
file="../../../../../sample-android/src/debug/AndroidManifest.xml"
line="17"
column="2"/>
</issue>

<issue
id="MissingVersion"
message="Should set `android:versionName` to specify the application version"
errorLine1="&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;"
errorLine2=" ~~~~~~~~">
<location
file="../../../../../sample-android/src/debug/AndroidManifest.xml"
line="17"
column="2"/>
</issue>

<issue
id="Typos"
message="Did you mean &quot;flavor!&quot; instead of &quot;flavor1&quot;?">
Expand All @@ -21,6 +43,28 @@
column="37"/>
</issue>

<issue
id="UnusedResources"
message="The resource `R.string.type` appears to be unused"
errorLine1=" &lt;string name=&quot;type&quot;>debug&lt;/string>"
errorLine2=" ~~~~~~~~~~~">
<location
file="../../../../android-armeabi-v7a-fastbuild/bin/sample-android/src/main/res/values/gen_strings_sample-android-flavor1-free-debug_res_value.xml"
line="4"
column="17"/>
</issue>

<issue
id="UnusedResources"
message="The resource `R.string.flavor` appears to be unused"
errorLine1=" &lt;string name=&quot;flavor&quot;>free&lt;/string>"
errorLine2=" ~~~~~~~~~~~~~">
<location
file="../../../../android-armeabi-v7a-fastbuild/bin/sample-android/src/main/res/values/gen_strings_sample-android-flavor1-free-debug_res_value.xml"
line="5"
column="17"/>
</issue>

<issue
id="MonochromeLauncherIcon"
message="The application adaptive icon is missing a monochrome tag"
Expand Down

0 comments on commit e05e0f8

Please sign in to comment.