Skip to content

Commit

Permalink
analysis updates and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomarra committed Dec 20, 2024
1 parent 9a8fef2 commit 2acece7
Show file tree
Hide file tree
Showing 24 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:very_good_analysis/analysis_options.5.1.0.yaml
include: package:very_good_analysis/analysis_options.7.0.0.yaml
analyzer:
exclude:
- "**/version.dart"
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/dart_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Dart {
try {
await _Cmd.run('dart', ['--version'], logger: logger);
return true;
} catch (_) {
} on Exception catch (_) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Flutter {
try {
await _Cmd.run('flutter', ['--version'], logger: logger);
return true;
} catch (_) {
} on Exception catch (_) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/git_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Git {
['ls-remote', '$remote', '--exit-code'],
logger: logger,
);
} catch (_) {
} on Exception catch (_) {
throw UnreachableGitDependency(remote: remote);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ${lightYellow.wrap('Changelog:')} ${lightCyan.wrap('https://github.com/verygoodo
Run ${lightCyan.wrap('very_good update')} to update''',
);
}
} catch (_) {}
} on Exception catch (_) {}
}

void _showThankYou() {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/create/commands/create_subcommand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ abstract class CreateSubCommand extends Command<int> {
'''Building generator from brick: ${brick.name} ${brick.location.version}''',
);
return await _generatorFromBrick(brick);
} catch (error) {
} on Exception catch (error) {
logger.detail('Building generator from brick failed: $error');
}
logger.detail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class PackagesCheckLicensesCommand extends Command<int> {
try {
detectorResult =
await detectLicense(licenseFileContent, _defaultDetectionThreshold);
} catch (e) {
} on Exception catch (e) {
final errorMessage =
'''[$dependencyName] Failed to detect license from $packagePath: $e''';
if (!ignoreFailures) {
Expand Down Expand Up @@ -330,7 +330,7 @@ PubspecLock? _tryParsePubspecLock(File pubspecLockFile) {
final content = pubspecLockFile.readAsStringSync();
try {
return PubspecLock.fromString(content);
} catch (_) {}
} on Exception catch (_) {}
}

return null;
Expand All @@ -348,7 +348,7 @@ Future<package_config.PackageConfig?> _tryFindPackageConfig(
final findPackageConfig =
findPackageConfigOverride ?? package_config.findPackageConfig;
return await findPackageConfig(directory);
} catch (error) {
} on Exception {
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/packages/commands/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PackagesGetCommand extends Command<int> {
} on PubspecNotFound catch (_) {
_logger.err('Could not find a pubspec.yaml in $targetPath');
return ExitCode.noInput.code;
} catch (error) {
} on Exception catch (error) {
_logger.err('$error');
return ExitCode.unavailable.code;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/test/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ This command should be run from the root of your Flutter project.''',
'''Expected coverage >= ${minCoverage.toStringAsFixed(decimalPlaces)}% but actual is ${e.coverage.toStringAsFixed(decimalPlaces)}%.''',
);
return ExitCode.unavailable.code;
} catch (error) {
} on Exception catch (error) {
_logger.err('$error');
return ExitCode.unavailable.code;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/commands/update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UpdateCommand extends Command<int> {
late final String latestVersion;
try {
latestVersion = await _pubUpdater.getLatestVersion(packageName);
} catch (error) {
} on Exception catch (error) {
updateCheckProgress.fail();
_logger.err('$error');
return ExitCode.software.code;
Expand All @@ -57,7 +57,7 @@ class UpdateCommand extends Command<int> {
packageName: packageName,
versionConstraint: latestVersion,
);
} catch (error) {
} on Exception catch (error) {
updateProgress.fail();
_logger.err('$error');
return ExitCode.software.code;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/pubspec_lock/pubspec_lock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// source of the dependencies to analyze. Hence, it is not a complete parser,
/// it only parses the information that is needed for the
/// `packages check license` command.
library pubspec_lock;
library;

import 'dart:collection';

Expand Down Expand Up @@ -38,7 +38,7 @@ class PubspecLock {
late final YamlMap yaml;
try {
yaml = loadYaml(content) as YamlMap;
} catch (_) {
} on Exception catch (_) {
throw const PubspecLockParseException();
}

Expand All @@ -56,7 +56,7 @@ class PubspecLock {
data: entry.value as YamlMap,
);
parsedPackages.add(package);
} catch (_) {
} on Exception catch (_) {
// Ignore those packages that for some reason cannot be parsed.
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/very_good_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
/// # see usage
/// very_good --help
/// ```
library very_good_cli;
library;
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dev_dependencies:
build_version: ^2.1.1
mocktail: ^1.0.4
test: ^1.25.8
very_good_analysis: ">=6.0.0 <8.0.0"
very_good_analysis: ^7.0.0

executables:
very_good:
2 changes: 1 addition & 1 deletion test/ensure_build_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@Tags(['pull-request-only'])
library ensure_build_test;
library;

import 'package:build_verify/build_verify.dart';
import 'package:test/test.dart';
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/command_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void Function() withRunner(
environment: {'CI': 'true'},
);

when(() => progress.complete(any())).thenAnswer((_) {
final message = _.positionalArguments.elementAt(0) as String?;
when(() => progress.complete(any())).thenAnswer((a) {
final message = a.positionalArguments.elementAt(0) as String?;
if (message != null) progressLogs.add(message);
});
when(() => logger.progress(any())).thenReturn(progress);
Expand Down
4 changes: 2 additions & 2 deletions test/src/command_runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void main() {
).thenAnswer((_) => Future.value(true));
final progress = _MockProgress();
final progressLogs = <String>[];
when(() => progress.complete(any())).thenAnswer((_) {
final message = _.positionalArguments.elementAt(0) as String?;
when(() => progress.complete(any())).thenAnswer((a) {
final message = a.positionalArguments.elementAt(0) as String?;
if (message != null) progressLogs.add(message);
});
when(() => logger.progress(any())).thenReturn(progress);
Expand Down
4 changes: 2 additions & 2 deletions test/src/commands/create/commands/dart_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ void main() {
vars: any(named: 'vars'),
logger: any(named: 'logger'),
),
).thenAnswer((_) async {
).thenAnswer((a) async {
final target =
_.positionalArguments.first as DirectoryGeneratorTarget;
a.positionalArguments.first as DirectoryGeneratorTarget;
File(path.join(target.dir.path, 'my_cli', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspec);
Expand Down
4 changes: 2 additions & 2 deletions test/src/commands/create/commands/dart_package_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ void main() {
vars: any(named: 'vars'),
logger: any(named: 'logger'),
),
).thenAnswer((_) async {
).thenAnswer((a) async {
final target =
_.positionalArguments.first as DirectoryGeneratorTarget;
a.positionalArguments.first as DirectoryGeneratorTarget;
File(path.join(target.dir.path, 'my_package', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspec);
Expand Down
4 changes: 2 additions & 2 deletions test/src/commands/create/commands/docs_site_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ void main() {
vars: any(named: 'vars'),
logger: any(named: 'logger'),
),
).thenAnswer((_) async {
).thenAnswer((a) async {
final target =
_.positionalArguments.first as DirectoryGeneratorTarget;
a.positionalArguments.first as DirectoryGeneratorTarget;
File(path.join(target.dir.path, 'my_docs_site', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspec);
Expand Down
8 changes: 4 additions & 4 deletions test/src/commands/create/commands/flame_game_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void main() {
logger = _MockLogger();

final progress = _MockProgress();
when(() => progress.complete(any())).thenAnswer((_) {
final message = _.positionalArguments.elementAt(0) as String?;
when(() => progress.complete(any())).thenAnswer((a) {
final message = a.positionalArguments.elementAt(0) as String?;
if (message != null) progressLogs.add(message);
});
when(() => logger.progress(any())).thenReturn(progress);
Expand Down Expand Up @@ -148,9 +148,9 @@ void main() {
vars: any(named: 'vars'),
logger: any(named: 'logger'),
),
).thenAnswer((_) async {
).thenAnswer((a) async {
final target =
_.positionalArguments.first as DirectoryGeneratorTarget;
a.positionalArguments.first as DirectoryGeneratorTarget;
File(path.join(target.dir.path, 'my_app', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspec);
Expand Down
8 changes: 4 additions & 4 deletions test/src/commands/create/commands/flutter_app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void main() {
logger = _MockLogger();

final progress = _MockProgress();
when(() => progress.complete(any())).thenAnswer((_) {
final message = _.positionalArguments.elementAt(0) as String?;
when(() => progress.complete(any())).thenAnswer((a) {
final message = a.positionalArguments.elementAt(0) as String?;
if (message != null) progressLogs.add(message);
});
when(() => logger.progress(any())).thenReturn(progress);
Expand Down Expand Up @@ -141,9 +141,9 @@ void main() {
vars: any(named: 'vars'),
logger: any(named: 'logger'),
),
).thenAnswer((_) async {
).thenAnswer((a) async {
final target =
_.positionalArguments.first as DirectoryGeneratorTarget;
a.positionalArguments.first as DirectoryGeneratorTarget;
File(path.join(target.dir.path, 'my_app', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspec);
Expand Down
4 changes: 2 additions & 2 deletions test/src/commands/create/commands/flutter_package_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ void main() {
vars: any(named: 'vars'),
logger: any(named: 'logger'),
),
).thenAnswer((_) async {
).thenAnswer((a) async {
final target =
_.positionalArguments.first as DirectoryGeneratorTarget;
a.positionalArguments.first as DirectoryGeneratorTarget;
File(path.join(target.dir.path, 'my_flutter_package', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspec);
Expand Down
4 changes: 2 additions & 2 deletions test/src/commands/create/commands/flutter_plugin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ void main() {
vars: any(named: 'vars'),
logger: any(named: 'logger'),
),
).thenAnswer((_) async {
).thenAnswer((a) async {
final target =
_.positionalArguments.first as DirectoryGeneratorTarget;
a.positionalArguments.first as DirectoryGeneratorTarget;
File(path.join(target.dir.path, 'my_plugin', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspec);
Expand Down
4 changes: 2 additions & 2 deletions test/src/commands/create/create_subcommand_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ void main() {
logger = _MockLogger();

progress = _MockProgress();
when(() => progress.complete(any())).thenAnswer((_) {
final message = _.positionalArguments.elementAt(0) as String?;
when(() => progress.complete(any())).thenAnswer((a) {
final message = a.positionalArguments.elementAt(0) as String?;
if (message != null) progressLogs.add(message);
});
when(() => logger.progress(any())).thenReturn(progress);
Expand Down

0 comments on commit 2acece7

Please sign in to comment.