-
Notifications
You must be signed in to change notification settings - Fork 58
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
Support default/json output formats #86
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I don't know honestly.
What's the issue exactly? |
The |
No it is crutial that logs in the client are reported. That's probably the most important bit. But I do not understand why you need to disable log reporting in the client for this |
Maybe you're looking at modifying the CommandCustomLintDelegate? |
Well |
89f75ab
to
52a6562
Compare
Maybe I am also just stupid. I fixed the tests and added screenshots of the sample outputs. |
52a6562
to
40e2eac
Compare
Using zone overrides is expected. It's the most user-friendly experience, as they can just use "print". That's natural As I said, you should be able to change CommandCustomLintDelegate to your liking. |
I think this is good now, I added a test for the json format and extended the sorting test to take the severity into account. |
I'm looking forward to this being merged. :) |
@@ -70,58 +75,26 @@ Future<void> _runPlugins( | |||
CustomLintRunner runner, { | |||
required bool reload, | |||
}) async { | |||
final log = Logger.standard(); | |||
|
|||
log.progress('Analyzing'); |
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.
The progress is never stopped
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.
cli_util
automatically stops progress if any other output is performed.
@@ -33,6 +33,7 @@ q: Quit | |||
/// Watch mode cannot be enabled if in release mode. | |||
Future<void> customLint({ | |||
bool watchMode = true, | |||
String format = 'default', |
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.
Don't use Strings here. Use an enum
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.
Yea, will do.
import 'package:path/path.dart' as p; | ||
|
||
/// The maximum length of any of the existing severity labels. | ||
const int _severityWidth = 7; |
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.
It's weird to have this hardcoded I think. We should be able to easily compute this dymically
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.
Yea maybe, but I wanted to keep the whole output code as close to the original Dart analyzer code as possible. This way custom_lint
has the same consistent output formatting and it is easier to keep up with changes in the Dart analyzer.
/// is used as the usageLineLength. | ||
int? get _dartdevUsageLineLength => | ||
stdout.hasTerminal ? stdout.terminalColumns : null; |
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 don't understand how the function name and its implementation are related
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.
Just taken from the Dart analyzer - it is the max line length in a terminal before a line break happens, but only if stdout is connected a terminal.
for (final contextMessage in error.contextMessages!) { | ||
final startOffset = contextMessage.location.offset; | ||
contextMessages.add({ | ||
'location': location( |
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.
All of this serialization logic sounds redundant with the AnalyzerConverter class. Which allows converting an AnalysisError from analyzer into one from analyzer_plugin. And the latter has a toJson
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.
Same as above, this is just taken from Dart analyzer and is different from the toJson output I believe.
|
||
/// Emits a list of lints in the Dart analyzer style default format. | ||
@internal | ||
void emitDefaultFormat( |
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.
Please don't change the output of the default mode in this PR.
That makes reviewing this PR a bit difficult
If we want to improve the rendering, this should be a separate issue/PR
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.
Since this is apparently taken from the analyzer, it'd be great to document that too. Maybe have all the analyzer code in a separate file with a link to their original source
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.
Yea that is basically most of the output file, I will try to split the custom_lint
parts out and add a license-info/documentation at the top.
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 splitting up the json/default format into 2 PRs is kinda hard because they are pretty interwoven until the last print step.
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.
Sounds good then. I'm fine with having one PR if you move analyzer-stuff in its own file :)
Otherwise it's a bit hard to know what you wrote vs what's forked
Are the 2 output examples in the screenshots something that we generally agree on? |
@@ -21,6 +22,8 @@ final helloWordPluginSource = createPluginSource([ | |||
) | |||
]); | |||
|
|||
final ansi = Ansi(Ansi.terminalSupportsAnsi); |
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.
The tests shouldn't rely on terminalSupportsAnsi
Instead they should use a consistent on/off status.
We'd want to test the output both with and without terminalSupportsAnsi then.
Which also means a test which doesn't strip ansi codes to make sure they are present if you don't mind.
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.
Will see if we can simulate this somehow but Github runner terminals don't support ansi.
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 don't need github runners for this.
If you don't mind, I'll wait until I can fix the funky platform crash before merging this. |
I am gonna split this up in smaller parts. |
This is an initial start in order to eventually support invertase/github-action-dart-analyzer#199
It works pretty much, most of the output code comes from the Dart SDK. Wonder if there is a way to use it directly?
Fixes #22
Fixes #101