Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Sort out the mixture of effective_dart and flutter_lints #808

Merged
merged 1 commit into from
Apr 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:effective_dart/analysis_options.yaml
include: package:flutter_lints/flutter.yaml

analyzer:
exclude:
Expand All @@ -11,6 +11,6 @@ linter:
rules:
constant_identifier_names: false
lines_longer_than_80_chars: false
# prefer_const_constructors: true
prefer_const_constructors: false # TODO: enable
public_member_api_docs: false
sort_pub_dependencies: true
2 changes: 2 additions & 0 deletions packages/subiquity_client/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class SubiquityException implements Exception {
final String method;
final int statusCode;
final String message;

@override
String toString() => '$method returned error $statusCode\n$message';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/subiquity_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.1
effective_dart: ^1.3.1
flutter_lints: ^1.0.0
freezed: ^0.14.1
json_serializable: ^4.1.1
mockito: ^5.0.14
Expand Down
9 changes: 4 additions & 5 deletions packages/subiquity_client/test/subiquity_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:test/test.dart';
void main() {
late SubiquityServer _testServer;
late SubiquityClient _client;
var _socketPath;

test('initialization', () async {
final client = SubiquityClient();
Expand All @@ -21,15 +20,15 @@ void main() {
setUpAll(() async {
_testServer = SubiquityServer();
_client = SubiquityClient();
_socketPath = await _testServer.start(ServerMode.DRY_RUN, args: [
final socketPath = await _testServer.start(ServerMode.DRY_RUN, args: [
'--machine-config',
'examples/simple.json',
'--source-catalog',
'${Directory.current.path}/test/install-sources.yaml',
'--bootloader',
'uefi',
]);
_client.open(_socketPath);
_client.open(socketPath);
});

tearDownAll(() async {
Expand Down Expand Up @@ -441,8 +440,8 @@ void main() {
setUpAll(() async {
_testServer = SubiquityServer.wsl();
_client = SubiquityClient();
_socketPath = await _testServer.start(ServerMode.DRY_RUN);
_client.open(_socketPath);
final socketPath = await _testServer.start(ServerMode.DRY_RUN);
_client.open(socketPath);
});

tearDownAll(() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PartitionFormat {
/// The type of the partition format (e.g. 'ext4').
final String type;

@override
String toString() => type;

static const btrfs = PartitionFormat._('btrfs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'storage_columns.dart';
import 'storage_table.dart';

class PartitionBar extends StatelessWidget {
PartitionBar({Key? key}) : super(key: key);
const PartitionBar({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import 'configure_secure_boot_model.dart';
import 'configure_secure_boot_widgets.dart';

class ConfigureSecureBootPage extends StatefulWidget {
@visibleForTesting
const ConfigureSecureBootPage({Key? key}) : super(key: key);

@override
_ConfigureSecureBootPageState createState() =>
_ConfigureSecureBootPageState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class ConnectToInternetModel extends SafeChangeNotifier
}
}

@override
Future<void> cleanup() async {
for (final model in _connectModels.values) {
await model.cleanup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ abstract class NetworkModel<T extends NetworkDevice>

bool? _wasEnabled;
bool? _hadActiveConnection;

@override
Stream get onAvailabilityChanged => _onAvailable.stream;
final _onAvailable = StreamController();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class WifiDevice extends NetworkDevice {
_setLastScan(wireless?.lastScan ?? -1);
_setScanning(false);
if (_completer?.isCompleted == false) {
_completer!.complete(device);
_completer!.complete();
}
_completer = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class InstallationSlidesModel extends ChangeNotifier with SystemShutdown {
}

/// Requests an immediate system reboot.
@override
Future<void> reboot({bool immediate = true}) {
return super.reboot(immediate: immediate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TryOrInstallModel extends ChangeNotifier {
.readAsLinesSync()
.firstWhere((line) => line.trim().isNotEmpty);
return url.replaceAll(r'${LANG}', locale.languageCode);
// ignore: avoid_catches_without_on_clauses
// ignore: empty_catches
} catch (e) {}
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import '../../services.dart';
import 'turn_off_bitlocker_model.dart';

class TurnOffBitLockerPage extends StatelessWidget {
@visibleForTesting
const TurnOffBitLockerPage({Key? key}) : super(key: key);

static Widget create(BuildContext context) {
final client = getService<SubiquityClient>();
return Provider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import '../../services.dart';
import 'updates_other_software_model.dart';

class UpdatesOtherSoftwarePage extends StatefulWidget {
@visibleForTesting
const UpdatesOtherSoftwarePage({Key? key}) : super(key: key);

@override
_UpdatesOtherSoftwarePageState createState() =>
_UpdatesOtherSoftwarePageState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Slide {
/// Provides access to the slides in the current context.
class SlidesContext extends InheritedWidget {
/// Creates an inherited slide widget with the specified slides.
SlidesContext({
const SlidesContext({
Key? key,
required this.slides,
required Widget child,
Expand Down
2 changes: 1 addition & 1 deletion packages/ubuntu_desktop_installer/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.5
effective_dart: ^1.3.1
fake_async: ^1.2.0
flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
integration_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() {
return MaterialApp(
home: StorageTable(
columns: columns,
storages: [sda, sdb, sdc, sdd],
storages: const [sda, sdb, sdc, sdd],
canSelect: canSelect,
isSelected: isSelected,
onSelected: onSelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void main() {
});

test('enable', () async {
when(service.setWirelessEnabled(true)).thenAnswer((_) async => null);
when(service.setWirelessEnabled(true)).thenAnswer((_) async {});

model.enable();
verify(service.setWirelessEnabled(true)).called(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
await tester.pumpWidget(
tester.buildApp(
(_) => DetectKeyboardLayoutView(
pressKey: ['x', 'y', 'z'],
pressKey: const ['x', 'y', 'z'],
onKeyPress: (code) => keyPress = code,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void main() {

test('set locale', () {
final client = MockSubiquityClient();
when(client.setLocale('fr_CA.UTF-8')).thenAnswer((_) async => null);
when(client.setLocale('fr_CA.UTF-8')).thenAnswer((_) async {});

final model = WelcomeModel(client);
model.applyLocale(Locale('fr', 'CA'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void main() {
final location = GeoLocation(timezone: 'Europe/Oslo');

final client = MockSubiquityClient();
when(client.setTimezone('geoip')).thenAnswer((_) async => null);
when(client.setTimezone(location.timezone)).thenAnswer((_) async => null);
when(client.setTimezone('geoip')).thenAnswer((_) async {});
when(client.setTimezone(location.timezone)).thenAnswer((_) async {});
final service = MockGeoService();

final model = WhereAreYouModel(client: client, service: service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void main() {

final model = buildModel();
when(model.searchLocation('b')).thenAnswer((_) async => locations);
when(model.selectLocation(GeoLocation())).thenReturn((_) {});
when(model.selectLocation(GeoLocation())).thenAnswer((_) {});

await tester.pumpWidget(tester.buildApp((_) => buildPage(model)));

Expand Down Expand Up @@ -120,7 +120,7 @@ void main() {

final model = buildModel();
when(model.searchTimezone('b')).thenAnswer((_) async => timezones);
when(model.selectTimezone(GeoLocation())).thenReturn((_) {});
when(model.selectTimezone(GeoLocation())).thenAnswer((_) {});

await tester.pumpWidget(tester.buildApp((_) => buildPage(model)));

Expand Down
2 changes: 1 addition & 1 deletion packages/ubuntu_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ environment:

dependencies:
build_runner: ^2.1.1
effective_dart: ^1.3.1
flutter:
sdk: flutter
flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
gsettings: ^0.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ class ProductInfoExtractor {

try {
_cachedProductInfo ??= _extractIsoInfo(_fileSystem.file(isoPath));
// ignore: empty_catches
} on Exception {}

try {
_cachedProductInfo ??= _extractLocalInfo(_fileSystem.file(localPath));
// ignore: empty_catches
} on Exception {}

_cachedProductInfo ??= ProductInfo(name: 'Ubuntu');
Expand Down
2 changes: 1 addition & 1 deletion packages/ubuntu_wizard/lib/src/widgets/flavor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FlavorData {
/// Provides access to the flavor data in the current context.
class Flavor extends InheritedWidget {
/// Creates an inherited flavor widget with the specified flavor data.
Flavor({
const Flavor({
Key? key,
required this.data,
required Widget child,
Expand Down
1 change: 0 additions & 1 deletion packages/ubuntu_wizard/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.5
effective_dart: ^1.3.2
flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
Expand Down
2 changes: 1 addition & 1 deletion packages/ubuntu_wizard/test/form_layout_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
child: FormLayout(
rowSpacing: 10,
columnSpacing: 20,
rows: [
rows: const [
[
SizedBox(key: Key('r0c0'), width: 100, height: 10),
SizedBox(key: Key('r0c1'), width: 200, height: 10),
Expand Down
18 changes: 9 additions & 9 deletions packages/ubuntu_wizard/test/product_info_extractor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() {
});

test('should return product info when iso file exists', () async {
final isoPath = '/cdrom/.disk/info';
const isoPath = '/cdrom/.disk/info';

await fileSystem.file(isoPath).create(recursive: true).then((f) {
f.writeAsString(
Expand All @@ -31,7 +31,7 @@ void main() {

test('should return product info from disk when iso file doesnt exists',
() async {
final localPath = '/etc/os-release';
const localPath = '/etc/os-release';

await fileSystem.file(localPath).create(recursive: true).then((f) {
f.writeAsString('''
Expand Down Expand Up @@ -68,7 +68,7 @@ UBUNTU_CODENAME=hirsute
});

test('should return product info with LTS when iso file exists', () async {
final isoPath = '/cdrom/.disk/info';
const isoPath = '/cdrom/.disk/info';

await fileSystem.file(isoPath).create(recursive: true).then((f) {
f.writeAsString(
Expand All @@ -84,7 +84,7 @@ UBUNTU_CODENAME=hirsute

test('should return product info LTS from disk when iso file doesnt exists',
() async {
final localPath = '/etc/os-release';
const localPath = '/etc/os-release';

await fileSystem.file(localPath).create(recursive: true).then((f) {
f.writeAsString('''
Expand Down Expand Up @@ -112,7 +112,7 @@ UBUNTU_CODENAME=focal
});

test('should return product info for kubuntu', () async {
final isoPath = '/cdrom/.disk/info';
const isoPath = '/cdrom/.disk/info';

await fileSystem.file(isoPath).create(recursive: true).then((f) {
f.writeAsString(
Expand All @@ -127,7 +127,7 @@ UBUNTU_CODENAME=focal
});

test('should return product info for kubuntu', () async {
final isoPath = '/cdrom/.disk/info';
const isoPath = '/cdrom/.disk/info';

await fileSystem.file(isoPath).create(recursive: true).then((f) {
f.writeAsString(
Expand All @@ -142,7 +142,7 @@ UBUNTU_CODENAME=focal
});

test('should return product info for ubuntu mate', () async {
final isoPath = '/cdrom/.disk/info';
const isoPath = '/cdrom/.disk/info';

await fileSystem.file(isoPath).create(recursive: true).then((f) {
f.writeAsString(
Expand All @@ -157,7 +157,7 @@ UBUNTU_CODENAME=focal
});

test('should cache product info', () async {
final isoPath = '/cdrom/.disk/info';
const isoPath = '/cdrom/.disk/info';

await fileSystem.file(isoPath).create(recursive: true).then((f) {
f.writeAsString(
Expand All @@ -179,7 +179,7 @@ UBUNTU_CODENAME=focal
});

test('should reset cache when paramter is passed', () async {
final isoPath = '/cdrom/.disk/info';
const isoPath = '/cdrom/.disk/info';

await fileSystem.file(isoPath).create(recursive: true).then((f) {
f.writeAsString(
Expand Down
2 changes: 1 addition & 1 deletion packages/ubuntu_wizard/test/settings_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:ubuntu_wizard/settings.dart';
void main() {
test('set gtk-theme via gsettings', () {
final gsettings = MockGSettings();
when(gsettings.set(any, any)).thenAnswer((_) async => null);
when(gsettings.set(any, any)).thenAnswer((_) async {});

final settings = Settings(gsettings);

Expand Down
1 change: 1 addition & 0 deletions packages/ubuntu_wizard/test/system_shutdown_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ typedef SystemShutdownTester = Future<void> Function(SystemShutdown system);
class TestSystemShutdown with SystemShutdown {
TestSystemShutdown(this.client);

@override
final SubiquityClient client;
}

Expand Down