Skip to content

Commit ab4b340

Browse files
github-actions[bot]vgvbotmarcossevilla
authored
chore: update SPDX licenses (#1296)
* chore: update SPDX licenses * fix: lint and remove pana min score --------- Co-authored-by: VGV Bot <[email protected]> Co-authored-by: Marcos Sevilla <[email protected]> Co-authored-by: Marcos Sevilla <[email protected]>
1 parent 1d96cc3 commit ab4b340

File tree

14 files changed

+91
-124
lines changed

14 files changed

+91
-124
lines changed

.github/workflows/very_good_cli.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,4 @@ jobs:
5252
pana:
5353
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/pana.yml@v1
5454
with:
55-
min_score: 150 # Update minimum score to 160 once we have the CLI up to date.
5655
pana_version: 0.22.21

lib/src/cli/cli.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ abstract class ProcessOverrides {
5252
}
5353

5454
/// Runs [body] in a fresh [Zone] using the provided overrides.
55-
static R runZoned<R>(
56-
R Function() body, {
57-
RunProcess? runProcess,
58-
}) {
55+
static R runZoned<R>(R Function() body, {RunProcess? runProcess}) {
5956
final overrides = _ProcessOverridesScope(runProcess);
6057
return _asyncRunZoned(body, zoneValues: {_token: overrides});
6158
}

lib/src/cli/dart_cli.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ part of 'cli.dart';
33
/// Dart CLI
44
class Dart {
55
/// Determine whether dart is installed.
6-
static Future<bool> installed({
7-
required Logger logger,
8-
}) async {
6+
static Future<bool> installed({required Logger logger}) async {
97
try {
108
await _Cmd.run('dart', ['--version'], logger: logger);
119
return true;

lib/src/cli/flutter_cli.dart

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,22 @@ class _CoverageMetrics {
7979
String? excludeFromCoverage,
8080
) {
8181
final glob = excludeFromCoverage != null ? Glob(excludeFromCoverage) : null;
82-
return records.fold<_CoverageMetrics>(
83-
const _CoverageMetrics._(),
84-
(current, record) {
85-
final found = record.lines?.found ?? 0;
86-
final hit = record.lines?.hit ?? 0;
87-
if (glob != null && record.file != null) {
88-
if (glob.matches(record.file!)) {
89-
return current;
90-
}
82+
return records.fold<_CoverageMetrics>(const _CoverageMetrics._(), (
83+
current,
84+
record,
85+
) {
86+
final found = record.lines?.found ?? 0;
87+
final hit = record.lines?.hit ?? 0;
88+
if (glob != null && record.file != null) {
89+
if (glob.matches(record.file!)) {
90+
return current;
9191
}
92-
return _CoverageMetrics._(
93-
totalFound: current.totalFound + found,
94-
totalHits: current.totalHits + hit,
95-
);
96-
},
97-
);
92+
}
93+
return _CoverageMetrics._(
94+
totalFound: current.totalFound + found,
95+
totalHits: current.totalHits + hit,
96+
);
97+
});
9898
}
9999

100100
final int totalHits;
@@ -119,9 +119,7 @@ typedef GeneratorBuilder = Future<MasonGenerator> Function(MasonBundle);
119119
/// Flutter CLI
120120
class Flutter {
121121
/// Determine whether flutter is installed.
122-
static Future<bool> installed({
123-
required Logger logger,
124-
}) async {
122+
static Future<bool> installed({required Logger logger}) async {
125123
try {
126124
await _Cmd.run('flutter', ['--version'], logger: logger);
127125
return true;
@@ -213,14 +211,10 @@ class Flutter {
213211
? '.'
214212
: '.${p.context.separator}$relativePath';
215213

216-
stdout?.call(
217-
'Running "flutter test" in $path ...\n',
218-
);
214+
stdout?.call('Running "flutter test" in $path ...\n');
219215

220216
if (!Directory(p.join(target.dir.absolute.path, 'test')).existsSync()) {
221-
stdout?.call(
222-
'No test folder found in $path\n',
223-
);
217+
stdout?.call('No test folder found in $path\n');
224218
return ExitCode.success.code;
225219
}
226220

@@ -333,10 +327,7 @@ Future<void> _verifyGitDependencies(
333327

334328
await Future.wait(
335329
gitDependencies.map(
336-
(dependency) => Git.reachable(
337-
dependency.url,
338-
logger: logger,
339-
),
330+
(dependency) => Git.reachable(dependency.url, logger: logger),
340331
),
341332
);
342333
}
@@ -408,13 +399,11 @@ Future<int> _flutterTest({
408399
Stream.periodic(
409400
const Duration(seconds: 1),
410401
(computationCount) => computationCount,
411-
).listen(
412-
(tick) {
413-
if (completer.isCompleted) return;
414-
final timeElapsed = Duration(seconds: tick).formatted();
415-
stdout('$clearLine$timeElapsed ...');
416-
},
417-
);
402+
).listen((tick) {
403+
if (completer.isCompleted) return;
404+
final timeElapsed = Duration(seconds: tick).formatted();
405+
stdout('$clearLine$timeElapsed ...');
406+
});
418407

419408
late final StreamSubscription<TestEvent> subscription;
420409
late final StreamSubscription<ProcessSignal> sigintWatchSubscription;
@@ -429,10 +418,7 @@ Future<int> _flutterTest({
429418
subscription =
430419
testRunner(
431420
workingDirectory: cwd,
432-
arguments: [
433-
if (collectCoverage) '--coverage',
434-
...?arguments,
435-
],
421+
arguments: [if (collectCoverage) '--coverage', ...?arguments],
436422
runInShell: true,
437423
).listen(
438424
(event) {
@@ -586,9 +572,8 @@ String? _topGroupName(Test test, Map<int, TestGroup> groups) => test.groupIDs
586572
.map((groupID) => groups[groupID]?.name)
587573
.firstWhereOrNull((groupName) => groupName?.isNotEmpty ?? false);
588574

589-
Future<void> _cleanupOptimizerFile(String cwd) async => File(
590-
p.join(cwd, 'test', _testOptimizerFileName),
591-
).delete().ignore();
575+
Future<void> _cleanupOptimizerFile(String cwd) async =>
576+
File(p.join(cwd, 'test', _testOptimizerFileName)).delete().ignore();
592577

593578
final int _lineLength = () {
594579
try {

lib/src/cli/git_cli.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ Make sure the remote exists and you have the correct access rights.''';
2121
/// Git CLI
2222
class Git {
2323
/// Determine whether the [remote] is reachable.
24-
static Future<void> reachable(
25-
Uri remote, {
26-
required Logger logger,
27-
}) async {
24+
static Future<void> reachable(Uri remote, {required Logger logger}) async {
2825
try {
29-
await _Cmd.run(
30-
'git',
31-
['ls-remote', '$remote', '--exit-code'],
32-
logger: logger,
33-
);
26+
await _Cmd.run('git', [
27+
'ls-remote',
28+
'$remote',
29+
'--exit-code',
30+
], logger: logger);
3431
} on Exception catch (_) {
3532
throw UnreachableGitDependency(remote: remote);
3633
}

lib/src/command_runner.dart

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ class VeryGoodCommandRunner extends CompletionCommandRunner<int> {
2727
_environment = environment ?? Platform.environment,
2828
super('very_good', '🦄 A Very Good Command-Line Interface') {
2929
argParser
30-
..addFlag(
31-
'version',
32-
negatable: false,
33-
help: 'Print the current version.',
34-
)
30+
..addFlag('version', negatable: false, help: 'Print the current version.')
3531
..addFlag(
3632
'verbose',
3733
help: 'Noisy logging, including all shell commands executed.',
@@ -139,22 +135,19 @@ class VeryGoodCommandRunner extends CompletionCommandRunner<int> {
139135
if (!isUpToDate) {
140136
_logger
141137
..info('')
142-
..info(
143-
'''
138+
..info('''
144139
${lightYellow.wrap('Update available!')} ${lightCyan.wrap(packageVersion)} \u2192 ${lightCyan.wrap(latestVersion)}
145140
${lightYellow.wrap('Changelog:')} ${lightCyan.wrap('https://github.com/verygoodopensource/very_good_cli/releases/tag/v$latestVersion')}
146-
Run ${lightCyan.wrap('very_good update')} to update''',
147-
);
141+
Run ${lightCyan.wrap('very_good update')} to update''');
148142
}
149143
} on Exception catch (_) {}
150144
}
151145

152146
void _showThankYou() {
153147
if (environment.containsKey('CI')) return;
154148

155-
final versionFile = File(
156-
path.join(_configDir.path, 'version'),
157-
)..createSync(recursive: true);
149+
final versionFile = File(path.join(_configDir.path, 'version'))
150+
..createSync(recursive: true);
158151

159152
if (versionFile.readAsStringSync() == packageVersion) return;
160153
versionFile.writeAsStringSync(packageVersion);

lib/src/commands/create/commands/create_subcommand.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,7 @@ mixin MultiTemplates on CreateSubCommand {
293293
final templateName =
294294
argResults['template'] as String? ?? defaultTemplateName;
295295

296-
return templates.firstWhere(
297-
(element) => element.name == templateName,
298-
);
296+
return templates.firstWhere((element) => element.name == templateName);
299297
}
300298
}
301299

lib/src/commands/packages/commands/check/check.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ import 'package:very_good_cli/src/commands/packages/commands/check/commands/comm
88
/// {@endtemplate}
99
class PackagesCheckCommand extends Command<int> {
1010
/// {@macro packages_check_command}
11-
PackagesCheckCommand({
12-
Logger? logger,
13-
}) {
14-
addSubcommand(
15-
PackagesCheckLicensesCommand(logger: logger),
16-
);
11+
PackagesCheckCommand({Logger? logger}) {
12+
addSubcommand(PackagesCheckLicensesCommand(logger: logger));
1713
}
1814

1915
@override

lib/src/commands/packages/commands/check/commands/licenses.dart

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import 'package:very_good_cli/src/pubspec_lock/pubspec_lock.dart';
2424

2525
/// Overrides the [package_config.findPackageConfig] function for testing.
2626
@visibleForTesting
27-
Future<package_config.PackageConfig?> Function(
28-
Directory directory,
29-
)?
27+
Future<package_config.PackageConfig?> Function(Directory directory)?
3028
findPackageConfigOverride;
3129

3230
/// Overrides the [detector.detectLicense] function for testing.
@@ -72,9 +70,8 @@ typedef _BannedDependencyLicenseMap = Map<String, Set<String>>;
7270
/// {@endtemplate}
7371
class PackagesCheckLicensesCommand extends Command<int> {
7472
/// {@macro packages_check_licenses_command}
75-
PackagesCheckLicensesCommand({
76-
Logger? logger,
77-
}) : _logger = logger ?? Logger() {
73+
PackagesCheckLicensesCommand({Logger? logger})
74+
: _logger = logger ?? Logger() {
7875
argParser
7976
..addFlag(
8077
'ignore-retrieval-failures',
@@ -102,10 +99,7 @@ class PackagesCheckLicensesCommand extends Command<int> {
10299
'allowed',
103100
help: 'Only allow the use of certain licenses.',
104101
)
105-
..addMultiOption(
106-
'forbidden',
107-
help: 'Deny the use of certain licenses.',
108-
)
102+
..addMultiOption('forbidden', help: 'Deny the use of certain licenses.')
109103
..addMultiOption(
110104
'skip-packages',
111105
help: 'Skip packages from having their licenses checked.',
@@ -459,20 +453,20 @@ String _composeReport({
459453
}
460454

461455
String _composeBannedReport(_BannedDependencyLicenseMap bannedDependencies) {
462-
final bannedDependenciesList = bannedDependencies.entries.fold(
463-
<String>[],
464-
(previousValue, element) {
465-
final dependencyName = element.key;
466-
final dependencyLicenses = element.value;
467-
468-
final text =
469-
'$dependencyName (${link(
470-
uri: pubLicenseUri(dependencyName),
471-
message: dependencyLicenses.toList().stringify(),
472-
)})';
473-
return previousValue..add(text);
474-
},
475-
);
456+
final bannedDependenciesList = bannedDependencies.entries.fold(<String>[], (
457+
previousValue,
458+
element,
459+
) {
460+
final dependencyName = element.key;
461+
final dependencyLicenses = element.value;
462+
final hyperlink = link(
463+
uri: pubLicenseUri(dependencyName),
464+
message: dependencyLicenses.toList().stringify(),
465+
);
466+
467+
final text = '$dependencyName ($hyperlink)';
468+
return previousValue..add(text);
469+
});
476470
final bannedLicenseTypes = bannedDependencies.values.fold(<String>{}, (
477471
previousValue,
478472
licenses,

lib/src/commands/test/test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ class TestCommand extends Command<int> {
153153
final recursive = _argResults['recursive'] as bool;
154154

155155
if (!recursive && !pubspec.existsSync()) {
156-
_logger.err(
157-
'''
156+
_logger.err('''
158157
Could not find a pubspec.yaml in $targetPath.
159-
This command should be run from the root of your Flutter project.''',
160-
);
158+
This command should be run from the root of your Flutter project.''');
161159
return ExitCode.noInput.code;
162160
}
163161

0 commit comments

Comments
 (0)