-
Notifications
You must be signed in to change notification settings - Fork 0
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
Transpiler: Remove .unwrap()
usages
#76
Comments
Some of the rules use poc-plpgsql-analyzer/src/rules/builtins.rs Lines 57 to 68 in 75ed336
One possible option to avoid the filter(|i| i.name().map_or(false, |i| i.to_lowercase() == "sysdate")) which seems idiomatic enough. An alternative approach could be to expect |
Another example is the poc-plpgsql-analyzer/src/rules/procedure.rs Lines 121 to 127 in 75ed336
An alternative could look like: let syntax_tokens = t
.parent()
.into_iter() // called exactly once (on Some) or zero (None)
.flat_map(|it| it.siblings_with_tokens(Direction::Next)) // but requires to flatten inner Iterator then
.skip(1)
.take(4)
.collect::<Vec<_>>(); This works quite nicely, because This iterator sequence can also be found in Rust Analyzer. |
Found another type for eliminating For example in the poc-plpgsql-analyzer/src/rules/procedure.rs Lines 29 to 41 in 75ed336
Note the The .filter_map(|h| {
Some(RuleMatch::new(
h.syntax().clone(),
TextRange::at(
h.identifier()?.syntax().text_range().end(),
0.into(),
),
))
}) I think this covers a fair chunk of the cases that exist in the code. The |
The AST navigation in the transpiler is making substanial use of
.unwrap()
on Options. As these may panic, they should be refactored.Refer to #70 (comment).
The text was updated successfully, but these errors were encountered: