Skip to content

Commit 849e9dc

Browse files
vgvbotmarcossevillavery-good-code-bot[bot]
authored
chore: update SPDX licenses (#1580)
* chore: update SPDX licenses * chore: update SPDX licenses * fix: address review feedback on PR #1580 * chore: format --------- Co-authored-by: Marcos Sevilla <31174242+marcossevilla@users.noreply.github.com> Co-authored-by: very-good-code-bot[bot] <269805761+very-good-code-bot[bot]@users.noreply.github.com> Co-authored-by: Marcos Sevilla <me@marcossevilla.dev>
1 parent 2bf9345 commit 849e9dc

22 files changed

Lines changed: 1107 additions & 1430 deletions

lib/src/cli/flutter_cli.dart

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -83,42 +83,42 @@ class CoverageMetrics {
8383
}
8484
}
8585

86-
return records.fold<CoverageMetrics>(
87-
const CoverageMetrics(),
88-
(current, record) {
89-
final found = record.lines?.found ?? 0;
90-
final hit = record.lines?.hit ?? 0;
91-
if (globs.isNotEmpty && record.file != null) {
92-
for (final glob in globs) {
93-
if (glob.matches(record.file!)) return current;
94-
}
86+
return records.fold<CoverageMetrics>(const CoverageMetrics(), (
87+
current,
88+
record,
89+
) {
90+
final found = record.lines?.found ?? 0;
91+
final hit = record.lines?.hit ?? 0;
92+
if (globs.isNotEmpty && record.file != null) {
93+
for (final glob in globs) {
94+
if (glob.matches(record.file!)) return current;
9595
}
96+
}
9697

97-
final file = record.file;
98-
final details = record.lines?.details;
99-
final uncoveredLines = Map<String, List<int>>.from(
100-
current.uncoveredLines,
101-
);
102-
103-
if (file != null && details != null) {
104-
for (final line in details) {
105-
if ((line.hit ?? 1) == 0 && line.line != null) {
106-
uncoveredLines.update(
107-
file,
108-
(lines) => [...lines, line.line!],
109-
ifAbsent: () => [line.line!],
110-
);
111-
}
98+
final file = record.file;
99+
final details = record.lines?.details;
100+
final uncoveredLines = Map<String, List<int>>.from(
101+
current.uncoveredLines,
102+
);
103+
104+
if (file != null && details != null) {
105+
for (final line in details) {
106+
if ((line.hit ?? 1) == 0 && line.line != null) {
107+
uncoveredLines.update(
108+
file,
109+
(lines) => [...lines, line.line!],
110+
ifAbsent: () => [line.line!],
111+
);
112112
}
113113
}
114+
}
114115

115-
return CoverageMetrics(
116-
totalFound: current.totalFound + found,
117-
totalHits: current.totalHits + hit,
118-
uncoveredLines: uncoveredLines,
119-
);
120-
},
121-
);
116+
return CoverageMetrics(
117+
totalFound: current.totalFound + found,
118+
totalHits: current.totalHits + hit,
119+
uncoveredLines: uncoveredLines,
120+
);
121+
});
122122
}
123123

124124
/// Total number of lines hit (covered) across all included files.

lib/src/commands/create/templates/post_generate_actions.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ Future<bool> installDartPackages(
1414
final isDartInstalled = await Dart.installed(logger: logger);
1515
if (!isDartInstalled) return false;
1616

17-
return Dart.pubGet(
18-
cwd: outputDir.path,
19-
recursive: recursive,
20-
logger: logger,
21-
);
17+
return Dart.pubGet(cwd: outputDir.path, recursive: recursive, logger: logger);
2218
}
2319

2420
/// Runs `flutter pub get` in the [outputDir].

lib/src/mcp/mcp_command.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import 'package:very_good_cli/src/mcp/mcp_server.dart';
1010

1111
/// Type definition for a factory that creates a [VeryGoodMCPServer].
1212
typedef ServerFactory =
13-
MCPServer Function({
14-
required StreamChannel<String> channel,
15-
});
13+
MCPServer Function({required StreamChannel<String> channel});
1614

1715
/// Factory function to create a [StreamChannel] from input and output streams.
1816
typedef ChannelFactory = StreamChannel<String> Function();
@@ -27,11 +25,9 @@ StreamChannel<String> _defaultChannelFactory() {
2725
/// {@endtemplate}
2826
class MCPCommand extends Command<int> {
2927
/// {@macro mcp_command}
30-
MCPCommand({
31-
ChannelFactory? channelFactory,
32-
ServerFactory? serverFactory,
33-
}) : _channelFactory = channelFactory ?? _defaultChannelFactory,
34-
_serverFactory = serverFactory ?? VeryGoodMCPServer.new;
28+
MCPCommand({ChannelFactory? channelFactory, ServerFactory? serverFactory})
29+
: _channelFactory = channelFactory ?? _defaultChannelFactory,
30+
_serverFactory = serverFactory ?? VeryGoodMCPServer.new;
3531

3632
/// The [name] of the command. But static.
3733
static const String commandName = 'mcp';

lib/src/pub_license/spdx_license.gen.dart

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/helpers/test_multi_template_commands.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ Future<void> testMultiTemplateCommand({
5555
),
5656
);
5757
verify(
58-
() => generator.generate(
59-
any(),
60-
vars: expectedVars,
61-
logger: logger,
62-
),
58+
() => generator.generate(any(), vars: expectedVars, logger: logger),
6359
).called(1);
6460
verify(() => logger.created(expectedLogSummary)).called(1);
6561
}

test/src/cli/dart_cli_test.dart

Lines changed: 76 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,7 @@ void main() {
8383
});
8484

8585
test('returns false when dart is not installed', () async {
86-
final processResult = ProcessResult(
87-
42,
88-
ExitCode.software.code,
89-
'',
90-
'',
91-
);
86+
final processResult = ProcessResult(42, ExitCode.software.code, '', '');
9287

9388
when(
9489
() => process.run(
@@ -100,10 +95,8 @@ void main() {
10095
).thenAnswer((_) async => processResult);
10196

10297
await ProcessOverrides.runZoned(
103-
() => expectLater(
104-
Dart.installed(logger: logger),
105-
completion(isFalse),
106-
),
98+
() =>
99+
expectLater(Dart.installed(logger: logger), completion(isFalse)),
107100
runProcess: process.run,
108101
);
109102
});
@@ -156,75 +149,69 @@ void main() {
156149
);
157150
});
158151

159-
test(
160-
'completes when there is a pubspec.yaml and '
161-
'directory is ignored (recursive)',
162-
() async {
163-
final tempDirectory = Directory.systemTemp.createTempSync();
164-
addTearDown(() => tempDirectory.deleteSync(recursive: true));
165-
166-
final nestedDirectory = Directory(p.join(tempDirectory.path, 'test'))
167-
..createSync();
168-
final ignoredDirectory = Directory(
169-
p.join(tempDirectory.path, 'test_plugin'),
170-
)..createSync();
171-
172-
File(
173-
p.join(nestedDirectory.path, 'pubspec.yaml'),
174-
).writeAsStringSync(_pubspec);
175-
File(
176-
p.join(ignoredDirectory.path, 'pubspec.yaml'),
177-
).writeAsStringSync(_pubspec);
178-
179-
final relativePathPrefix = '.${p.context.separator}';
180-
181-
await ProcessOverrides.runZoned(
182-
() => expectLater(
183-
Dart.pubGet(
184-
cwd: tempDirectory.path,
185-
recursive: true,
186-
ignore: {
187-
'test_plugin',
188-
'/**/test_plugin_two/**',
189-
},
190-
logger: logger,
191-
),
192-
completes,
152+
test('completes when there is a pubspec.yaml and '
153+
'directory is ignored (recursive)', () async {
154+
final tempDirectory = Directory.systemTemp.createTempSync();
155+
addTearDown(() => tempDirectory.deleteSync(recursive: true));
156+
157+
final nestedDirectory = Directory(p.join(tempDirectory.path, 'test'))
158+
..createSync();
159+
final ignoredDirectory = Directory(
160+
p.join(tempDirectory.path, 'test_plugin'),
161+
)..createSync();
162+
163+
File(
164+
p.join(nestedDirectory.path, 'pubspec.yaml'),
165+
).writeAsStringSync(_pubspec);
166+
File(
167+
p.join(ignoredDirectory.path, 'pubspec.yaml'),
168+
).writeAsStringSync(_pubspec);
169+
170+
final relativePathPrefix = '.${p.context.separator}';
171+
172+
await ProcessOverrides.runZoned(
173+
() => expectLater(
174+
Dart.pubGet(
175+
cwd: tempDirectory.path,
176+
recursive: true,
177+
ignore: {'test_plugin', '/**/test_plugin_two/**'},
178+
logger: logger,
193179
),
194-
runProcess: process.run,
195-
).whenComplete(() {
196-
final nestedRelativePath = p.relative(
197-
nestedDirectory.path,
180+
completes,
181+
),
182+
runProcess: process.run,
183+
).whenComplete(() {
184+
final nestedRelativePath = p.relative(
185+
nestedDirectory.path,
186+
from: tempDirectory.path,
187+
);
188+
189+
verify(() {
190+
logger.progress(
191+
any(
192+
that: contains(
193+
'''Running "dart pub get" in $relativePathPrefix$nestedRelativePath''',
194+
),
195+
),
196+
);
197+
}).called(1);
198+
199+
verifyNever(() {
200+
final ignoredRelativePath = p.relative(
201+
ignoredDirectory.path,
198202
from: tempDirectory.path,
199203
);
200204

201-
verify(() {
202-
logger.progress(
203-
any(
204-
that: contains(
205-
'''Running "dart pub get" in $relativePathPrefix$nestedRelativePath''',
206-
),
207-
),
208-
);
209-
}).called(1);
210-
211-
verifyNever(() {
212-
final ignoredRelativePath = p.relative(
213-
ignoredDirectory.path,
214-
from: tempDirectory.path,
215-
);
216-
217-
logger.progress(
218-
any(
219-
that: contains(
220-
'''Running "dart pub get" in $relativePathPrefix$ignoredRelativePath''',
221-
),
205+
logger.progress(
206+
any(
207+
that: contains(
208+
'''Running "dart pub get" in $relativePathPrefix$ignoredRelativePath''',
222209
),
223-
);
224-
});
210+
),
211+
);
225212
});
226-
},
227-
);
213+
});
214+
});
228215

229216
test('throws when process fails', () async {
230217
when(
@@ -364,25 +351,22 @@ void main() {
364351
});
365352

366353
test('runs dart with correct args', () async {
367-
await ProcessOverrides.runZoned(
368-
() async {
369-
await Dart.runPigeon(
370-
logger: logger,
371-
cwd: '.',
372-
input: 'pigeons/messages.dart',
373-
);
374-
375-
verify(
376-
() => process.run(
377-
'dart',
378-
['run', 'pigeon', '--input', 'pigeons/messages.dart'],
379-
runInShell: any(named: 'runInShell'),
380-
workingDirectory: any(named: 'workingDirectory'),
381-
),
382-
).called(1);
383-
},
384-
runProcess: process.run,
385-
);
354+
await ProcessOverrides.runZoned(() async {
355+
await Dart.runPigeon(
356+
logger: logger,
357+
cwd: '.',
358+
input: 'pigeons/messages.dart',
359+
);
360+
361+
verify(
362+
() => process.run(
363+
'dart',
364+
['run', 'pigeon', '--input', 'pigeons/messages.dart'],
365+
runInShell: any(named: 'runInShell'),
366+
workingDirectory: any(named: 'workingDirectory'),
367+
),
368+
).called(1);
369+
}, runProcess: process.run);
386370
});
387371
});
388372
});

0 commit comments

Comments
 (0)