-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Start of linting Android embedding #8023
Conversation
tools/android_lint/bin/main.dart
Outdated
argParser.addOption( | ||
'in', | ||
help: 'The path to `engine/src`.', | ||
defaultsTo: path.join(path.current), |
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.
You could have it find the default based on the location of the script, using Platform.script
:
final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
This makes it possible to run it from any dir without needing to specify --in
(although you should keep that as an option).
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.
Done with a little twist to make sure it's still relative so that project.xml comes out ok on other systems
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.
LGTM
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.
@@ -0,0 +1,120 @@ | |||
// Copyright 2013 The Flutter Authors. All rights reserved. |
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.
2019?
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'm worried the license checker won't be smart enough to figure out this doesn't impact licensing :(
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.
FYI @gspencergoog @dnfield my understanding is that 2013 should be the year used on all licenses within the embedding.
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.
Nevermind, this file lives somewhere else.
tools/android_lint/bin/main.dart
Outdated
print(result.stdout); | ||
// TODO(dnfield): once we know what a clean lint will look like for this | ||
// project, we should detect it and set the exit code based on it. | ||
// Android Lint does _not_ set the exit code to non-zero if it detects lint |
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.
Whoa. Seems like quite an oversight in the lint tool to not report its results via exit code.
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.
Ah! There's an option for it.
@@ -0,0 +1,81 @@ | |||
<!-- THIS FILE IS GENERATED. PLEASE USE THE INCLUDED DART PROGRAM WHICH --> | |||
<!-- WILL AUTOMATICALLY FIND ALL .java FILES AND INCLUDE THEM HERE --> |
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.
Should you find all Java files, or only the Java files listed in BUILD.gn?
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.
We could use BUILD.gn - in which case we could probably write this as a build rule. I don't really have a strong opinion on that - would we want unlinted files in the repo that aren't part of the build though?
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 guess the question is, why would a Java file exist without being a part of BUILD.gn....and if no such situation can occur, then why not just yank the Java file paths out of BUILD.gn?
import 'package:path/path.dart' as path; | ||
import 'package:process/process.dart'; | ||
|
||
/// Runs the Android SDK Lint tool on flutter/shell/platform/android. |
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.
When will this run? And what will be the impact on the fact that most files will not conform to our desired styles?
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.
Right now it would be run by hand. Longer term we want to run it as part of CI.
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.
If we determine that the linter is suggesting things that violate our desired styles we can turn them off. For now we want to just try to catch as much as we can.
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.
But these aren't being run on PRs are they? What I want to avoid is being forced to make changes to existing files just because I had to alter a constructor argument, etc.
/// At the time of this writing, the Android Lint tool doesn't work well with | ||
/// Java > 1.8. This script will print a warning if you are not running | ||
/// Java 1.8. | ||
Future<void> main(List<String> args) async { |
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.
Can we break this function down? Something like:
request = parseArgs(args);
writeProjectFile(request);
result = runLint();
return result;
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.
More or less done - I could definitely get fancier with this, but right now I just want something that works.
/// Runs the Android SDK Lint tool on flutter/shell/platform/android. | ||
/// | ||
/// This script scans the flutter/shell/platform/android directory for Java | ||
/// files to build a `project.xml` file. This file is then passed to the lint |
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.
Where are the lint rules that are being applied?
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.
Right now all of the default ones and all warnings, which are all getting elevated to errors.
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.
But the linter includes style doesn't it? If so, which of the many flavors of java/Android style is it applying?
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'm also curious where these are actually defined. I don't know any default lint rules off the top of my head.
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.
This is the public doc for it: https://developer.android.com/studio/write/lint
I don't know that it actually checks what we'd be calling style - or certainly not everything in the Java style guide.
LGTM - discussed offline, no PR blockages at this point. |
flutter/engine@f4951df19 (upstream/master) Minor cleanups to CONTRIBUTING.md (flutter/engine#8043) flutter/engine@effee2f80 remove extra statement (flutter/engine#8041) flutter/engine@14e082fa0 (master) add lint script for Android with baseline (flutter/engine#8036) flutter/engine@5fed42197 Roll src/third_party/skia 25bc174cf682..72542816cadb (14 commits) (flutter/engine#8040) flutter/engine@e6a5201f0 Add missing values to semantics action enums (flutter/engine#8033) flutter/engine@75d4db31d Roll src/third_party/skia fbc887df72ec..25bc174cf682 (7 commits) (flutter/engine#8039) flutter/engine@c46226980 Roll src/third_party/skia 0a57971f0544..fbc887df72ec (1 commits) (flutter/engine#8037) flutter/engine@ed628da00 Add missing kHasImplicitScrolling enum value (flutter/engine#8030) flutter/engine@052774e1c Roll src/third_party/skia e3e80b7edfd1..0a57971f0544 (16 commits) (flutter/engine#8035) flutter/engine@2cd9b41ba Select MPL instead of LGPL (flutter/engine#7991) flutter/engine@629c0d836 Roll src/third_party/dart 7d8ffe0daf..571ea80e11 (3 commits) flutter/engine@8f1fdcd19 Android Embedding PR 14: Almost done with FlutterFragment. (flutter/engine#8000) flutter/engine@fb3e35d6a Android Embedding PR15: Add Viewport Metrics to FlutterView (flutter/engine#8029) flutter/engine@36ca5740c (flutter/engine#8026) flutter/engine@3d53e2026 Roll src/third_party/skia 5800f2e8a920..e3e80b7edfd1 (2 commits) (flutter/engine#8028) flutter/engine@f3d4a7f71 Roll src/third_party/dart 7c70ab1817..7d8ffe0daf (77 commits) flutter/engine@a2246c199 Start of linting Android embedding (flutter/engine#8023) flutter/engine@48bf4803e [fuchsia] Fix snapshot BUILD.gn file for Fuchsia roll (flutter/engine#8024)
flutter/engine@f4951df19 (upstream/master) Minor cleanups to CONTRIBUTING.md (flutter/engine#8043) flutter/engine@effee2f80 remove extra statement (flutter/engine#8041) flutter/engine@14e082fa0 (master) add lint script for Android with baseline (flutter/engine#8036) flutter/engine@5fed42197 Roll src/third_party/skia 25bc174cf682..72542816cadb (14 commits) (flutter/engine#8040) flutter/engine@e6a5201f0 Add missing values to semantics action enums (flutter/engine#8033) flutter/engine@75d4db31d Roll src/third_party/skia fbc887df72ec..25bc174cf682 (7 commits) (flutter/engine#8039) flutter/engine@c46226980 Roll src/third_party/skia 0a57971f0544..fbc887df72ec (1 commits) (flutter/engine#8037) flutter/engine@ed628da00 Add missing kHasImplicitScrolling enum value (flutter/engine#8030) flutter/engine@052774e1c Roll src/third_party/skia e3e80b7edfd1..0a57971f0544 (16 commits) (flutter/engine#8035) flutter/engine@2cd9b41ba Select MPL instead of LGPL (flutter/engine#7991) flutter/engine@629c0d836 Roll src/third_party/dart 7d8ffe0daf..571ea80e11 (3 commits) flutter/engine@8f1fdcd19 Android Embedding PR 14: Almost done with FlutterFragment. (flutter/engine#8000) flutter/engine@fb3e35d6a Android Embedding PR15: Add Viewport Metrics to FlutterView (flutter/engine#8029) flutter/engine@36ca5740c (flutter/engine#8026) flutter/engine@3d53e2026 Roll src/third_party/skia 5800f2e8a920..e3e80b7edfd1 (2 commits) (flutter/engine#8028) flutter/engine@f3d4a7f71 Roll src/third_party/dart 7c70ab1817..7d8ffe0daf (77 commits) flutter/engine@a2246c199 Start of linting Android embedding (flutter/engine#8023) flutter/engine@48bf4803e [fuchsia] Fix snapshot BUILD.gn file for Fuchsia roll (flutter/engine#8024)
Tool for linting the Android embedding.
Addresses part of flutter/flutter#28847