You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add an option to "flutter test/drive/analyze" to make output more machine readable #14134
The current output is machine readable (in fact, it's machine-read; that's why it's still using [hint] and similar syntax instead of the bullets and such that the dartanalyzer uses by default). There's also a mode for dartanalyzer (which you can invoke directly) that is intended specifically to be read by machines. Are either of those sufficient? If not, can you elaborate on the use case?
The ask is to have the output in an easier format/structure so that it's easier to integrate into a CI system. The current output (as far as I can see, unless there's other ways to format via flags, etc.) is not the easiest to parse.
Can you elaborate on "integrate into a CI system"? What are you going to do with the data? What fields do you need? It's hard to know how to address the request without knowing the full use case.
@Hixie Now when I run flutter analyze for flutter package of the master branch, the console output is like below:
[warning] The method 'launch' isn't defined for the class 'UpdaterState'. (/Users/kylewong/Codes/Flutter/flutter_master/flutter/examples/flutter_gallery/lib/gallery/updates.dart, line 46, col 9)
[warning] The method 'launch' isn't defined for the class 'GalleryDrawer'. (/Users/kylewong/Codes/Flutter/flutter_master/flutter/examples/flutter_gallery/lib/gallery/drawer.dart, line 224, col 9)
[error] Target of URI doesn't exist: 'package:url_launcher/url_launcher.dart'. (/Users/kylewong/Codes/Flutter/flutter_master/flutter/examples/flutter_gallery/lib/gallery/drawer.dart, line 11, col 8)
[warning] The method 'launch' isn't defined for the class 'LinkTextSpan'. (/Users/kylewong/Codes/Flutter/flutter_master/flutter/examples/flutter_gallery/lib/gallery/drawer.dart, line 32, col 7)
[lint] 2 public members lack documentation (ran in 37.7s)
Do you mean the right approach for us to know how much passed/failed is to analyze the formated message line by line? Extract type(warning/error), message, file and line num from each line?
As to the flutter test, the message as below:
00:02 +22 -1: 00:01 +24 -1: /Users/kylewong/Codes/Flutter/flutter_master/flutter/packages/flutter/test/animation/animation_controller_test.dart: velocity test - linear
02:17 +2177 ~16 -2: Some tests failed.
Should we use the same approach to extract the type(passed/failed) and file from each line?
Do you mean the right approach for us to know how much passed/failed is to analyze the formated message line by line?
I'm not sure exactly what you mean by "how much passed/failed". The analyzer only tells you if there was a problem; the output cannot reliably tell you how much of a problem it is or how many problems there are. For example, remove a semicolon or add a comma somewhere bogus, and you'll see the analyzer will start to report thousands of errors, some in entirely different libraries. You can tell if there were any errors by looking at the exit code (0 = no errors, anything else = errors).
Extract type(warning/error), message, file and line num from each line?
Well, again, I'm not sure exactly what you're trying to do here so it's hard to evaluate. If you are trying to write an IDE-like feature where it highlights all the lines that had errors, then the output above is easy to parse: it follows the form [...] ... (..., line ..., col ...); ignore lines that don't match.
flutter test
For flutter test, the output is not machine-readable. The exit code is 0 on success, 1 on failure. Without knowing exactly what you want to do with the output it's hard to give further advice.
Side note: the classification of errors as warnings, errors, lints, or hints, is mostly arbitrary and I would strongly recommend ignoring it. Some of the lints are more serious than some of the errors, in my experience.
Another use case is parsing the output to integrate in editors/IDEs. For example, I would like to use these commands as makeprg in VIM so I can run :make and it will run them and parse the output to get a list of errors so I can quickly jump to them. Since plugin-ins like coc-flutter already do some on-the-fly analyzing, it is more important for test for me, although it would be nice to also be able to run an analyze for the whole project (as the on-the-fly option only shows errors in the current file).
In particular the VIM plugin Neomake complains about issues adding dart support because of this: neomake/neomake#1803
BTW, I guess the suggestion to use dartanalyzer is outdated, as the tendency is to move away from dartanalyzer according to the dart tool documentation:
Over time, we expect the dart command to replace most existing commands in the Dart SDK.
But another reason for me, is flutter analyze does some extra magic, like running inside the example directory by changing to it, as it is a separate project.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
Hixie commentedon Jan 17, 2018
Ideally not JSON...
The current output is machine readable (in fact, it's machine-read; that's why it's still using
[hint]and similar syntax instead of the bullets and such that the dartanalyzer uses by default). There's also a mode fordartanalyzer(which you can invoke directly) that is intended specifically to be read by machines. Are either of those sufficient? If not, can you elaborate on the use case?mjohnsullivan commentedon Jan 17, 2018
The ask is to have the output in an easier format/structure so that it's easier to integrate into a CI system. The current output (as far as I can see, unless there's other ways to format via flags, etc.) is not the easiest to parse.
Hixie commentedon Jan 18, 2018
Can you elaborate on "integrate into a CI system"? What are you going to do with the data? What fields do you need? It's hard to know how to address the request without knowing the full use case.
kangwang1988 commentedon Jan 18, 2018
@Hixie Now when I run flutter analyze for flutter package of the master branch, the console output is like below:
Do you mean the right approach for us to know how much passed/failed is to analyze the formated message line by line? Extract type(warning/error), message, file and line num from each line?
As to the flutter test, the message as below:
Should we use the same approach to extract the type(passed/failed) and file from each line?
Hixie commentedon Jan 18, 2018
I'm not sure exactly what you mean by "how much passed/failed". The analyzer only tells you if there was a problem; the output cannot reliably tell you how much of a problem it is or how many problems there are. For example, remove a semicolon or add a comma somewhere bogus, and you'll see the analyzer will start to report thousands of errors, some in entirely different libraries. You can tell if there were any errors by looking at the exit code (0 = no errors, anything else = errors).
Well, again, I'm not sure exactly what you're trying to do here so it's hard to evaluate. If you are trying to write an IDE-like feature where it highlights all the lines that had errors, then the output above is easy to parse: it follows the form
[...] ... (..., line ..., col ...); ignore lines that don't match.For
flutter test, the output is not machine-readable. The exit code is 0 on success, 1 on failure. Without knowing exactly what you want to do with the output it's hard to give further advice.Hixie commentedon Jan 18, 2018
Side note: the classification of errors as warnings, errors, lints, or hints, is mostly arbitrary and I would strongly recommend ignoring it. Some of the lints are more serious than some of the errors, in my experience.
kangwang1988 commentedon Jan 23, 2018
@Hixie Got it.
Thanks.
iapicca commentedon Nov 1, 2019
Hi @mjohnsullivan is this issue still meant to be open?
2 remaining items
Manual roll engine fdaa7cf..ee4c2a5 (8 commits)
Manual roll engine fdaa7cf..ee4c2a5 (8 commits) (#46174)
Roll engine fdaa7cf..ee4c2a5 (8 commits) (#46178)
jmagman commentedon Feb 20, 2020
The
flutter drivepart was split out to #51135.llucax commentedon Jan 27, 2021
Another use case is parsing the output to integrate in editors/IDEs. For example, I would like to use these commands as
makeprgin VIM so I can run:makeand it will run them and parse the output to get a list of errors so I can quickly jump to them. Since plugin-ins likecoc-flutteralready do some on-the-fly analyzing, it is more important fortestfor me, although it would be nice to also be able to run ananalyzefor the whole project (as the on-the-fly option only shows errors in the current file).In particular the VIM plugin Neomake complains about issues adding dart support because of this: neomake/neomake#1803
llucax commentedon Jan 27, 2021
BTW, I guess the suggestion to use
dartanalyzeris outdated, as the tendency is to move away fromdartanalyzeraccording to the dart tool documentation:But another reason for me, is
flutter analyzedoes some extra magic, like running inside theexampledirectory by changing to it, as it is a separate project.ueman commentedon May 4, 2021
I want to add support for reporting linter errors to Code Climate. Sot his would be beneficial for it.
github-actions commentedon Jul 11, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.