-
Notifications
You must be signed in to change notification settings - Fork 168
Analyzer skeleton. #149
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
Analyzer skeleton. #149
Conversation
kevmoo
left a comment
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.
Good start!
app/lib/analyzer.dart
Outdated
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.
make final
app/lib/analyzer.dart
Outdated
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.
make final
app/lib/analyzer.dart
Outdated
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 have all of this written already - https://github.com/kevmoo/pana.dart
Mostly. Need to expose some of the private impl stuff I have
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.
looks good! Any ETA for publishing the recent changes?
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 did...
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.
@kevmoo No you did not! The last upload to package:pana was in 2015!
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.
Also if we want to use package:pana for the task, why this code here?
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.
This code precedes my awareness of pana. I think pana is a better place for most of this analysis, and I'm planning to contribute to it (e.g. dart-lang/pana#3). At the same time as soon as it is 'good enough', I'll update this PR with the 'pana' version.
|
@mkustermann would you take a look and merge? |
| } | ||
|
|
||
| class PubspecLock { | ||
| Map _content; |
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 you initialize it in the constructor, you might as well make it final (and use initializer rather than constructor body)
| 'with exit code: ${result.exitCode}\n' | ||
| 'stdout: ${result.stdout}\n' | ||
| 'stderr: ${result.stderr}'); | ||
| throw new Exception('Failed to extract tarball.'); |
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.
Consider changing readTarballFile to also log a warning - for consistency.
| } | ||
|
|
||
| List<LockedDependency> get packages { | ||
| if (_packages == 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.
Why do this lazily? The only reason one would construct a PubspecLock object is to call packages on it.
| // for details. All rights reserved. Use of this source code is governed by a | ||
| // BSD-style license that can be found in the LICENSE file. | ||
|
|
||
| library pub_dartlang_org.analysis; |
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.
Maybe use a consistent name for the filename and library name (i.e. analysis -> analyzer).
| ? new Directory(workDir) | ||
| : Directory.systemTemp.createTempSync(); | ||
| return new Analyzer._(new File(source), wd, workDir == 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.
Maybe it would be easier to read when using only one instead of two constructors:
Analyzer(String source, {String workdir})
: _sourceTarGz = new File(source),
_workDir = workdir != null ? new Directory(workdir) : Directory.systemTemp.createTempSync(),
_clearWorkDir = workdir == null;| } | ||
|
|
||
| /// Prepares the directories for the analysis and extracts the package. | ||
| Future setUp() async { |
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.
Consider renaming it from setUp to extractTarball.
app/lib/analyzer.dart
Outdated
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.
@kevmoo No you did not! The last upload to package:pana was in 2015!
app/lib/analyzer.dart
Outdated
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.
Also if we want to use package:pana for the task, why this code here?
| /// Reads pubspec.yaml and pubspec.lock. | ||
| Future readPubspecs() async { | ||
| final String pubspecContent = await new File( | ||
| _packageDir.path + Platform.pathSeparator + 'pubspec.yaml') |
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.
Consider using package:path/path.dart and do path.join(_packagesDir.path, 'pubspec.yaml')
|
I believe that the recent changes and the two open PRs at https://github.com/kevmoo/pana.dart cover more than I was planning here. As soon as there is a new version, I'll close this PR and create a new one using |
|
|
I wanted it to structure it in a way that helps to develop its parts in parallel.