Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/dart_frog/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include: package:very_good_analysis/analysis_options.6.0.0.yaml
include: package:very_good_analysis/analysis_options.yaml
linter:
rules:
# Experimental and there are lots of false positives
specify_nonobvious_property_types: false
3 changes: 0 additions & 3 deletions packages/dart_frog/lib/dart_frog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/// A fast, minimalistic backend framework for Dart 🎯
library dart_frog;

export 'src/_internal.dart'
show
Cascade,
Expand Down
1 change: 1 addition & 0 deletions packages/dart_frog/lib/src/request_logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ part of '_internal.dart';
///
/// If [logger] is not passed, the message is just passed to [print].
Middleware requestLogger({
// ignoring to match the shelf.logRequests signature
// ignore: avoid_positional_boolean_parameters
void Function(String message, bool isError)? logger,
}) {
Expand Down
2 changes: 2 additions & 0 deletions packages/dart_frog/lib/src/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class RouterEntry {
final params = <String>[];
var pattern = '';
for (final m in _parser.allMatches(route)) {
// avoiding string_buffers to align with shelf_router
// ignore: use_string_buffers
pattern += RegExp.escape(m[1]!);
if (m[2] != null) {
Expand Down Expand Up @@ -418,6 +419,7 @@ class RouterEntry {
}

if (_handler is Handler || _params.isEmpty) {
// ignoring to align with shelf_router
// ignore: avoid_dynamic_calls
return await _handler(updatedContext) as Response;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dart_frog/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dev_dependencies:
mocktail: ^1.0.0
path: ^1.8.2
test: ^1.19.2
very_good_analysis: ">=5.1.0 <7.0.0"
very_good_analysis: ^9.0.0

false_secrets:
- test/src/serve_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignoring for testing purposes
// ignore_for_file: prefer_const_constructors
// ignore_for_file: deprecated_member_use_from_same_package

Expand Down
1 change: 1 addition & 0 deletions packages/dart_frog/test/src/http_method_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignoring for testing purposes
// ignore_for_file: prefer_const_declarations

import 'package:dart_frog/dart_frog.dart';
Expand Down
2 changes: 2 additions & 0 deletions packages/dart_frog/test/src/provider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ void main() {
Response onRequest(RequestContext context) {
try {
context.read<Uri>();
// ignoring since we need to catch the StateError for testing
// ignore: avoid_catches_without_on_clauses
} catch (e) {
exception = e;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dart_frog/test/src/request_logger_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: avoid_positional_boolean_parameters

import 'package:dart_frog/dart_frog.dart';
import 'package:mocktail/mocktail.dart';
import 'package:test/test.dart';
Expand All @@ -10,6 +8,8 @@ void main() {
group('requestLogger', () {
var gotLog = false;

// ignoring to align with shelf logger
// ignore: avoid_positional_boolean_parameters
void logger(String msg, bool isError) {
expect(gotLog, isFalse);
gotLog = true;
Expand Down
6 changes: 1 addition & 5 deletions packages/dart_frog/test/src/response_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ void main() {

group('bufferOutput', () {
test('is omitted by default', () {
final response = Response.stream(
body: const Stream.empty(),
// ignore: avoid_redundant_argument_values
bufferOutput: true,
);
final response = Response.stream(body: const Stream.empty());

expect(
response.context,
Expand Down
6 changes: 5 additions & 1 deletion packages/dart_frog_auth/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include: package:very_good_analysis/analysis_options.7.0.0.yaml
include: package:very_good_analysis/analysis_options.yaml
linter:
rules:
# Experimental and there are lots of false positives
specify_nonobvious_property_types: false
2 changes: 1 addition & 1 deletion packages/dart_frog_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:
dev_dependencies:
mocktail: ^1.0.0
test: ^1.19.2
very_good_analysis: ^7.0.0
very_good_analysis: ^9.0.0
6 changes: 5 additions & 1 deletion packages/dart_frog_cli/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
include: package:very_good_analysis/analysis_options.6.0.0.yaml
include: package:very_good_analysis/analysis_options.yaml
analyzer:
exclude:
- lib/src/version.dart
linter:
rules:
# Experimental and there are lots of false positives
specify_nonobvious_property_types: false
10 changes: 5 additions & 5 deletions packages/dart_frog_cli/e2e/test/dev_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ void main() {
});

fail('exception not thrown');
} catch (e) {
expect(e.toString(), contains('Could not start the VM service:'));
} on String catch (e) {
expect(e, contains('Could not start the VM service:'));

expect(
e.toString(),
e,
contains(
'DartDevelopmentServiceException: Failed to create server socket',
),
);

expect(e.toString(), contains('127.0.0.1:8181'));
expect(e, contains('127.0.0.1:8181'));
}
},
);
Expand Down Expand Up @@ -131,6 +131,6 @@ extension<T> on Future<T> {
Future<void> ignoreErrors() async {
try {
await this;
} catch (_) {}
} on Exception catch (_) {}
}
}
10 changes: 0 additions & 10 deletions packages/dart_frog_cli/lib/dart_frog_cli.dart

This file was deleted.

4 changes: 2 additions & 2 deletions packages/dart_frog_cli/lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class DartFrogCommandRunner extends CompletionCommandRunner<int> {
late final int exitCode;
try {
exitCode = await runCommand(argResults) ?? ExitCode.success.code;
} catch (error) {
} on Exception catch (error) {
_logger.err('$error');
exitCode = ExitCode.software.code;
}
Expand Down Expand Up @@ -123,7 +123,7 @@ ${lightYellow.wrap('Changelog:')} $changelogLink
Run ${lightCyan.wrap('$executableName update')} to update''',
);
}
} catch (error, stackTrace) {
} on Exception catch (error, stackTrace) {
_logger.detail(
'[updater] update check error.\n$error\n$stackTrace',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/dart_frog_cli/lib/src/commands/build/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BuildCommand extends DartFrogCommand {

try {
return (await builder.build()).code;
} catch (e) {
} on Exception catch (e) {
logger.err(e.toString());
return ExitCode.software.code;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dart_frog_cli/lib/src/commands/dev/dev.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class DevCommand extends DartFrogCommand {
try {
await _devServerRunner.start(results.rest);
return (await _devServerRunner.exitCode).code;
} catch (e) {
} on Exception catch (e) {
logger.err(e.toString());
return ExitCode.software.code;
} finally {
Expand Down
2 changes: 2 additions & 0 deletions packages/dart_frog_cli/lib/src/commands/new/new.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ class _NewSubCommand extends DartFrogCommand {

@visibleForTesting
@override
// ignoring for testing purposes
// ignore: invalid_use_of_visible_for_testing_member
ArgResults? get testArgResults => parent.testArgResults;

@override
// ignoring for testing purposes
// ignore: invalid_use_of_visible_for_testing_member
String? get testUsage => parent.testUsage;

Expand Down
4 changes: 2 additions & 2 deletions packages/dart_frog_cli/lib/src/commands/update/update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UpdateCommand extends DartFrogCommand {
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 @@ -70,7 +70,7 @@ class UpdateCommand extends DartFrogCommand {
packageName: packageName,
versionConstraint: latestVersion,
);
} catch (error) {
} on Exception catch (error) {
updateProgress.fail();
_logger.err('$error');
return ExitCode.software.code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class DevServerDomain extends DomainBase {
'applicationId': applicationId,
},
);
// ignoring for backward compatibility
// ignore: avoid_catches_without_on_clauses
} catch (e) {
return DaemonResponse.error(
id: request.id,
Expand Down Expand Up @@ -149,6 +151,8 @@ class DevServerDomain extends DomainBase {
'applicationId': applicationId,
},
);
// ignoring for backward compatibility
// ignore: avoid_catches_without_on_clauses
} catch (e) {
return DaemonResponse.error(
id: request.id,
Expand Down Expand Up @@ -186,6 +190,8 @@ class DevServerDomain extends DomainBase {
'exitCode': exitCode.code,
},
);
// ignoring for backward compatibility
// ignore: avoid_catches_without_on_clauses
} catch (e) {
if (!runner.isCompleted) {
_devServerRunners[applicationId] = runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class RouteConfigurationDomain extends DomainBase {
},
),
);
// ignoring for backward compatibility
// ignore: avoid_catches_without_on_clauses
} catch (e) {
return DaemonResponse.error(
id: request.id,
Expand Down Expand Up @@ -183,6 +185,8 @@ class RouteConfigurationDomain extends DomainBase {
'exitCode': exitCode.code,
},
);
// ignoring for backward compatibility
// ignore: avoid_catches_without_on_clauses
} catch (e) {
if (!watcher.isCompleted) {
_routeConfigurationWatchers[watcherId] = watcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class RouteConfigurationWatcher {
final projectDirectory = workingDirectory;
try {
routeConfiguration = _routeConfigurationBuilder(projectDirectory);
} catch (error) {
} on Exception catch (error) {
logger.err('$error');
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dart_frog_cli/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dev_dependencies:
build_version: ^2.1.1
mocktail: ^1.0.4
test: ^1.25.8
very_good_analysis: ^6.0.0
very_good_analysis: ^9.0.0

executables:
dart_frog:
3 changes: 2 additions & 1 deletion packages/dart_frog_cli/test/src/command_runner_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore_for_file: no_adjacent_strings_in_list
import 'dart:async';
import 'dart:io';

Expand All @@ -20,6 +19,8 @@ class _MockProcessSignal extends Mock implements ProcessSignal {}
class _MockStdin extends Mock implements Stdin {}

const expectedUsage = [
// ignoring for ease of testing usage
// ignore: no_adjacent_strings_in_list
'A fast, minimalistic backend framework for Dart.\n'
'\n'
'Usage: dart_frog <command> [arguments]\n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _MockProcessSignal extends Mock implements ProcessSignal {}
class _MockStdin extends Mock implements Stdin {}

const expectedUsage = [
// ignoring for ease of testing usage
// ignore: no_adjacent_strings_in_list
'Start the Dart Frog daemon\n'
'\n'
Expand All @@ -35,15 +36,21 @@ void main() {
group('dart_frog daemon', () {
late DartFrogCommandRunner commandRunner;
late Logger logger;
late PubUpdater updater;

setUp(() {
logger = _MockLogger();

updater = _MockPubUpdater();
final sigint = _MockProcessSignal();

when(sigint.watch).thenAnswer((_) => const Stream.empty());
when(
() => updater.getLatestVersion(any()),
).thenAnswer((_) async => packageVersion);

commandRunner = DartFrogCommandRunner(
logger: logger,
pubUpdater: _MockPubUpdater(),
pubUpdater: updater,
exit: (_) {},
sigint: sigint,
stdin: _MockStdin(),
Expand Down
10 changes: 8 additions & 2 deletions packages/dart_frog_cli/test/src/commands/list/list_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore_for_file: no_adjacent_strings_in_list
import 'dart:io';

import 'package:args/args.dart';
Expand Down Expand Up @@ -31,6 +30,8 @@ class _MockRouteConfiguration extends Mock implements RouteConfiguration {}
class _MockStdin extends Mock implements Stdin {}

const expectedUsage = [
// ignoring for ease of testing usage
// ignore: no_adjacent_strings_in_list
'Lists the routes on a Dart Frog project.\n'
'\n'
'Usage: dart_frog list "path/to/project"\n'
Expand All @@ -50,6 +51,7 @@ void main() {
late ArgResults argResults;
late Logger logger;
late Progress progress;
late PubUpdater updater;
late ListCommand command;
late DartFrogCommandRunner commandRunner;
late RouteConfiguration routeConfiguration;
Expand All @@ -58,6 +60,7 @@ void main() {
argResults = _MockArgResults();
logger = _MockLogger();
progress = _MockProgress();
updater = _MockPubUpdater();
routeConfiguration = _MockRouteConfiguration();
when(() => logger.progress(any())).thenReturn(progress);
command = ListCommand(
Expand All @@ -68,14 +71,17 @@ void main() {
..testUsage = 'test usage';

when(() => argResults['plain']).thenReturn(false);
when(
() => updater.getLatestVersion(any()),
).thenAnswer((_) async => packageVersion);

final sigint = _MockProcessSignal();

when(sigint.watch).thenAnswer((_) => const Stream.empty());

commandRunner = DartFrogCommandRunner(
logger: logger,
pubUpdater: _MockPubUpdater(),
pubUpdater: updater,
exit: (_) {},
sigint: sigint,
stdin: _MockStdin(),
Expand Down
Loading
Loading