Skip to content

Commit

Permalink
dartsdk 2.18 and strict
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Jan 12, 2023
1 parent 376e9c1 commit 759a363
Show file tree
Hide file tree
Showing 32 changed files with 89 additions and 105 deletions.
2 changes: 1 addition & 1 deletion repo_support/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# tekartik analysis_options extension to pedantic
include: package:tekartik_lints/recommended.yaml
include: package:tekartik_lints/strict.yaml
3 changes: 1 addition & 2 deletions repo_support/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.2.0
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dev_dependencies:
path:
Expand All @@ -23,4 +23,3 @@ dev_dependencies:
dev_test:
pedantic:


2 changes: 1 addition & 1 deletion sqflite_common_porter/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# tekartik analysis_options extension to pedantic
include: package:tekartik_lints/recommended.yaml
include: package:tekartik_lints/strict.yaml
24 changes: 9 additions & 15 deletions sqflite_common_porter/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Future<Database> openEmptyDatabase(
return db;
}

typedef PrintFunction = void Function(Object? message);
PrintFunction _print = core.print;

Iterable<String> rowsToLines(Iterable<Object?> rows) {
return rows.map((Object? row) => row.toString());
}
Expand All @@ -41,36 +44,32 @@ String formatLines(List rows) {
return '[${rowsToLines(rows).join(',\n')}]';
}

Function(Object? message) _print = core.print;

void dumpSetPrint(Function(Object? message) print) {
void dumpSetPrint(PrintFunction print) {
_print = print;
}

void dumpLines(List rows, {Function(Object? message)? print}) {
void dumpLines(List rows, {PrintFunction? print}) {
print ??= _print;
rowsToLines(rows).toList().forEach((line) {
print!(line);
});
}

void dumpLine(Object? line, {Function(Object? message)? print}) {
void dumpLine(Object? line, {PrintFunction? print}) {
print ??= _print;
print(line);
}

Future dumpTableDefinitions(Database db,
{Function(Object? message)? print}) async {
Future dumpTableDefinitions(Database db, {PrintFunction? print}) async {
dumpLines(await db.query('sqlite_master'), print: print);
}

Future dumpTable(Database db, String table,
{Function(Object? message)? print}) async {
Future dumpTable(Database db, String table, {PrintFunction? print}) async {
dumpLine('TABLE: $table', print: print);
dumpLines(await db.query(table), print: print);
}

Future dumpTables(Database db, {Function(Object? message)? print}) async {
Future dumpTables(Database db, {PrintFunction? print}) async {
for (var row in await db.query('sqlite_master', columns: ['name'])) {
var table = row.values.first as String;
await dumpTable(db, table, print: print);
Expand All @@ -89,8 +88,3 @@ Future<Database> importSqlDatabase(DatabaseFactory factory, String dbName,
}));
return db;
}

String bookshelfSql = '''
CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT);
INSERT INTO book(title) VALUES ('Le petit prince');
INSERT INTO book(title) VALUES ('Harry Potter');''';
3 changes: 1 addition & 2 deletions sqflite_common_porter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.3.0
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
path: any
Expand All @@ -21,4 +21,3 @@ dev_dependencies:
test:
process_run: '>=0.10.3'
dev_test:

2 changes: 1 addition & 1 deletion sqflite_common_porter/test/sqflite_porter_ffi_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() {
test('export empty', () async {
var db = await factory.openDatabase(inMemoryDatabasePath);
var export = await dbExportSql(db);
expect(export, []);
expect(export, isEmpty);

await db.close();
db = await openDatabaseInMemoryFromSqlImport(factory, export);
Expand Down
6 changes: 5 additions & 1 deletion sqflite_common_porter/test/src_utils_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'package:dev_test/test.dart';
import 'package:sqflite_common_porter/src/sql_parser.dart';
import 'package:sqflite_common_porter/src/utils.dart';

String bookshelfSql = '''
CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT);
INSERT INTO book(title) VALUES ('Le petit prince');
INSERT INTO book(title) VALUES ('Harry Potter');''';

void main() {
group('src_utils', () {
Expand Down
2 changes: 1 addition & 1 deletion sqflite_common_server/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# tekartik analysis_options extension to pedantic
include: package:tekartik_lints/recommended.yaml
include: package:tekartik_lints/strict.yaml
2 changes: 1 addition & 1 deletion sqflite_common_server/lib/sqflite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SqfliteServerContext implements SqfliteContext {
bool get supportsWithoutRowId =>
client!.serverInfo.supportsWithoutRowId == true;

Future<T?> sendRequest<T>(String method, Object? param) async {
Future<T> sendRequest<T>(String method, Object? param) async {
return await _client!.sendRequest<T>(method, param);
}

Expand Down
2 changes: 1 addition & 1 deletion sqflite_common_server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.3.3
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
path:
Expand Down
4 changes: 2 additions & 2 deletions sqflite_common_server/test/sqflite_server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void main() {
);

var result = await sqfliteClient
.invoke('openDatabase', {'path': inMemoryDatabasePath});
expect((result as Map)['id'], const TypeMatcher<int>());
.invoke<Map>('openDatabase', {'path': inMemoryDatabasePath});
expect(result['id'], const TypeMatcher<int>());

expect(sqfliteClient, isNotNull);

Expand Down
2 changes: 1 addition & 1 deletion sqflite_common_test_app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:tekartik_lints_flutter/recommended.yaml
include: package:tekartik_lints/strict.yaml

linter:
rules:
Expand Down
2 changes: 1 addition & 1 deletion sqflite_common_test_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://github.com/tekartik/sqflite_more/tree/master/sqflite_common_te
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
sqflite_common:
Expand Down
2 changes: 1 addition & 1 deletion sqflite_porter/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# tekartik analysis_options extension to pedantic
include: package:tekartik_lints/recommended.yaml
include: package:tekartik_lints_flutter/strict.yaml
55 changes: 5 additions & 50 deletions sqflite_porter/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import 'dart:core' as core;
import 'dart:core';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_porter/src/sql_parser.dart';
import 'package:sqflite_porter/src/sqlite_porter.dart';
export 'package:sqflite_common_porter/src/utils.dart';

Future<String> initEmptyDb(String dbName) async {
var databasePath = await getDatabasesPath();
Expand All @@ -20,7 +22,9 @@ Future<String> initEmptyDb(String dbName) async {
try {
await Directory(dirname(path)).create(recursive: true);
} catch (e) {
print(e);
if (kDebugMode) {
print(e);
}
}
}
return path;
Expand All @@ -32,50 +36,6 @@ Future<Database> openEmptyDatabase(String dbName) async {
return db;
}

Iterable<String> rowsToLines(Iterable<Object?> rows) {
return rows.map((Object? row) => row.toString());
}

String formatLines(List rows) {
return '[${rowsToLines(rows).join(',\n')}]';
}

Function(Object? message) _print = core.print;

void dumpSetPrint(Function(Object? message) print) {
_print = print;
}

void dumpLines(List rows, {Function(Object? message)? print}) {
print ??= _print;
rowsToLines(rows).toList().forEach((line) {
print!(line);
});
}

void dumpLine(Object? line, {Function(Object? message)? print}) {
print ??= _print;
print(line);
}

Future dumpTableDefinitions(Database db,
{Function(Object? message)? print}) async {
dumpLines(await db.query('sqlite_master'), print: print);
}

Future dumpTable(Database db, String table,
{Function(Object? message)? print}) async {
dumpLine('TABLE: $table', print: print);
dumpLines(await db.query(table), print: print);
}

Future dumpTables(Database db, {Function(Object? message)? print}) async {
for (var row in await db.query('sqlite_master', columns: ['name'])) {
var table = row.values.first as String;
await dumpTable(db, table, print: print);
}
}

Future<Database> importSqlDatabase(String dbName,
{String? sql, List<String>? sqlStatements}) async {
sqlStatements ??= parseStatements(sql);
Expand All @@ -86,8 +46,3 @@ Future<Database> importSqlDatabase(String dbName,
});
return db;
}

String bookshelfSql = '''
CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT);
INSERT INTO book(title) VALUES ('Le petit prince');
INSERT INTO book(title) VALUES ('Harry Potter');''';
17 changes: 15 additions & 2 deletions sqflite_porter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.2.0+1
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
flutter:
Expand All @@ -23,15 +23,28 @@ dependencies:
path: sqflite_test
version: '>=0.1.0'
csv:
sqflite_common_porter:
git:
url: https://github.com/tekartik/sqflite_more
ref: dart2_3
path: sqflite_common_porter
version: '>=0.2.0'

dev_dependencies:
flutter_test:
sdk: flutter
test:
process_run: '>=0.10.3'
dev_test:

tekartik_lints_flutter:
git:
url: https://github.com/tekartik/common_flutter.dart
ref: dart2_3
path: packages/lints_flutter
version: '>=0.1.0'
dependency_overrides:
sqflite_common_porter:
path: ../sqflite_common_porter
sqflite_test:
path: ../sqflite_test
sqflite_common_server:
Expand Down
2 changes: 2 additions & 0 deletions sqflite_porter/test/csv_utils_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

import 'dart:convert';
import 'dart:typed_data';

Expand Down
8 changes: 4 additions & 4 deletions sqflite_porter/test/db_csv_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import 'package:test/test.dart';

import 'csv_utils_test.dart';

final String tableTodo = 'todo';
final String columnId = '_id';
final String columnTitle = 'title';
final String columnDone = 'done';
const String tableTodo = 'todo';
const String columnId = '_id';
const String columnTitle = 'title';
const String columnDone = 'done';

Future main() {
return testMain(run);
Expand Down
6 changes: 5 additions & 1 deletion sqflite_porter/test/src_utils_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_porter/src/sql_parser.dart';
import 'package:sqflite_porter/src/utils.dart';

String bookshelfSql = '''
CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT);
INSERT INTO book(title) VALUES ('Le petit prince');
INSERT INTO book(title) VALUES ('Harry Potter');''';

void main() {
group('src_utils', () {
Expand Down
2 changes: 1 addition & 1 deletion sqflite_server_app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tekartik analysis_options extension to pedantic
include: package:tekartik_lints_flutter/recommended.yaml
include: package:tekartik_lints_flutter/strict.yaml

linter:
rules:
Expand Down
4 changes: 3 additions & 1 deletion sqflite_server_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publish_to: none
version: 0.1.0

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
flutter:
Expand Down Expand Up @@ -115,6 +115,8 @@ flutter:
dependency_overrides:
sqflite_porter:
path: ../sqflite_porter
sqflite_common_porter:
path: ../sqflite_common_porter
sqflite_common_server:
path: ../sqflite_common_server
sqflite_test:
Expand Down
4 changes: 2 additions & 2 deletions sqflite_support/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:tekartik_lints/recommended.yaml
include: package:tekartik_lints/strict.yaml

# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
# Uncomment to specify additional rules.
Expand All @@ -11,4 +11,4 @@ include: package:tekartik_lints/recommended.yaml

analyzer:
# exclude:
# - path/to/excluded/files/**
# - path/to/excluded/files/**
2 changes: 1 addition & 1 deletion sqflite_support/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.1.0
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
process_run: '>=0.10.10+2'
Expand Down
2 changes: 1 addition & 1 deletion sqflite_test/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# tekartik analysis_options extension to pedantic
include: package:tekartik_lints_flutter/recommended.yaml
include: package:tekartik_lints_flutter/strict.yaml
Loading

0 comments on commit 759a363

Please sign in to comment.