-
Notifications
You must be signed in to change notification settings - Fork 20
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
Clippy warnings fixed & added to CI. #378
base: main
Are you sure you want to change the base?
Conversation
ShreyBana
commented
Jan 22, 2025
- Fixed all lint warnings. (Some shortcuts have been taken)
- Added targets in make to lint & format files, additionally a helper for commiting whilst checking these.
* feat: Add auth via OAUTH2 * feat: Make auth endpoints part of AuthHandler
- Removed nested/recursive make calls in targets. - Made docker conditonal, w/ podman as an alternative tool.
1aef89d
to
1ba9aba
Compare
makefile
Outdated
@@ -166,4 +168,26 @@ test: setup frontend superposition | |||
tailwind: | |||
cd crates/frontend && npx tailwindcss -i ./styles/tailwind.css -o ./pkg/style.css --watch | |||
|
|||
format: | |||
cargo fmt $(FMT_FLAGS) |
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.
cd crates/frontend && leptosfmt . && cd ../..
Let's add leptosfmt also
6159466
to
3451045
Compare
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.
TIL a.clone() and *a do the same thing
#[cfg(feature = "high-performance-mode")] | ||
let scope = scope.service(get_config_fast); | ||
Scope::new("") | ||
.service(get_config) | ||
.service(get_resolved_config) | ||
.service(reduce_config) | ||
.service(get_config_versions); | ||
#[cfg(feature = "high-performance-mode")] | ||
let scope = scope.service(get_config_fast); | ||
scope | ||
.service(get_config_versions) |
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 won't work, scope.service
isn't declared or defined yet. The new() is happening in the next line
@@ -159,7 +158,7 @@ pub fn generate_config_from_version( | |||
tenant: &Tenant, | |||
) -> superposition::Result<Config> { | |||
if let Some(val) = version { | |||
let val = val.clone(); | |||
let val = *val; |
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.
Opinion, .clone() is more clear on what's happening to val
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.
I just ran cargo clippy --fix, this is what the community prefers ig. But I think there is a way to turn this thing off, can other folks comment on this, we'll take a call accordingly.
@juspay/sdk-backend
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.
@Datron this should not have been a clone at all over here
let exp_context = Exp::<Condition>::try_from(req.context.clone()) | ||
.map_err(|err| { | ||
log::error!("failed to decode condition with error {}", err); | ||
bad_argument!(err) | ||
})? | ||
.into_inner(); |
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.
Does this work because the type is specified below? What about the error handling?
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.
It was a redundant operation, it was doing try_from from (& into) the same type.
.collect::<Map<_, _>>(); | ||
|
||
let toss = value | ||
.remove("toss") | ||
.and_then(|toss| toss.as_i64()) | ||
.and_then(|toss| { | ||
if -1 <= toss && toss <= 100 { | ||
if (-1..=100).contains(&toss) { |
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 seems like a worse check, earlier comparison was cleaner. This looks a bit overkill
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.
Lmao, the F is this 🤣, let me see if we can turn this off.
@@ -252,7 +256,7 @@ where | |||
on:keypress=move |ev| { | |||
let char_code = ev.char_code(); | |||
if char_code != 0 && char_code != 8 && char_code != 13 | |||
&& !(char_code >= 48 && char_code <= 57) | |||
&& !(48..=57).contains(&char_code) |
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.
I kind of prefer the older way. Why make this change? Not blocking on this though
@@ -46,7 +45,7 @@ pub fn enum_dropdown( | |||
disabled=disabled | |||
dropdown_width="w-100" | |||
dropdown_icon="".to_string() | |||
dropdown_text=(move || { selected_enum.get() })() | |||
dropdown_text=selected_enum.get() |
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.
Does this need to be a closure to be reactive?
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.
Closure gets created & is being consumed immediately 🥹
@@ -41,7 +41,7 @@ impl Expression { | |||
.cloned() | |||
.ok_or("Invalid operands list for context")?; | |||
|
|||
let operand_0 = operands.get(0); | |||
let operand_0 = operands.first(); |
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.
nitpick: can we keep it get(0) for consistency with the below statements?
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.
@@ -16,9 +16,9 @@ pub async fn decrypt(aws_kms_cli: Client, key: &str) -> String { | |||
.await; | |||
let key_value: String = String::from_utf8( | |||
key_value_bytes_result | |||
.expect(&format!("Failed to decrypt {key}")) | |||
.unwrap_or_else(|_| panic!("Failed to decrypt {key}")) |
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.
Is this a clippy suggestion? What reason did it give for this change?
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.
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 rationale is pretty correct, often this rationale has been ignored while development but luckily we did not have any side effect in all of our expect
s and unwrap_or
s, so we were lucky
in practice, its always better to have unwrap_or_else
at the very least, instead of unwrap_or
@ShreyBana there are some issues with leptosfmt, we don't need to add it right now. Edit: Saw that you added check flags, ignore the last sentence. |
* refactor: workspace ui & form * refactor: moved api types behind feature flag
We did have issues with leptosfmt in the past, @ShreyBana can you format the frontend code once with leptosfmt and check whether things work as suppose to on your local. |
3451045
to
58a1cd2
Compare
ci: Added lint check in CI.
58a1cd2
to
4d08fdf
Compare
@@ -15,11 +15,12 @@ pub struct CreateReq { | |||
|
|||
#[derive(Debug, Deserialize, AsRef, Deref, DerefMut, Into, Clone)] | |||
#[serde(try_from = "i32")] | |||
#[derive(Default)] |
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.
can you combine this with the other Derives which is there above