📝 CodeRabbit Chat: Implement requested code changes#324
📝 CodeRabbit Chat: Implement requested code changes#324coderabbitai[bot] wants to merge 1 commit intomainfrom
Conversation
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Gates Failed
Enforce advisory code health rules
(2 files with Code Duplication, Excess Number of Function Arguments)
Gates Passed
5 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| flow_support.rs | 2 advisory rules | 9.10 | Suppress |
| user_interests_revision_conflicts_bdd.rs | 1 advisory rule | 9.39 | Suppress |
Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
| fn existing_preferences_revision_1_with_preserved_safety_and_unit_settings(world: &mut World) { | ||
| if is_skipped(world) { | ||
| return; | ||
| } | ||
|
|
||
| let db = world.db.as_ref().expect("db context"); | ||
| seed_preferences( | ||
| db.database_url.as_str(), | ||
| Uuid::parse_str(FIXTURE_AUTH_ID).expect("valid fixture UUID"), | ||
| PreferencesData::new(&[FIRST_THEME_ID], &[SAFETY_TOGGLE_ID], "imperial", 1), | ||
| ) | ||
| .expect("seed user preferences"); | ||
| } |
There was a problem hiding this comment.
❌ New issue: Code Duplication
The module contains 6 functions with similar structure: existing_preferences_revision_1_with_preserved_safety_and_unit_settings,existing_preferences_revision_2,the_first_interests_response_includes_revision_1,the_response_is_a_conflict_with_expected_revision_1_and_actual_revision_2 and 2 more functions
| async fn update_interests_snapshot<S>( | ||
| app: &S, | ||
| cookie: Cookie<'static>, | ||
| payload: InterestsRequest, | ||
| ) -> Snapshot | ||
| where | ||
| S: actix_web::dev::Service< | ||
| actix_http::Request, | ||
| Response = actix_web::dev::ServiceResponse<actix_web::body::BoxBody>, | ||
| Error = actix_web::Error, | ||
| >, | ||
| { | ||
| let req = actix_test::TestRequest::put() | ||
| .uri("/api/v1/users/me/interests") | ||
| .cookie(cookie) | ||
| .set_json(payload) | ||
| .to_request(); | ||
| capture_snapshot(actix_test::call_service(app, req).await, false).await | ||
| } |
There was a problem hiding this comment.
❌ New issue: Code Duplication
The module contains 5 functions with similar structure: preferences_snapshot,run_first_write,run_missing_revision_conflict,run_stale_revision_conflict and 1 more functions
| pub(crate) fn assert_preferences_snapshot( | ||
| snapshot: &Snapshot, | ||
| expected_interest_ids: &[&str], | ||
| expected_safety_ids: &[&str], | ||
| expected_unit_system: &str, | ||
| expected_revision: u32, | ||
| ) { | ||
| assert_eq!(snapshot.status, 200); | ||
| let body = snapshot.body.as_ref().expect("preferences body"); | ||
| assert_eq!( | ||
| body.get("interestThemeIds") | ||
| .and_then(Value::as_array) | ||
| .expect("interestThemeIds array") | ||
| .iter() | ||
| .map(|value| value.as_str().expect("string interest id")) | ||
| .collect::<Vec<_>>(), | ||
| expected_interest_ids | ||
| ); | ||
| assert_eq!( | ||
| body.get("safetyToggleIds") | ||
| .and_then(Value::as_array) | ||
| .expect("safetyToggleIds array") | ||
| .iter() | ||
| .map(|value| value.as_str().expect("string safety id")) | ||
| .collect::<Vec<_>>(), | ||
| expected_safety_ids | ||
| ); | ||
| assert_eq!( | ||
| body.get("unitSystem").and_then(Value::as_str), | ||
| Some(expected_unit_system) | ||
| ); | ||
| assert_eq!( | ||
| body.get("revision").and_then(Value::as_u64), | ||
| Some(u64::from(expected_revision)) | ||
| ); | ||
| } No newline at end of file |
There was a problem hiding this comment.
❌ New issue: Excess Number of Function Arguments
assert_preferences_snapshot has 5 arguments, max arguments = 4
Code changes was requested by @leynos.
The following files were modified:
backend/tests/user_interests_revision_conflicts_bdd.rsbackend/tests/user_interests_revision_conflicts_bdd/db_support.rsbackend/tests/user_interests_revision_conflicts_bdd/flow_support.rs