Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[flutter_plugin_tools] Add a command to lint Android code (#4206)
Browse files Browse the repository at this point in the history
Adds a new `lint-android` command to run `gradlew lint` on Android plugins.

Also standardizes the names of the Cirrus tasks that run all the build and platform-specific (i.e., not Dart unit test) tests for each platform, as they were getting unnecessarily long and complex in some cases.

Fixes flutter/flutter#87071
  • Loading branch information
stuartmorgan authored Aug 18, 2021
1 parent 90fd90e commit af2896b
Show file tree
Hide file tree
Showing 60 changed files with 1,306 additions and 47 deletions.
23 changes: 18 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ task:
setup_script:
- flutter config --enable-linux-desktop
<< : *BUILD_ALL_PLUGINS_APP_TEMPLATE
- name: build-linux+drive-examples
- name: linux-build+platform-tests
env:
matrix:
CHANNEL: "master"
Expand All @@ -146,7 +146,7 @@ task:
memory: 12G
matrix:
### Android tasks ###
- name: build-apks+android-unit+firebase-test-lab
- name: android-build+platform-tests
env:
matrix:
PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4"
Expand All @@ -165,6 +165,13 @@ task:
- export CIRRUS_CHANGE_MESSAGE=""
- export CIRRUS_COMMIT_MESSAGE=""
- ./script/tool_runner.sh build-examples --apk
lint_script:
# Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they
# might include non-ASCII characters which makes Gradle crash.
# TODO(stuartmorgan): See https://github.com/flutter/flutter/issues/24935
- export CIRRUS_CHANGE_MESSAGE=""
- export CIRRUS_COMMIT_MESSAGE=""
- ./script/tool_runner.sh lint-android # must come after build-examples
native_unit_test_script:
# Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they
# might include non-ASCII characters which makes Gradle crash.
Expand All @@ -186,8 +193,14 @@ task:
- else
- echo "This user does not have permission to run Firebase Test Lab tests."
- fi
# Upload the full lint results to Cirrus to display in the results UI.
always:
android-lint_artifacts:
path: "**/reports/lint-results-debug.xml"
type: text/xml
format: android-lint
### Web tasks ###
- name: build-web+drive-examples
- name: web-build+platform-tests
env:
matrix:
CHANNEL: "master"
Expand Down Expand Up @@ -220,7 +233,7 @@ task:
CHANNEL: "master"
CHANNEL: "stable"
<< : *BUILD_ALL_PLUGINS_APP_TEMPLATE
- name: build-ipas+drive-examples
- name: ios-build+platform-tests
env:
PATH: $PATH:/usr/local/bin
matrix:
Expand Down Expand Up @@ -256,7 +269,7 @@ task:
setup_script:
- flutter config --enable-macos-desktop
<< : *BUILD_ALL_PLUGINS_APP_TEMPLATE
- name: build-macos+drive-examples
- name: macos-build+platform-tests
env:
matrix:
CHANNEL: "master"
Expand Down
1 change: 1 addition & 0 deletions packages/android_alarm_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT

* Remove support for the V1 Android embedding.
* Updated Android lint settings.

## 2.0.2

Expand Down
2 changes: 2 additions & 0 deletions packages/android_alarm_manager/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ android {
}
lintOptions {
disable 'InvalidPackage'
disable 'GradleDependency'
baseline file("lint-baseline.xml")
}


Expand Down
59 changes: 59 additions & 0 deletions packages/android_alarm_manager/android/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 3.3.0" client="gradle" variant="debug" version="3.3.0">

<issue
id="LongLogTag"
message="The logging tag can be at most 23 characters, was 25 (AndroidAlarmManagerPlugin)"
errorLine1=" Log.i(TAG, &quot;onAttachedToEngine&quot;);"
errorLine2=" ~~~">
<location
file="src/main/java/io/flutter/plugins/androidalarmmanager/AndroidAlarmManagerPlugin.java"
line="75"
column="13"/>
</issue>

<issue
id="LongLogTag"
message="The logging tag can be at most 23 characters, was 25 (AndroidAlarmManagerPlugin)"
errorLine1=" Log.i(TAG, &quot;onDetachedFromEngine&quot;);"
errorLine2=" ~~~">
<location
file="src/main/java/io/flutter/plugins/androidalarmmanager/AndroidAlarmManagerPlugin.java"
line="96"
column="11"/>
</issue>

<issue
id="LongLogTag"
message="The logging tag can be at most 23 characters, was 25 (FlutterBackgroundExecutor)"
errorLine1=" Log.e(TAG, &quot;Background isolate already started&quot;);"
errorLine2=" ~~~">
<location
file="src/main/java/io/flutter/plugins/androidalarmmanager/FlutterBackgroundExecutor.java"
line="130"
column="13"/>
</issue>

<issue
id="LongLogTag"
message="The logging tag can be at most 23 characters, was 25 (FlutterBackgroundExecutor)"
errorLine1=" Log.i(TAG, &quot;Starting AlarmService...&quot;);"
errorLine2=" ~~~">
<location
file="src/main/java/io/flutter/plugins/androidalarmmanager/FlutterBackgroundExecutor.java"
line="134"
column="11"/>
</issue>

<issue
id="StaticFieldLeak"
message="Do not place Android context classes in static fields (static reference to `AndroidAlarmManagerPlugin` which has field `context` pointing to `Context`); this is a memory leak (and also breaks Instant Run)"
errorLine1=" private static AndroidAlarmManagerPlugin instance;"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/androidalarmmanager/AndroidAlarmManagerPlugin.java"
line="43"
column="11"/>
</issue>

</issues>
1 change: 1 addition & 0 deletions packages/android_intent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT

* Remove references to the V1 Android embedding.
* Updated Android lint settings.

## 2.0.2

Expand Down
1 change: 1 addition & 0 deletions packages/android_intent/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android {
}
lintOptions {
disable 'InvalidPackage'
disable 'GradleDependency'
}


Expand Down
1 change: 1 addition & 0 deletions packages/battery/battery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT

* Remove references to the Android v1 embedding.
* Updated Android lint settings.

## 2.0.3

Expand Down
1 change: 1 addition & 0 deletions packages/battery/battery/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ android {
}
lintOptions {
disable 'InvalidPackage'
disable 'GradleDependency'
}


Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Updated Android lint settings.

## 0.8.1+7

* Fix device orientation sometimes not affecting the camera preview orientation.
Expand Down
2 changes: 2 additions & 0 deletions packages/camera/camera/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ android {
}
lintOptions {
disable 'InvalidPackage'
disable 'GradleDependency'
baseline file("lint-baseline.xml")
}
compileOptions {
sourceCompatibility = '1.8'
Expand Down
114 changes: 114 additions & 0 deletions packages/camera/camera/android/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 3.5.0" client="gradle" variant="debug" version="3.5.0">

<issue
id="Assert"
message="Assertions are unreliable in Dalvik and unimplemented in ART. Use `BuildConfig.DEBUG` conditional checks instead."
errorLine1=" assert (boundaries.getWidth() > 0 &amp;&amp; boundaries.getHeight() > 0);"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraRegionUtils.java"
line="73"
column="5"/>
</issue>

<issue
id="Assert"
message="Assertions are unreliable in Dalvik and unimplemented in ART. Use `BuildConfig.DEBUG` conditional checks instead."
errorLine1=" assert (x >= 0 &amp;&amp; x &lt;= 1);"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraRegionUtils.java"
line="74"
column="5"/>
</issue>

<issue
id="Assert"
message="Assertions are unreliable in Dalvik and unimplemented in ART. Use `BuildConfig.DEBUG` conditional checks instead."
errorLine1=" assert (y >= 0 &amp;&amp; y &lt;= 1);"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraRegionUtils.java"
line="75"
column="5"/>
</issue>

<issue
id="Assert"
message="Assertions are unreliable in Dalvik and unimplemented in ART. Use `BuildConfig.DEBUG` conditional checks instead."
errorLine1=" assert (maxBoundaries == null || maxBoundaries.getWidth() > 0);"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraRegions.java"
line="16"
column="5"/>
</issue>

<issue
id="Assert"
message="Assertions are unreliable in Dalvik and unimplemented in ART. Use `BuildConfig.DEBUG` conditional checks instead."
errorLine1=" assert (maxBoundaries == null || maxBoundaries.getHeight() > 0);"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraRegions.java"
line="17"
column="5"/>
</issue>

<issue
id="Assert"
message="Assertions are unreliable in Dalvik and unimplemented in ART. Use `BuildConfig.DEBUG` conditional checks instead."
errorLine1=" assert (x >= 0 &amp;&amp; x &lt;= 1);"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraRegions.java"
line="50"
column="5"/>
</issue>

<issue
id="Assert"
message="Assertions are unreliable in Dalvik and unimplemented in ART. Use `BuildConfig.DEBUG` conditional checks instead."
errorLine1=" assert (y >= 0 &amp;&amp; y &lt;= 1);"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraRegions.java"
line="51"
column="5"/>
</issue>

<issue
id="SwitchIntDef"
message="Switch statement on an `int` with known associated constant missing case `Configuration.ORIENTATION_SQUARE`, `Configuration.ORIENTATION_UNDEFINED`"
errorLine1=" switch (orientation) {"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/DeviceOrientationManager.java"
line="143"
column="5"/>
</issue>

<issue
id="SwitchIntDef"
message="Switch statement on an `int` with known associated constant missing case `Configuration.ORIENTATION_SQUARE`, `Configuration.ORIENTATION_UNDEFINED`"
errorLine1=" switch (orientation) {"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/features/sensororientation/DeviceOrientationManager.java"
line="264"
column="5"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is never &lt; 21"
errorLine1=" if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.LOLLIPOP) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/camera/CameraPlugin.java"
line="102"
column="9"/>
</issue>

</issues>
1 change: 1 addition & 0 deletions packages/connectivity/connectivity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT

* Remove references to the Android V1 embedding.
* Updated Android lint settings.

## 3.0.6

Expand Down
1 change: 1 addition & 0 deletions packages/connectivity/connectivity/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android {
}
lintOptions {
disable 'InvalidPackage'
disable 'GradleDependency'
}


Expand Down
1 change: 1 addition & 0 deletions packages/device_info/device_info/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT

* Remove references to the Android V1 embedding.
* Updated Android lint settings.

## 2.0.2

Expand Down
1 change: 1 addition & 0 deletions packages/device_info/device_info/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ android {
}
lintOptions {
disable 'InvalidPackage'
disable 'GradleDependency'
}


Expand Down
4 changes: 4 additions & 0 deletions packages/espresso/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Updated Android lint settings.

## 0.1.0+3

* Remove references to the Android v1 embedding.
Expand Down
2 changes: 2 additions & 0 deletions packages/espresso/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ android {
}
lintOptions {
disable 'InvalidPackage'
disable 'GradleDependency'
baseline file("lint-baseline.xml")
}


Expand Down
Loading

0 comments on commit af2896b

Please sign in to comment.