Skip to content

Commit

Permalink
Updated code to match latest pedantic lints and Dart SDK hints. (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Apr 11, 2020
1 parent 0b11ed2 commit 66db5c0
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 24 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include: package:pedantic/analysis_options.yaml

analyzer:
errors:
override_on_non_overriding_method: error
unused_element: error
unused_import: error
unused_local_variable: error
Expand Down
4 changes: 2 additions & 2 deletions lib/src/client_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class StartupMessage extends ClientMessage {

@override
void applyToBuffer(ByteDataWriter buffer) {
int fixedLength = 48;
int variableLength = _databaseName.utf8Length + _timeZone.utf8Length + 2;
var fixedLength = 48;
var variableLength = _databaseName.utf8Length + _timeZone.utf8Length + 2;

if (_username != null) {
fixedLength += 5;
Expand Down
12 changes: 7 additions & 5 deletions lib/src/connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ class PostgreSQLConnection extends Object
/// If specified, the final `"COMMIT"` query of the transaction will use
/// [commitTimeoutInSeconds] as its timeout, otherwise the connection's
/// default query timeout will be used.
Future transaction(Future queryBlock(PostgreSQLExecutionContext connection),
{int commitTimeoutInSeconds}) async {
Future transaction(
Future Function(PostgreSQLExecutionContext connection) queryBlock, {
int commitTimeoutInSeconds,
}) async {
if (isClosed) {
throw PostgreSQLException(
'Attempting to execute query, but connection is not open.');
Expand Down Expand Up @@ -429,7 +431,7 @@ abstract class _PostgreSQLExecutionContextMixin
}

final rows = await _enqueue(query, timeoutInSeconds: timeoutInSeconds);
List<FieldDescription> columnDescriptions = query.fieldDescriptions;
var columnDescriptions = query.fieldDescriptions;
if (resolveOids) {
columnDescriptions = await _connection._oidCache
._resolveTableNames(this, columnDescriptions);
Expand Down Expand Up @@ -545,7 +547,7 @@ class _PostgreSQLResultRow extends UnmodifiableListView
_metaData.tableNames.forEach((tableName) {
rowMap[tableName] = <String, dynamic>{};
});
for (int i = 0; i < _metaData.columnDescriptions.length; i++) {
for (var i = 0; i < _metaData.columnDescriptions.length; i++) {
final col = _metaData.columnDescriptions[i];
rowMap[col.tableName][col.columnName] = this[i];
}
Expand All @@ -555,7 +557,7 @@ class _PostgreSQLResultRow extends UnmodifiableListView
@override
Map<String, dynamic> toColumnMap() {
final rowMap = <String, dynamic>{};
for (int i = 0; i < _metaData.columnDescriptions.length; i++) {
for (var i = 0; i < _metaData.columnDescriptions.length; i++) {
final col = _metaData.columnDescriptions[i];
rowMap[col.columnName] = this[i];
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/execution_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ abstract class ColumnDescription {

/// A single row of a query result.
///
/// Column values can be accessed through the [] [List] accessor.
/// Column values can be accessed through the `[]` operator.
abstract class PostgreSQLResultRow implements List {
List<ColumnDescription> get columnDescriptions;

Expand All @@ -113,7 +113,7 @@ abstract class PostgreSQLResultRow implements List {

/// The query result.
///
/// Rows can be accessed through the [] [List] accessor.
/// Rows can be accessed through the `[]` operator.
abstract class PostgreSQLResult implements List<PostgreSQLResultRow> {
List<ColumnDescription> get columnDescriptions;
}
4 changes: 2 additions & 2 deletions lib/src/message_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'server_messages.dart';
const int _headerByteSize = 5;
final _emptyData = Uint8List(0);

typedef ServerMessage _ServerMessageFn(Uint8List data);
typedef _ServerMessageFn = ServerMessage Function(Uint8List data);

Map<int, _ServerMessageFn> _messageTypeMap = {
49: (d) => ParseCompleteMessage(),
Expand Down Expand Up @@ -42,7 +42,7 @@ class MessageFramer {
void addBytes(Uint8List bytes) {
_reader.add(bytes);

bool evaluateNextMessage = true;
var evaluateNextMessage = true;
while (evaluateNextMessage) {
evaluateNextMessage = false;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class FieldDescription implements ColumnDescription {

factory FieldDescription.read(ByteDataReader reader) {
final buf = StringBuffer();
int byte = 0;
var byte = 0;
do {
byte = reader.readUint8();
if (byte != 0) {
Expand Down Expand Up @@ -288,7 +288,7 @@ class FieldDescription implements ColumnDescription {
}
}

typedef String SQLReplaceIdentifierFunction(
typedef SQLReplaceIdentifierFunction = String Function(
PostgreSQLFormatIdentifier identifier, int index);

enum PostgreSQLFormatTokenType { text, variable }
Expand Down
4 changes: 2 additions & 2 deletions lib/src/server_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class CommandCompleteMessage extends ServerMessage {
factory CommandCompleteMessage(Uint8List bytes) {
final str = utf8.decode(bytes.sublist(0, bytes.length - 1));
final match = identifierExpression.firstMatch(str);
int rowsAffected = 0;
var rowsAffected = 0;
if (match.end < str.length) {
rowsAffected = int.parse(str.split(' ').last);
}
Expand Down Expand Up @@ -221,7 +221,7 @@ class UnknownMessage extends ServerMessage {
}

@override
operator ==(dynamic other) {
bool operator ==(dynamic other) {
if (bytes != null) {
if (bytes.length != other.bytes.length) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/text_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class PostgresTextEncoder extends Converter<dynamic, String> {
final backslashCodeUnit = r'\'.codeUnitAt(0);
final quoteCodeUnit = r"'".codeUnitAt(0);

int quoteCount = 0;
int backslashCount = 0;
var quoteCount = 0;
var backslashCount = 0;
final it = RuneIterator(text);
while (it.moveNext()) {
if (it.current == backslashCodeUnit) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/transaction_proxy.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of postgres.connection;

typedef Future<dynamic> _TransactionQuerySignature(
typedef _TransactionQuerySignature = Future<dynamic> Function(
PostgreSQLExecutionContext connection);

class _TransactionProxy extends Object
Expand Down
2 changes: 1 addition & 1 deletion test/framer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Uint8List bufferWithMessages(List<List<int>> messages) {
return Uint8List.fromList(messages.expand((l) => l).toList());
}

flush(MessageFramer framer) {
void flush(MessageFramer framer) {
framer.messageQueue.clear();
framer.addBytes(bufferWithMessages([
messageWithBytes([1, 2, 3], 1)
Expand Down
4 changes: 2 additions & 2 deletions test/notification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void main() {

test('Notification many channel', () async {
final countResponse = <String, int>{};
int totalCountResponse = 0;
var totalCountResponse = 0;
final finishExecute = Completer();
connection.notifications.listen((msg) {
final count = countResponse[msg.channel];
Expand All @@ -81,7 +81,7 @@ void main() {
final channel2 = 'virtual2';

final notifier = () async {
for (int i = 0; i < 5; i++) {
for (var i = 0; i < 5; i++) {
await connection.execute('NOTIFY $channel1;'
'NOTIFY $channel2;');
}
Expand Down
4 changes: 2 additions & 2 deletions test/transaction_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void main() {
});

test('May intentionally rollback transaction', () async {
bool reached = false;
var reached = false;
await conn.transaction((c) async {
await c.query('INSERT INTO t (id) VALUES (1)');
c.cancelTransaction();
Expand Down Expand Up @@ -500,7 +500,7 @@ void main() {
});

test('Async query failure prevents closure from continuning', () async {
bool reached = false;
var reached = false;

try {
await conn.transaction((c) async {
Expand Down

0 comments on commit 66db5c0

Please sign in to comment.