Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
03d6f18f
Unverified
Commit
03d6f18f
authored
Aug 17, 2018
by
Ian Hickson
Committed by
GitHub
Aug 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track number of package dependencies in Flutter (#20722)
parent
3dec6a69
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
14 deletions
+41
-14
technical_debt__cost.dart
dev/devicelab/bin/tasks/technical_debt__cost.dart
+41
-14
No files found.
dev/devicelab/bin/tasks/technical_debt__cost.dart
View file @
03d6f18f
...
...
@@ -43,24 +43,51 @@ Future<double> findCostsForFile(File file) async {
return
total
;
}
const
String
_kBenchmarkKey
=
'technical_debt_in_dollars'
;
Future
<
double
>
findCostsForRepo
()
async
{
final
Process
git
=
await
startProcess
(
'git'
,
<
String
>[
'ls-files'
,
'--full-name'
,
flutterDirectory
.
path
],
workingDirectory:
flutterDirectory
.
path
,
);
double
total
=
0.0
;
await
for
(
String
entry
in
git
.
stdout
.
transform
(
utf8
.
decoder
).
transform
(
const
LineSplitter
()))
total
+=
await
findCostsForFile
(
new
File
(
path
.
join
(
flutterDirectory
.
path
,
entry
)));
final
int
gitExitCode
=
await
git
.
exitCode
;
if
(
gitExitCode
!=
0
)
throw
new
Exception
(
'git exit with unexpected error code
$gitExitCode
'
);
return
total
;
}
Future
<
int
>
countDependencies
()
async
{
final
Process
subprocess
=
await
startProcess
(
'flutter'
,
<
String
>[
'update-packages'
,
'--transitive-closure'
],
workingDirectory:
flutterDirectory
.
path
,
);
final
List
<
String
>
lines
=
await
subprocess
.
stdout
.
transform
(
utf8
.
decoder
).
transform
(
const
LineSplitter
()).
toList
();
final
int
subprocessExitCode
=
await
subprocess
.
exitCode
;
if
(
subprocessExitCode
!=
0
)
throw
new
Exception
(
'flutter exit with unexpected error code
$subprocessExitCode
'
);
final
int
count
=
lines
.
where
((
String
line
)
=>
line
.
contains
(
'->'
)).
length
;
if
(
count
<
2
)
// we'll always have flutter and flutter_test, at least...
throw
new
Exception
(
'"flutter update-packages --transitive-closure" returned bogus output:
\n
${lines.join("\n")}
'
);
return
count
;
}
const
String
_kCostBenchmarkKey
=
'technical_debt_in_dollars'
;
const
String
_kNumberOfDependenciesKey
=
'dependencies_count'
;
Future
<
Null
>
main
()
async
{
await
task
(()
async
{
final
Process
git
=
await
startProcess
(
'git'
,
<
String
>[
'ls-files'
,
'--full-name'
,
flutterDirectory
.
path
],
workingDirectory:
flutterDirectory
.
path
,
);
double
total
=
0.0
;
await
for
(
String
entry
in
git
.
stdout
.
transform
(
utf8
.
decoder
).
transform
(
const
LineSplitter
()))
total
+=
await
findCostsForFile
(
new
File
(
path
.
join
(
flutterDirectory
.
path
,
entry
)));
final
int
gitExitCode
=
await
git
.
exitCode
;
if
(
gitExitCode
!=
0
)
throw
new
Exception
(
'git exit with unexpected error code
$gitExitCode
'
);
return
new
TaskResult
.
success
(
<
String
,
dynamic
>{
_kBenchmarkKey:
total
},
benchmarkScoreKeys:
<
String
>[
_kBenchmarkKey
],
<
String
,
dynamic
>{
_kCostBenchmarkKey:
await
findCostsForRepo
(),
_kNumberOfDependenciesKey:
await
countDependencies
(),
},
benchmarkScoreKeys:
<
String
>[
_kCostBenchmarkKey
,
_kNumberOfDependenciesKey
,
],
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment