Skip to content

Commit b5d60c6

Browse files
committed
Remove unnecessary type declarations.
1 parent e656a5c commit b5d60c6

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

lib/src/dartdoc_options.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ class ToolConfiguration {
148148

149149
static ToolConfiguration fromYamlMap(
150150
YamlMap yamlMap, pathLib.Context pathContext) {
151-
Map<String, ToolDefinition> newToolDefinitions = {};
152-
for (MapEntry entry in yamlMap.entries) {
153-
String name = entry.key.toString();
151+
var newToolDefinitions = <String, ToolDefinition>{};
152+
for (var entry in yamlMap.entries) {
153+
var name = entry.key.toString();
154154
var toolMap = entry.value;
155-
String description;
155+
var description;
156156
List<String> command;
157157
if (toolMap is Map) {
158158
description = toolMap['description']?.toString();
159159
// If the command key is given, then it applies to all platforms.
160-
String commandFrom = toolMap.containsKey('command')
160+
var commandFrom = toolMap.containsKey('command')
161161
? 'command'
162162
: Platform.operatingSystem;
163163
if (toolMap.containsKey(commandFrom)) {
@@ -195,10 +195,10 @@ class ToolConfiguration {
195195
'At least one of "command" or "${Platform.operatingSystem}" must '
196196
'be defined for the tool $name.');
197197
}
198-
String executable = command.removeAt(0);
198+
var executable = command.removeAt(0);
199199
executable = pathContext.canonicalize(executable);
200-
File executableFile = new File(executable);
201-
FileStat exeStat = executableFile.statSync();
200+
var executableFile = new File(executable);
201+
var exeStat = executableFile.statSync();
202202
if (exeStat.type == FileSystemEntityType.notFound) {
203203
throw new DartdocOptionError('Command executables must exist. '
204204
'The file "$executable" does not exist for tool $name.');

lib/src/model.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,11 +3699,11 @@ abstract class ModelElement extends Canonicalization
36993699
// Matches all tool directives (even some invalid ones). This is so
37003700
// we can give good error messages if the directive is malformed, instead of
37013701
// just silently emitting it as-is.
3702-
final RegExp basicToolRegExp = new RegExp(
3702+
final basicToolRegExp = new RegExp(
37033703
r'[ ]*{@tool\s+([^}]+)}\n?([\s\S]+?)\n?{@end-tool}[ ]*\n?',
37043704
multiLine: true);
37053705

3706-
ToolRunner runner = new ToolRunner(config.tools, (String message) {
3706+
var runner = new ToolRunner(config.tools, (String message) {
37073707
warn(PackageWarning.toolError, message: message);
37083708
});
37093709
try {
@@ -3972,7 +3972,7 @@ abstract class ModelElement extends Canonicalization
39723972
// args that look like assignments (start with valid option names followed
39733973
// by an equals sign), add a "--" in front so that they parse as options.
39743974
return matches.map<String>((Match match) {
3975-
String option = '';
3975+
var option = '';
39763976
if (convertToArgs && match[1] != null && !match[1].startsWith('-'))
39773977
option = '--';
39783978
if (match[2] != null) {
@@ -3990,7 +3990,7 @@ abstract class ModelElement extends Canonicalization
39903990
/// normally with [argParser] and returns the result.
39913991
ArgResults _parseArgs(
39923992
String argsAsString, ArgParser argParser, String directiveName) {
3993-
Iterable<String> args =
3993+
var args =
39943994
_splitUpQuotedArgs(argsAsString, convertToArgs: true);
39953995
try {
39963996
return argParser.parse(args);

lib/src/tool_runner.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ class ToolRunner {
6161
assert(args != null);
6262
assert(args.isNotEmpty);
6363
content ??= '';
64-
String tool = args.removeAt(0);
64+
var tool = args.removeAt(0);
6565
if (!toolConfiguration.tools.containsKey(tool)) {
6666
_error('Unable to find definition for tool "$tool" in tool map. '
6767
'Did you add it to dartdoc_options.yaml?');
6868
return '';
6969
}
70-
ToolDefinition toolDefinition = toolConfiguration.tools[tool];
71-
List<String> toolArgs = toolDefinition.command;
70+
var toolDefinition = toolConfiguration.tools[tool];
71+
var toolArgs = toolDefinition.command;
7272
if (pathLib.extension(toolDefinition.command.first) == '.dart') {
7373
// For dart tools, we want to invoke them with Dart.
7474
toolArgs.insert(0, Platform.resolvedExecutable);
@@ -83,21 +83,21 @@ class ToolRunner {
8383
// the input to a temporary file before running the tool synchronously.
8484

8585
// Write the content to a temp file.
86-
File tmpFile = _createTemporaryFile();
86+
var tmpFile = _createTemporaryFile();
8787
tmpFile.writeAsStringSync(content);
8888

8989
// Substitute the temp filename for the "$INPUT" token.
90-
RegExp fileToken = new RegExp(r'\$INPUT\b');
91-
List<String> argsWithInput = <String>[];
92-
for (String arg in args) {
90+
var fileToken = new RegExp(r'\$INPUT\b');
91+
var argsWithInput = <String>[];
92+
for (var arg in args) {
9393
argsWithInput.add(arg.replaceAll(fileToken, tmpFile.absolute.path));
9494
}
9595

9696
argsWithInput = toolArgs + argsWithInput;
97-
final String commandPath = argsWithInput.removeAt(0);
97+
final commandPath = argsWithInput.removeAt(0);
9898
String commandString() => ([commandPath] + argsWithInput).join(' ');
9999
try {
100-
ProcessResult result = Process.runSync(commandPath, argsWithInput);
100+
var result = Process.runSync(commandPath, argsWithInput);
101101
if (result.exitCode != 0) {
102102
_error('Tool "$tool" returned non-zero exit code '
103103
'(${result.exitCode}) when run as '

test/tool_runner_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'package:test/test.dart';
1414
import 'src/utils.dart' as utils;
1515

1616
void main() {
17-
ToolConfiguration toolMap = ToolConfiguration.empty;
17+
var toolMap = ToolConfiguration.empty;
1818

1919
toolMap.tools.addAll({
2020
'missing': new ToolDefinition(['/a/missing/executable'], "missing"),
@@ -28,7 +28,7 @@ void main() {
2828
new ToolDefinition([Platform.resolvedExecutable], 'non-dart tool'),
2929
});
3030
ToolRunner runner;
31-
final List<String> errors = <String>[];
31+
final errors = <String>[];
3232

3333
setUpAll(() async {
3434
runner = new ToolRunner(toolMap, (String message) => errors.add(message));
@@ -42,7 +42,7 @@ void main() {
4242
errors.clear();
4343
});
4444
test('can invoke a Dart tool', () {
45-
String result = runner.run(
45+
var result = runner.run(
4646
['drill', r'--file=$INPUT'],
4747
'TEST INPUT',
4848
);

0 commit comments

Comments
 (0)