@cvega With 3.4.0, Dart analysis now runs, kudos for that. At the moment, though, it's not very usable without setting DISABLE_ERRORS: true, given that --fatal-infos turns pedantic nitpicks--copious, voluminous amounts of pedantic nitpicks--into workflow failures. That could hopefully be addressed in the Super Linter.
@devoncarew The larger practical hurdle in actually using this in Dart projects are the uri_does_not_exist errors (error • Target of URI doesn't exist: 'package:...') for any and all package imports. (That's been a common problem for Dart analysis outside of the Super Linter as well.) Would you perchance have any pointers on how to fix that? (Examples of the errors)
_Originally posted by @artob in https://github.com/github/super-linter/issues/120#issuecomment-667623551_
that --fatal-infos turns pedantic nitpicks into workflow failures
Dialing it back a bit makes sense - pedantic is very proscriptive. We (the Dart team) will come out with a slightly less proscriptive rule set in the near term (cc @munificent, @mit-mit), which would probably then be a good default.
The larger practical hurdle in actually using this in Dart projects are the uri_does_not_exist errors ...
I think these are actually correct, and indicate that we'll need to iterate on the integration here a bit. In-lining some errors from the failing project linked above:
File:[/github/workspace/example/lib/demos/face_detector.dart]
ERROR! Found errors in [dart] linter!
ERROR:[Analyzing /github/workspace/example/lib/demos/face_detector.dart...
error • Target of URI doesn't exist: 'package:flutter/material.dart'. • example/lib/demos/face_detector.dart:3:8 • uri_does_not_exist
error • Target of URI doesn't exist: 'package:flutter_android/android_graphics.dart'. • example/lib/demos/face_detector.dart:5:8 • uri_does_not_exist
error • Target of URI doesn't exist: 'package:flutter_android/android_media.dart'. • example/lib/demos/face_detector.dart:6:8 • uri_does_not_exist
I see that:
package:flutter/material.dart is not found. That's an indication that we're using the Dart sdk to analyze a Flutter project; for these cases, we should be using the Flutter SDK. I suspect that we should also be installing the Flutter SDK as part of the image, and that we should use either the Flutter SDK or the Dart SDK to analyze the project (you can determine which to use by looking in the pubspec.yaml file for an environment: flutter: dep).dartanalyzer (and preferably dart analyze / flutter analyze) over the main repo directory)example/ directory. That dir can contain a sub-project; we'll either want to ignore results from that directory, or if it exists, also run pub get / flutter pub get in that directory to provision any packages.also cc'ing in @jonasfj and @isoos, who have experience with running analysis for various repos in the context of the pub.dev site. There may be some learning / scripts that we can share here.
I think we have a couple of issues, and I would love to address these and get the tool working as best as possible for the dart community. First, thank you for filing issues and bringing guidance, always appreciated.
Here are some of my thoughts/todo/need more information:
--fatal-* flag, it seems even when a lint/issue is found I receive an exit code of 0. I want to remove these, but I also want to fail a build if something is reported. pedantic is highly favorabledart analyze vs dartanalyzerThis issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.
@cvega @devoncarew Any updates?
This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.
Lots of the issues you're having are because you're not using flutter, or installing dependencies before running the analysis.
In short you need to do:
dart pub getdart analyze or (dartanalyzer)flutter pub getdart analyze or (dartanalyzer)Long term I suspect that dartanalyzer will go away, so if you can make dart analyze work, this is probably preferable.
The following happens because the dependency package:flutter_test is not available, running flutter pub get should fetch dependencies and dev_dependencies specified in pubspec.yaml. The undefined_function happens because the group function is defined in package:flutter_test/flutter_test.dart but this isn't available.
error • Target of URI doesn't exist: 'package:flutter_test/flutter_test.dart'. • test/android_test.dart:3:8 • uri_does_not_exist
error • The function 'group' isn't defined. • test/android_test.dart:8:3 • undefined_function
Note about caching: dart pub get and flutter pub get will install dependencies into PUB_CACHE if defined (otherwise, dart will use ~/.pub-cache/ and flutter will use a folder in the flutter SDK). The dependencies installed into PUB_CACHE should not be mutated. In addition to installing dependencies into PUB_CACHE, (dart|flutter) pub get will also create a .dart_tool/package_config.json file in the current-working-directory (must be the directory holding the pubspec.yaml).
The .dart_tool/package_config.json is essentially mapping from package name to folder on the system, hence, it points into PUB_CACHE and Flutter SDK (for SDK dependencies).
You can cache PUB_CACHE between runs and gain performance. Do not check-in or cache the .dart_tool/package_config.json file or the old .packages file it also generates.
With respect to what lints should be enabled, if there is an analysis_options.yaml file typically in the project root (next to the pubspec.yaml, in case of mono-repositories it's not necessarily the repository-root), then using the analysis_options.yaml that the user has chosen is probably preferable.
If there is no analysis_options.yaml file, I suspect it's fair to consider:
package:pedantic, the set of lints used internally at Google (very strict, and aims to serve Googles internal need),package:effective_dart, a community package,Maybe just pick either pedantic or effective_dart and then switch to Dart team recommendations when such recommendations are made.
@jonasfj Thanks for the write-up, I will review and see if I can work around these issues.
This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.
Most helpful comment
I think we have a couple of issues, and I would love to address these and get the tool working as best as possible for the dart community. First, thank you for filing issues and bringing guidance, always appreciated.
Here are some of my thoughts/todo/need more information:
--fatal-*flag, it seems even when a lint/issue is found I receive an exit code of0. I want to remove these, but I also want to fail a build if something is reported.pedanticis highly favorabledart analyzevsdartanalyzer