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
4631717f
Commit
4631717f
authored
Apr 18, 2017
by
Devon Carew
Committed by
GitHub
Apr 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
De-duplicate the dartanalyzer command output (#9441)
parent
79afc775
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
7 deletions
+57
-7
test.dart
dev/bots/test.dart
+1
-1
analyze_once.dart
packages/flutter_tools/lib/src/commands/analyze_once.dart
+16
-0
analyze_once_test.dart
packages/flutter_tools/test/analyze_once_test.dart
+40
-6
No files found.
dev/bots/test.dart
View file @
4631717f
...
...
@@ -118,7 +118,7 @@ Future<Null> _pubRunTest(
String
workingDirectory
,
{
String
testPath
,
})
{
final
List
<
String
>
args
=
<
String
>[
'run'
,
'test'
];
final
List
<
String
>
args
=
<
String
>[
'run'
,
'test'
,
'-rexpanded'
];
if
(
testPath
!=
null
)
args
.
add
(
testPath
);
return
_runCommand
(
pub
,
args
,
workingDirectory:
workingDirectory
);
...
...
packages/flutter_tools/lib/src/commands/analyze_once.dart
View file @
4631717f
...
...
@@ -11,6 +11,7 @@ import 'package:yaml/yaml.dart' as yaml;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/process.dart'
;
import
'../base/utils.dart'
;
import
'../cache.dart'
;
import
'../dart/analysis.dart'
;
import
'../globals.dart'
;
...
...
@@ -83,19 +84,34 @@ class AnalyzeOnce extends AnalyzeBase {
final
String
dartanalyzer
=
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dartanalyzer'
);
arguments
.
insert
(
0
,
dartanalyzer
);
bool
noErrors
=
false
;
final
Set
<
String
>
issues
=
new
Set
<
String
>();
int
exitCode
=
await
runCommandAndStreamOutput
(
arguments
,
workingDirectory:
workingDirectory
?.
path
,
mapFunction:
(
String
line
)
{
// De-duplicate the dartanalyzer command output (https://github.com/dart-lang/sdk/issues/25697).
if
(
line
.
startsWith
(
' '
))
{
if
(!
issues
.
add
(
line
.
trim
()))
return
null
;
}
// Workaround for the fact that dartanalyzer does not exit with a non-zero exit code
// when errors are found.
// TODO(danrubel): Fix dartanalyzer to return non-zero exit code
if
(
line
==
'No issues found!'
)
noErrors
=
true
;
// Remove text about the issue count ('2 hints found.'); with the duplicates
// above, the printed count would be incorrect.
if
(
line
.
endsWith
(
' found.'
))
return
null
;
return
line
;
},
);
stopwatch
.
stop
();
if
(
issues
.
isNotEmpty
)
printStatus
(
'
${issues.length}
${pluralize('issue', issues.length)}
found.'
);
final
String
elapsed
=
(
stopwatch
.
elapsedMilliseconds
/
1000.0
).
toStringAsFixed
(
1
);
// Workaround for the fact that dartanalyzer does not exit with a non-zero exit code
// when errors are found.
...
...
packages/flutter_tools/test/analyze_once_test.dart
View file @
4631717f
...
...
@@ -84,14 +84,14 @@ void main() {
);
await
libMain
.
writeAsString
(
source
);
//
/
Analyze in the current directory - no arguments
// Analyze in the current directory - no arguments
await
runCommand
(
command:
new
AnalyzeCommand
(
workingDirectory:
tempDir
),
arguments:
<
String
>[
'analyze'
],
statusTextContains:
<
String
>[
'Analyzing'
,
'warning
$analyzerSeparator
The parameter
\'
child
\'
is required'
,
'1
warning
found.'
,
'1
issue
found.'
,
],
toolExit:
true
,
);
...
...
@@ -105,7 +105,7 @@ void main() {
statusTextContains:
<
String
>[
'Analyzing'
,
'warning
$analyzerSeparator
The parameter
\'
child
\'
is required'
,
'1
warning
found.'
,
'1
issue
found.'
,
],
toolExit:
true
,
);
...
...
@@ -124,7 +124,7 @@ void main() {
- only_throw_errors
'''
);
//
/
Analyze in the current directory - no arguments
// Analyze in the current directory - no arguments
await
runCommand
(
command:
new
AnalyzeCommand
(
workingDirectory:
tempDir
),
arguments:
<
String
>[
'analyze'
],
...
...
@@ -132,12 +132,46 @@ void main() {
'Analyzing'
,
'warning
$analyzerSeparator
The parameter
\'
child
\'
is required'
,
'lint
$analyzerSeparator
Only throw instances of classes extending either Exception or Error'
,
'
1 warning and 1 lint
found.'
,
'
2 issues
found.'
,
],
toolExit:
true
,
);
});
testUsingContext
(
'flutter analyze no duplicate issues'
,
()
async
{
final
Directory
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'analyze_once_test_'
).
absolute
;
try
{
final
File
foo
=
fs
.
file
(
fs
.
path
.
join
(
tempDir
.
path
,
'foo.dart'
));
foo
.
writeAsStringSync
(
'''
import '
bar
.
dart
';
foo() => bar();
'''
);
final
File
bar
=
fs
.
file
(
fs
.
path
.
join
(
tempDir
.
path
,
'bar.dart'
));
bar
.
writeAsStringSync
(
'''
import '
dart:
async
'; // unused
void bar() {
}
'''
);
// Analyze in the current directory - no arguments
await
runCommand
(
command:
new
AnalyzeCommand
(
workingDirectory:
tempDir
),
arguments:
<
String
>[
'analyze'
],
statusTextContains:
<
String
>[
'Analyzing'
,
'1 issue found.'
,
],
toolExit:
true
,
);
}
finally
{
tempDir
.
deleteSync
(
recursive:
true
);
}
});
// Analyze a specific file outside the current directory
testUsingContext
(
'flutter analyze one file with local options'
,
()
async
{
await
runCommand
(
...
...
@@ -147,7 +181,7 @@ void main() {
'Analyzing'
,
'warning
$analyzerSeparator
The parameter
\'
child
\'
is required'
,
'lint
$analyzerSeparator
Only throw instances of classes extending either Exception or Error'
,
'
1 warning and 1 lint
found.'
,
'
2 issues
found.'
,
],
toolExit:
true
,
);
...
...
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