Skip to content
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

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open

Clippy warnings fixed & added to CI. #378

wants to merge 39 commits into from

Conversation

ShreyBana
Copy link
Collaborator

  • 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.

sauraww and others added 30 commits January 9, 2025 12:51
* feat: Add auth via OAUTH2

* feat: Make auth endpoints part of AuthHandler
@ShreyBana ShreyBana requested a review from a team as a code owner January 22, 2025 12:17
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)
Copy link
Collaborator

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

@ShreyBana ShreyBana force-pushed the fix+ci/clippy branch 3 times, most recently from 6159466 to 3451045 Compare January 22, 2025 13:22
Copy link
Collaborator

@Datron Datron left a 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

Comment on lines +55 to +60
#[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)
Copy link
Collaborator

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;
Copy link
Collaborator

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

Copy link
Collaborator Author

@ShreyBana ShreyBana Jan 23, 2025

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

Copy link
Collaborator

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

Comment on lines -185 to -184
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();
Copy link
Collaborator

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?

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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

Copy link
Collaborator Author

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)
Copy link
Collaborator

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()
Copy link
Collaborator

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?

Copy link
Collaborator Author

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();
Copy link
Collaborator

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?

Copy link
Collaborator Author

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}"))
Copy link
Collaborator

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?

Copy link
Collaborator Author

@ShreyBana ShreyBana Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@ayushjain17 ayushjain17 Jan 29, 2025

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 expects and unwrap_ors, so we were lucky

in practice, its always better to have unwrap_or_else at the very least, instead of unwrap_or

@Datron
Copy link
Collaborator

Datron commented Jan 23, 2025

@ShreyBana there are some issues with leptosfmt, we don't need to add it right now. Also lets not format (both leptosfmt and cargofmt) in the CI, instead lets just check and fail as before.

Edit: Saw that you added check flags, ignore the last sentence.

* refactor: workspace ui & form

* refactor: moved api types behind  feature flag
@ShubhranshuSanjeev
Copy link
Collaborator

@ShreyBana there are some issues with leptosfmt, we don't need to add it right now. Also lets not format (both leptosfmt and cargofmt) in the CI, instead lets just check and fail as before.

Edit: Saw that you added check flags, ignore the last sentence.

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.
If things work fine, we can keep leptosfmt in the CI.

ci: Added lint check in CI.
Base automatically changed from saas to main January 23, 2025 13:18
@@ -15,11 +15,12 @@ pub struct CreateReq {

#[derive(Debug, Deserialize, AsRef, Deref, DerefMut, Into, Clone)]
#[serde(try_from = "i32")]
#[derive(Default)]
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants