After a bit of effort the other day, I was able to run my Dart Comics sample app through the Dart Editor's analysis tool. I cleaned up all of the M1-related warning and problems identified in the underlying Hipster MVC library.
There are still a few problems outstanding in the sample app. Before addressing them, there is just one problem with the dart analysis tools that needs fixing—the dependency on the Dart Editor. Don't get me wrong, the Dart Editor seems pretty solid, but it's no Emacs. Happily for me, there is a command line version of the dart analyzer.
To run the analyzer from my Dart Comics sample app, I use the following command line:
➜ dart-comics git:(M1) ~/local/dart/dart-sdk/bin/dart_analyzer \ --package-root public/scripts/packages \ public/scripts/main.dartI would normally symlink the
dart_analyzer
command into my $HOME/bin
directory, but that seems to confuse the analyzer as to the location of the SDK.The result of the the analysis too is a number of deprecation warning—many still in the Hipster MVC library:
... file:/home/chris/repos/hipster-mvc/lib/hipster_collection.dart:130: The presence of parentheses after the name of the getter has been deprecated and will soon be disallowed. Please remove the parentheses. 129: 130: String get type() =>_type; ~~~~ file:/home/chris/repos/hipster-mvc/lib/hipster_collection.dart:132: The presence of parentheses after the name of the getter has been deprecated and will soon be disallowed. Please remove the parentheses. 131: 132: HipsterModel get model() => _model; ~~~~~ ...Darn. I really thought that I had cleaned Hipster MVC up for M1.
The getter declaration syntax has been updated to reflect the manner in which it is called (i.e. without the empty parentheses). So the fix is a simple matter of removing the empty parentheses from those declarations:
String get type =>_type;I also run afoul of the recent switch from the Dynamic class to the dynamic keyword:
file:/home/chris/repos/hipster-mvc/lib/hipster_sync.dart:24: no such type "Dynamic" 23: // forward the call to the appropriate behavior (injected or default) 24: static Future<Dynamic> call(method, model) { ~~~~~~~The fix:
// static method for HipsterModel and HipsterCollection to invoke -- will
// forward the call to the appropriate behavior (injected or default)
static Future<dynamic> call(method, model) { /* ... */ }
The last change that I need in my Hipster MVC class is to remove the abstract modifier for some of my methods:file:/home/chris/repos/hipster-mvc/lib/hipster_collection.dart:19: Modifier 'abstract' is deprecated for methods without body. Remove it. 18: 19: abstract HipsterModel modelMaker(attrs); ~~~~~~~~As the warning indicates, the compiler now recognizes that method declarations without bodies are abstract—there is no longer a need to be explicit about it.
OK now I have fixed all of the warnings and problems in the Hipster MVC library. These deprecation messages may have been available as "info" messages rather than problems and warnings, which is why I skipped them the first time.
I rather like the new getter syntax. If the getter is invoked like a property, then it might as well be declared the same way. I do not understand the switch from
Dynamic
to dynamic
, but it is a simple enough change. I also like the removal of the abstract
keyword. Coming from a dynamic language background that seems unnecessary ceremony.And, of course, I most appreciate being able to run the analysis from the command line so that I can continue to use Emacs, the one true editor.
Day #554
No comments:
Post a Comment