Reflect rules's "severity" using analyser
tenhobi opened this issue · 4 comments
From the Effective Dart, you have these severity types:
- DO guidelines describe practices that should always be followed. There will almost never be a valid reason to stray from them.
- DON’T guidelines are the converse: things that are almost never a good idea. Hopefully, we don’t have as many of these as other languages do because we have less historical baggage.
- PREFER guidelines are practices that you should follow. However, there may be circumstances where it makes sense to do otherwise. Just make sure you understand the full implications of ignoring the guideline when you do.
- AVOID guidelines are the dual to “prefer”: stuff you shouldn’t do but where there may be good reasons to on rare occasions.
- CONSIDER guidelines are practices that you might or might not want to follow, depending on circumstances, precedents, and your own preference.
And as I understand, you can use four types of severity for analyzer:
error
warning
info
ignore
And more info about how it can be done here: https://dart.dev/guides/language/analysis-options#the-analysis-options-file
I would like to (and this is not opinionated, it would be nice to have in general to determine these types from the guide in the editor) reflect the type of usage from guidelines in Effective Dart, so do
and don't
rules are treated as they have to be done this way and prefer
and avoid
as only optional? With that, without enabling thins like --fatal-infos
and --fatal-warnings
, it would be good if analyzer would fail for do
s and don't
s and don't fail for prefer
s and avoid
s.
- Does this have a sense, is it worth it?
For example, in pedantic package, there is written "By default we disallow checking in code with any errors, warnings, or hints." and that might work if all the lints are given the same severity, but Effective Dart doesn't have this benefit. 🤷♂️
- Can I use
error
fordo
s anddon't
s, or it's too hard? Should I usewarning
for that? - If
error
will be used fordo
s anddon't
s, thenwarning
forprefer
s andavoid
s andinfo
forconsider
s? - if
consider
s would haveinfo
, and therefore be shown as a "something" from Dart Analyser, wouldn't that force people to use it, whereas this section isn't always what you want to do? So maybe omitconsider
s?
I would like some comments, mostly to be as aligned as possible with the guide intention.
Maybe cc @pq @kwalrath ...
Also cc @munificent
Also, it seems that flutter analyze
fails when there are infos or warnings. Is there any reason why? dartanalyze
doesn't do that.
In #25 I have set up do
s and don't
s as error
, avoid
s and prefer
s as warning
and consider
s as info
. But to be able to show the consider
s to the users, I would have to enable those lints.
Also, Flutter's analyzer doesn't allow warnings and lints in the code, so that is kinda weird in comparison with Dart Analyzer.
For now, I keep consider
s commented out.
EDIT: Btw. as a nit, I could also enable consider
s and mark them as ignore
.