-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
Huh. Will figure out what I broke and upload again, sorry. |
lib/src/query.dart
Outdated
@@ -351,7 +351,7 @@ class PostgreSQLFormatIdentifier { | |||
|
|||
final dataTypeString = variableComponents.last; | |||
try { | |||
type = typeStringToCodeMap[dataTypeString]!; | |||
type = typeStringToCodeMap[dataTypeString]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test that is failing is due to this line of code.
Apparently, the code was throwing an exception whenever type
is null
by relying on the removed null check -- that is, when the null check fails, it throws a format exception.
I think a proper way to handle this is to replace the try/catch statement with if/throw such as:
type = typeStringToCodeMap[dataTypeString];
if (type == null) {
throw FormatException(
"Invalid type code in substitution variable '$t'");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. @eseidel could you please rebase the PR and also fix this code?
Adding: - unnecessary_null_checks - unnecessary_parenthesis - unnecessary_raw_strings Each of these found real cases where fixing with the lint improved readability (one could argue about the raw strings).
Sorry for the delay, I believe this is ready now and should pass CI. 🤞 |
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #115 +/- ##
==========================================
+ Coverage 86.71% 86.72% +0.01%
==========================================
Files 29 29
Lines 2453 2455 +2
==========================================
+ Hits 2127 2129 +2
Misses 326 326
☔ View full report in Codecov by Sentry. |
lib/src/query.dart
Outdated
try { | ||
type = typeStringToCodeMap[dataTypeString]!; | ||
type = typeStringToCodeMap[dataTypeString]; | ||
if (type == null) { | ||
throw FormatException( | ||
"Invalid type code in substitution variable '$t'"); | ||
} | ||
} catch (e) { | ||
throw FormatException( | ||
"Invalid type code in substitution variable '$t'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try/catch encapsulating if/throw is redundant and could be removed.
Thanks. Apologies again. Got distracted with non-hacking matters. :) |
Adding: