Skip to content

[ci+various] Partially enable javac warning checks #3293

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

Merged

Conversation

stuartmorgan-g
Copy link
Contributor

Since our existing gradlew lint check doesn't catch all warnings (notably, deprecation warnings, but also others like raw values), this:

  • Configures our plugin example apps to enable -Xlint:all -Werror for the javac for the plugin project, so that we also get javac lint coverage in CI. This is done in the example app so that it won't affect plugin clients.
  • Adds a check to lint-android that the example is configured this way, so that we don't forget to set it up when adding new plugins (or re-generating plugin examples from template).

Where it was trivial for me to just fix existing violations, I did so in this PR. For the rest that had violations, I commented out the enabling of the flags, with a TODO. Normally we would do this kind of thing with a script/configs file to opt packages out of a new check, but since this is part of an existing check rather than a whole new command, doing it that way would disable gradlew lint for those packages as well. Making a whole new command seemed more complex for the long term, so this seemed like the best short term option. We should try to remove as many of these opt-outs as possible ASAP.

Part of flutter/flutter#91868

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

Camera camera =
processCameraProvider.bindToLifecycle(
(LifecycleOwner) lifecycleOwner, cameraSelector, useCases);
Camera camera = processCameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, useCases);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes an unnecessary cast warning.

@@ -25,7 +25,6 @@
import com.google.android.gms.maps.model.RoundCap;
import com.google.android.gms.maps.model.SquareCap;
import com.google.android.gms.maps.model.Tile;
import io.flutter.view.FlutterMain;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick research suggested that there's no good way to suppress the deprecation warning this line creates, so I fully qualified the names instead.

@@ -29,12 +29,6 @@
import java.util.Map;
import java.util.UUID;

enum CameraDevice {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a warning about referencing a class other that the main class (I forget the actual term in the warning) from another file.

Double maxWidth = (Double) resultMap.get(cache.MAP_KEY_MAX_WIDTH);
Double maxHeight = (Double) resultMap.get(cache.MAP_KEY_MAX_HEIGHT);
Double maxWidth = (Double) resultMap.get(ImagePickerCache.MAP_KEY_MAX_WIDTH);
Double maxHeight = (Double) resultMap.get(ImagePickerCache.MAP_KEY_MAX_HEIGHT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a warning about referencing static constants via instance.

@@ -26,7 +26,6 @@
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same deprecation issue here.

@stuartmorgan-g
Copy link
Contributor Author

Oops, I forgot to check the native unit tests for warnings. Looks like I'll need to turn it off for more packages for now (but I'll see if any are easily fixable).

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 1, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 1, 2023

auto label is removed for flutter/packages, pr: 3293, due to - The status or check suite android-platform_tests CHANNEL:master PACKAGE_SHARDING:--shardIndex 1 --shardCount 5 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@stuartmorgan-g
Copy link
Contributor Author

Looks like I'll need to fix some new warnings from the image_picker PR that just landed; I'll take a look tomorrow.

@stuartmorgan-g
Copy link
Contributor Author

It turns out that what caused the new warnings was the update to SDK 33, not warnings in the new code. Which means #3271 is probably going to create a lot of new deprecation warnings.

@reidbaker Are you okay with me adding a bunch of suppressions for new deprecation warnings, with TODOs pointing to new issues about writing new code paths for the deprecated code?

@reidbaker
Copy link
Contributor

Yes I am ok with that but it means that when we update to 34 any new warning there will also be a pain :/

@stuartmorgan-g
Copy link
Contributor Author

Isn't that to some extend a feature though? It means we'll find out about deprecated code earlier, and can track what will need to be updated before it becomes an emergency later.

@reidbaker
Copy link
Contributor

Yes it is a feature but it also means that updating compileSdkVersion is no longer "strictly better" if you treat warnings as errors.

@stuartmorgan-g stuartmorgan-g force-pushed the tool-android-javac-warnings branch from 2af1488 to c1a68e2 Compare March 2, 2023 18:23
@stuartmorgan-g
Copy link
Contributor Author

Landing manually; the two in-progress runs look hung, but they are iOS tests so can't be affected by this PR, and this PR is prone to collisions so I'd like to get it landed.

@stuartmorgan-g stuartmorgan-g merged commit 2f21321 into flutter:main Mar 2, 2023
@stuartmorgan-g stuartmorgan-g deleted the tool-android-javac-warnings branch March 2, 2023 19:47
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 3, 2023
sybrands-place pushed a commit to sybrands-place/packages that referenced this pull request Mar 6, 2023
* main: (3910 commits)
  [various] Align Flutter and Dart SDK constraints (flutter#3349)
  Roll Flutter from c590086 to f2f8005 (14 revisions) (flutter#3373)
  [webview_flutter] Enable warnings-as-errors on Android (flutter#3356)
  [ci] Increase Android platform test sharding (flutter#3365)
  Roll Flutter from f032a4d to c590086 (69 revisions) (flutter#3366)
  [Espresso] Update truth package to 1.1.3 (flutter#3358)
  [google_maps] Relax the Android renderer requset test (flutter#3364)
  [pigeon] Only check generated files on master (flutter#3357)
  [webview]: Bump androidx.webkit:webkit from 1.5.0 to 1.6.0 in /packages/webview_flutter/webview_flutter_android/android (flutter#3243)
  [ci+various] Partially enable javac warning checks (flutter#3293)
  [webview_flutter] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3336)
  [local_auth] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3335)
  [google_sign_in] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3330)
  [google_maps_flutter] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3329)
  [video_player] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3328)
  [file_selector] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3325)
  [go_router_builder] Fix the example for default values in the README (flutter#3231)
  Update annotation and espresso dependencies (flutter#3271)
  [tool] Provide a --base-branch flag (flutter#3322)
  [image_picker_android] Adds Android 13 photo picker functionality (flutter#3267)
  ...
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
Since our existing `gradlew lint` check doesn't catch all warnings (notably, deprecation warnings, but also others like raw values), this:
- Configures our plugin example apps to enable `-Xlint:all -Werror` for the javac for the plugin project, so that we also get javac lint coverage in CI. This is done in the example app so that it won't affect plugin clients.
- Adds a check to `lint-android` that the example is configured this way, so that we don't forget to set it up when adding new plugins (or re-generating plugin examples from template).

Where it was trivial for me to just fix existing violations, I did so in this PR. For the rest that had violations, I commented out the enabling of the flags, with a TODO. Normally we would do this kind of thing with a `script/configs` file to opt packages out of a new check, but since this is part of an existing check rather than a whole new command, doing it that way would disable `gradlew lint` for those packages as well. Making a whole new command seemed more complex for the long term, so this seemed like the best short term option. We should try to remove as many of these opt-outs as possible ASAP.

Part of flutter/flutter#91868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants