Skip to content

chore: add uneccessary_* lints #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2023
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
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ linter:
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_checks
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_statements
- unnecessary_this
- unrelated_type_equality_checks
Expand Down
2 changes: 1 addition & 1 deletion example/v3/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void main() async {
final connection = await PgConnection.open(database);
print('has connection!');

final statement = await connection.prepare(PgSql(r"SELECT 'foo';"));
final statement = await connection.prepare(PgSql("SELECT 'foo';"));
print('has statement');
final result = await statement.run();
print(result);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/binary_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final _hex = <String>[
'f',
];
final _numericRegExp = RegExp(r'^(\d*)(\.\d*)?$');
final _leadingZerosRegExp = RegExp(r'^0+');
final _leadingZerosRegExp = RegExp('^0+');
final _trailingZerosRegExp = RegExp(r'0+$');

class PostgresBinaryEncoder<T extends Object>
Expand Down
6 changes: 3 additions & 3 deletions lib/src/exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class PostgreSQLException implements Exception {
}

PostgreSQLException._(List<ErrorField> errorFields) {
ErrorField finder(int identifer) => (errorFields.firstWhere(
(ErrorField e) => e.identificationToken == identifer,
orElse: () => ErrorField(null, null)));
ErrorField finder(int identifier) => errorFields.firstWhere(
(ErrorField e) => e.identificationToken == identifier,
orElse: () => ErrorField(null, null));

severity = ErrorField.severityFromString(
finder(ErrorField.SeverityIdentifier).text);
Expand Down
9 changes: 4 additions & 5 deletions lib/src/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Query<T> {

void sendExtended(Socket socket, {CachedQuery? cacheQuery}) {
if (cacheQuery != null) {
fieldDescriptions = cacheQuery.fieldDescriptions!;
fieldDescriptions = cacheQuery.fieldDescriptions;
sendCachedQuery(socket, cacheQuery, substitutionValues);

return;
Expand Down Expand Up @@ -95,7 +95,7 @@ class Query<T> {
];

if (statementIdentifier != null) {
cache = CachedQuery(statementIdentifier!, formatIdentifiers);
cache = CachedQuery(statementIdentifier, formatIdentifiers);
}

socket.add(ClientMessage.aggregateBytes(messages));
Expand Down Expand Up @@ -350,9 +350,8 @@ class PostgreSQLFormatIdentifier {
name = variableComponents.first;

final dataTypeString = variableComponents.last;
try {
type = typeStringToCodeMap[dataTypeString]!;
} catch (e) {
type = typeStringToCodeMap[dataTypeString];
if (type == null) {
throw FormatException(
"Invalid type code in substitution variable '$t'");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/text_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PostgresTextEncoder extends Converter<Object, String> {
}

final backslashCodeUnit = r'\'.codeUnitAt(0);
final quoteCodeUnit = r"'".codeUnitAt(0);
final quoteCodeUnit = "'".codeUnitAt(0);

var quoteCount = 0;
var backslashCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/v3/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ enum PgDataType<Dart extends Object> {

static final Map<int, PgDataType> byTypeOid = Map.unmodifiable({
for (final type in values)
if (type.oid != null) type.oid!: type,
if (type.oid != null) type.oid: type,
});

static final Map<String, PgDataType> bySubstitutionName = Map.unmodifiable({
Expand All @@ -170,7 +170,7 @@ enum PgDataType<Dart extends Object> {
if (type != serial &&
type != bigSerial &&
type.nameForSubstitution != null)
type.nameForSubstitution!: type,
type.nameForSubstitution: type,
});

static final Map<PgDataType, _BinaryTypeCodec> _binaryCodecs = {};
Expand Down
6 changes: 4 additions & 2 deletions test/map_return_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void clearOidQueryCount(PostgreSQLConnection connection) {
dm.simpleName.toString().contains('_oidCache'));
// TODO(eseidel): Fix this by using @visibleForTesting instead of mirrors?
// ignore: avoid_dynamic_calls
(reflect(connection).getField(oidCacheMirror.simpleName).reflectee).clear();
reflect(connection).getField(oidCacheMirror.simpleName).reflectee.clear();
}

int getOidQueryCount(PostgreSQLConnection connection) {
Expand All @@ -154,6 +154,8 @@ int getOidQueryCount(PostgreSQLConnection connection) {
dm.simpleName.toString().contains('_oidCache'));
// TODO(eseidel): Fix this by using @visibleForTesting instead of mirrors?
// ignore: avoid_dynamic_calls
return (reflect(connection).getField(oidCacheMirror.simpleName).reflectee)
return reflect(connection)
.getField(oidCacheMirror.simpleName)
.reflectee
.queryCount as int;
}