Skip to content

Feature/mcb metrics removal and test cleanup - #153

Open
marlon-costa-dc wants to merge 8 commits into
mainfrom
feature/mcb-metrics-removal-and-test-cleanup
Open

Feature/mcb metrics removal and test cleanup#153
marlon-costa-dc wants to merge 8 commits into
mainfrom
feature/mcb-metrics-removal-and-test-cleanup

Conversation

@marlon-costa-dc

Copy link
Copy Markdown
Collaborator

No description provided.

… (-913 lines)

Dead test code removed (compiler-proven unused):
- test_utils.rs: 11 dead functions (create_test_crate_with_extra_file,
  create_test_crate_with_tests, create_file_at_path, ensure_workspace_structure,
  create_constants_file, create_null_provider_file, assert_violation_count,
  assert_min_violations, assert_violation_at, load_fixture, setup_fixture_crate)
- test_constants.rs: 22 dead constants (APPLICATION_CRATE, INFRASTRUCTURE_CRATE,
  PROVIDERS_CRATE, VALIDATE_CRATE, ERROR_RS, CONSTANTS_RS, NULL_RS, and 15 more)

Unused cargo dependencies stripped (cargo-machete verified):
- mcb-infrastructure: r2d2, r2d2_postgres, tree-sitter-c-sharp, tree-sitter-kotlin-ng,
  criterion, flate2, tar, seahash, pulldown-cmark, html-escape, hostname, nix
- mcb-server: async-nats, flate2, tar, fs2
- mcb-validate: criterion, garde, pest, pest_derive, jsonpath-rust, once_cell, rusty-rules
- mcb-ast-utils: tokio, tracing
- mcb-language-support: tracing

Also applied crud_adapter.rs macro consolidation from previous session.

Part of epic mcb-b9qd (v0.2.2 modernization plan).
…in mcb-providers

- Add #[allow(unsafe_code)] before #[linkme::distributed_slice(PROJECT_DETECTORS)] in:
  - crates/mcb-providers/src/git/project_detection/cargo.rs
  - crates/mcb-providers/src/git/project_detection/go.rs
  - crates/mcb-providers/src/git/project_detection/maven.rs
  - crates/mcb-providers/src/git/project_detection/npm.rs
  - crates/mcb-providers/src/git/project_detection/python.rs

- Add missing doc comments to sqlite repository structs and constructors:
  - SqliteVcsEntityRepository
  - SqliteIssueEntityRepository
  - SqliteOrgEntityRepository
  - SqlitePlanEntityRepository

- Add module-level doc comments in sqlite/mod.rs for public modules

Fixes -D unsafe-code lint errors and missing documentation warnings.
- Simplified search and filter conditions in `apply_filter_pipeline` by using `Option::filter` to eliminate unnecessary checks for empty values.
- Enhanced readability and maintainability of the code by consolidating logic for sorting and filtering.
- Updated environment variable handling in test helpers with `#[allow(unsafe_code)]` to suppress warnings.

This refactor improves code clarity and reduces potential errors in filtering logic.
…ate CI/CD workflows

- Downgraded versions of several packages (mcb, mcb-application, mcb-ast-utils, mcb-domain, mcb-infrastructure, mcb-language-support, mcb-providers, mcb-server, mcb-validate) from 0.2.2-dev to 0.2.1-dev in Cargo.lock and Cargo.toml.
- Updated the Codecov action version in CI workflow from v5.4.3 to v5.5.2 for improved functionality.
- Adjusted release workflow to use extracted version and tag for consistency in release naming.

These changes ensure compatibility with previous versions and enhance CI/CD reliability.
- Removed the `vcs_indexing_tests` module and its references due to obsolescence.
- Updated the `unit.rs` test file to comment out the `vcs_indexing_tests` path, indicating its removal in version 0.2.2.
- Enhanced documentation in various modules to clarify the purpose of fields and improve maintainability.
- Added module-level documentation for better context in the `test_services_config` and `utils` modules.
…code

- Remove prometheus, metrics, opentelemetry deps from 5 crate Cargo.tomls
- Simplify crud_adapter.rs (134→80 lines)
- Remove 70 dead test constants and 249 lines of unused test utils
- Fix issue_entity_repository column reference
- Clean sqlite module exports
- Regenerate Cargo.lock after dependency removal
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@marlon-costa-dc, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 68a0e11f-565a-42de-9b20-e596d0cb911a

📥 Commits

Reviewing files that changed from the base of the PR and between a6d22a3 and 15c4c6b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • crates/mcb-ast-utils/Cargo.toml
  • crates/mcb-infrastructure/Cargo.toml
  • crates/mcb-infrastructure/tests/unit/config_figment_tests.rs
  • crates/mcb-language-support/Cargo.toml
  • crates/mcb-providers/src/database/sqlite/issue_entity_repository.rs
  • crates/mcb-providers/src/database/sqlite/mod.rs
  • crates/mcb-server/Cargo.toml
  • crates/mcb-server/src/admin/crud_adapter.rs
  • crates/mcb-validate/Cargo.toml
  • crates/mcb-validate/tests/test_constants.rs
  • crates/mcb-validate/tests/test_utils.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/mcb-metrics-removal-and-test-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Remove unused dependencies and dead test helpers; refactor CRUD adapters

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Remove unused Cargo dependencies across multiple crates and refresh Cargo.lock.
• Delete compiler-proven dead test constants/utilities to reduce maintenance overhead.
• Refactor admin CRUD adapters via a macro and tighten test safety annotations.
Diagram

graph TD
  A["Workspace (Cargo.lock)"] --> B["mcb-infrastructure"] --> E["mcb-providers (sqlite)"]
  A --> C["mcb-server"] --> F["admin/crud_adapter.rs"]
  A --> D["mcb-validate"] --> G["tests (utils/constants)"]
  A --> H["mcb-ast-utils & mcb-language-support"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add CI guard for unused deps (cargo-machete)
  • ➕ Prevents reintroduction of unused dependencies over time
  • ➕ Makes dependency hygiene an automated invariant
  • ➖ Adds CI time and maintenance for tool version pinning
  • ➖ May require allowlists for conditional/feature-gated deps
2. Use a test env-var guard crate instead of unsafe set_var/remove_var
  • ➕ Eliminates unsafe blocks and relies on RAII to restore environment
  • ➕ Less reliance on serial test ordering assumptions
  • ➖ Introduces a new dependency for tests (counter to current cleanup goal)
  • ➖ May not cover all platform-specific env behavior edge cases

Recommendation: The PR’s approach (compiler/tool-verified dead-code removal + cargo-machete-based dependency pruning) is the right default for a cleanup sweep. The main follow-up worth considering is adding a CI check (or periodic job) to keep unused dependencies from creeping back in, while keeping the current minimal-dependency stance for tests.

Files changed (12) +139 / -1038

Enhancement (1) +4 / -2
mod.rsPublicly export SQLite issue/org repositories with module docs +4/-2

Publicly export SQLite issue/org repositories with module docs

• Changes issue_entity_repository and org_entity_repository modules from private to public and adds module-level documentation. This makes the SQLite-backed repositories accessible to downstream crates.

crates/mcb-providers/src/database/sqlite/mod.rs

Refactor (1) +49 / -85
crud_adapter.rsMacro-generate CRUD adapters and simplify filter conditionals +49/-85

Macro-generate CRUD adapters and simplify filter conditionals

• Introduces an impl_crud_adapter! macro to remove repeated wrapper + async_trait boilerplate across entity adapters. Also refactors filter pipeline conditionals using Option::filter to make search/sort checks more concise while keeping behavior consistent.

crates/mcb-server/src/admin/crud_adapter.rs

Tests (3) +7 / -320
config_figment_tests.rsClarify unsafe env var helpers and document serial execution +4/-4

Clarify unsafe env var helpers and document serial execution

• Adds doc comments and explicit #[allow(unsafe_code)] on helper functions that mutate environment variables. Updates safety comments to reflect the use of #[serial] rather than relying on a global test-threads=1 assumption.

crates/mcb-infrastructure/tests/unit/config_figment_tests.rs

test_constants.rsRemove dead test constants and unused fixture parameters +0/-70

Remove dead test constants and unused fixture parameters

• Deletes a large set of unused crate-name constants, file-name constants, fixture references, and threshold values that were no longer referenced by the test suite. Keeps only constants still required by active tests.

crates/mcb-validate/tests/test_constants.rs

test_utils.rsRemove unused test helper functions and narrow imports +3/-246

Remove unused test helper functions and narrow imports

• Eliminates multiple dead helper functions for creating crates/files and asserting violations that were no longer used. Updates module docs and imports to match the reduced helper surface area while keeping remaining assertion and fixture-workspace utilities intact.

crates/mcb-validate/tests/test_utils.rs

Documentation (1) +1 / -1
issue_entity_repository.rsTighten repository constructor documentation +1/-1

Tighten repository constructor documentation

• Updates the constructor docstring wording for clarity without changing behavior.

crates/mcb-providers/src/database/sqlite/issue_entity_repository.rs

Other (6) +78 / -630
Cargo.lockPrune lockfile entries and bump transitive versions +78/-578

Prune lockfile entries and bump transitive versions

• Removes many lockfile packages that were only reachable via now-removed dependencies (e.g., criterion, tar/flate2-related, postgres pool stack). Also updates a few transitive versions (notably syn 2.0.114 -> 2.0.115 and other minor bumps) as a consequence of the dependency graph change.

Cargo.lock

Cargo.tomlDrop unused runtime/logging deps from mcb-ast-utils +0/-6

Drop unused runtime/logging deps from mcb-ast-utils

• Removes tokio and tracing from dependencies, reflecting that this crate no longer requires an async runtime or logging directly. Keeps only dev-dependencies needed for tests.

crates/mcb-ast-utils/Cargo.toml

Cargo.tomlRemove unused markdown, DB pooling, compression, and extra parser/bench deps +0/-22

Remove unused markdown, DB pooling, compression, and extra parser/bench deps

• Deletes several unused dependencies including pulldown-cmark, r2d2/r2d2_postgres, hostname, nix, flate2/tar/seahash, html-escape, criterion, and some tree-sitter language grammars. This simplifies the crate’s build and reduces transitive dependency weight.

crates/mcb-infrastructure/Cargo.toml

Cargo.tomlRemove unused tracing dependency from language support crate +0/-3

Remove unused tracing dependency from language support crate

• Drops tracing from dependencies, indicating logging is not required at this layer (or is provided by consumers).

crates/mcb-language-support/Cargo.toml

Cargo.tomlRemove unused event bus/compression/file-lock dependencies +0/-8

Remove unused event bus/compression/file-lock dependencies

• Drops async-nats, flate2, tar, and fs2 from the server crate dependencies. Keeps mcb-providers explicitly in dependencies for linkme-based registration.

crates/mcb-server/Cargo.toml

Cargo.tomlStrip unused validation/parser/bench dependencies +0/-13

Strip unused validation/parser/bench dependencies

• Removes rusty-rules, garde, pest/pest_derive, jsonpath-rust, once_cell, and criterion from the validate crate. Retains tracing and other core dependencies, aligning the manifest with actual usage and explicit test targets.

crates/mcb-validate/Cargo.toml

@qodo-code-review

qodo-code-review Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (4) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 36 rules

Grey Divider


Remediation recommended

1. #[allow(unsafe_code)] lacks justification 📘 Rule violation ⚙ Maintainability ⭐ New
Description
#[allow(unsafe_code)] is used without an inline justification comment on the same line or
immediately following line. This violates the requirement to document why a static-analysis
suppression is necessary, making future audits and maintenance harder.
Code

crates/mcb-infrastructure/tests/unit/config_figment_tests.rs[R20-22]

+/// Helper to set env var safely.
#[allow(unsafe_code)]
-/// Helper to set env var safely
fn set_env(key: &str, value: &str) {
-    // SAFETY: Tests must run with --test-threads=1
Evidence
PR Compliance ID 1206895 requires every linter/static-analysis suppression (like #[allow(...)]) to
include a specific inline justification comment on the same line or immediately below. In
config_figment_tests.rs, #[allow(unsafe_code)] appears without such an inline justification
comment (the next line is the function signature).

Rule 1206895: Require inline justification comments for all static-analysis suppression directives
crates/mcb-infrastructure/tests/unit/config_figment_tests.rs[20-22]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`#[allow(unsafe_code)]` is a suppression directive but it has no inline justification comment on the same line or the next line, as required.

## Issue Context
This appears to be needed due to Rust 2024 requiring `unsafe` for `env::set_var`/`env::remove_var` in tests, but that rationale must be recorded inline next to the suppression.

## Fix Focus Areas
- crates/mcb-infrastructure/tests/unit/config_figment_tests.rs[20-22]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. test_constants.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability
Description
The modified file crates/mcb-validate/tests/test_constants.rs still exceeds the ~200 line limit
after the cleanup, which increases maintenance burden for test infrastructure. It should be split
into smaller modules grouped by purpose (crate names, paths, rule IDs, etc.).
Code

crates/mcb-validate/tests/test_constants.rs[L21-32]

-/// Application layer test crate name.
-pub const APPLICATION_CRATE: &str = "my-application";
-
-/// Infrastructure layer test crate name.
-pub const INFRASTRUCTURE_CRATE: &str = "my-infrastructure";
-
-/// Providers layer test crate name.
-pub const PROVIDERS_CRATE: &str = "my-providers";
-
-/// Validate crate name (self-referential).
-pub const VALIDATE_CRATE: &str = "my-validate";
-
Evidence
PR Compliance ID 1208563 requires that modified source files should not exceed ~200 lines. The
current test_constants.rs reaches at least line 248.

Rule 1208563: Source files must not exceed ~200 lines
crates/mcb-validate/tests/test_constants.rs[240-248]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`crates/mcb-validate/tests/test_constants.rs` is a modified source file that exceeds the ~200 line limit and should be split into smaller modules.

## Issue Context
The PR removes a large block of constants but the file is still >200 lines; splitting will keep future test refactors simpler.

## Fix Focus Areas
- crates/mcb-validate/tests/test_constants.rs[21-32]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. crud_adapter.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability
Description
The modified file crates/mcb-server/src/admin/crud_adapter.rs is well over the ~200 line limit,
increasing maintenance risk and making future changes harder to review. This violates the guideline
to split large source files into submodules when they grow beyond ~200 lines.
Code

crates/mcb-server/src/admin/crud_adapter.rs[R141-152]

+/// Generates a CRUD adapter struct wrapping a repository trait object.
+macro_rules! impl_crud_adapter {
+    ($name:ident($repo_ty:ty) { $($methods:item)* }) => {
+        struct $name(Arc<$repo_ty>);
+
+        #[async_trait]
+        impl EntityCrudAdapter for $name {
+            $($methods)*
+        }
+    };
+}
+
Evidence
PR Compliance ID 1208563 requires modified source files to stay under ~200 lines. The updated
crud_adapter.rs clearly extends far beyond 200 lines (e.g., it contains code well past line 275).

Rule 1208563: Source files must not exceed ~200 lines
crates/mcb-server/src/admin/crud_adapter.rs[141-152]
crates/mcb-server/src/admin/crud_adapter.rs[273-319]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`crates/mcb-server/src/admin/crud_adapter.rs` is a modified source file that exceeds the ~200 line limit and should be split to improve maintainability.

## Issue Context
The PR adds code to this already-large file, but the repository guideline requires splitting files that exceed ~200 lines.

## Fix Focus Areas
- crates/mcb-server/src/admin/crud_adapter.rs[141-152]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
4. test_utils.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability
Description
The modified file crates/mcb-validate/tests/test_utils.rs exceeds the ~200 line limit, making it
harder to navigate and maintain as it grows. It should be split into smaller focused modules/files.
Code

crates/mcb-validate/tests/test_utils.rs[R9-12]

+//! - **Assertions**:      `assert_no_violations`,
//!   `assert_has_violation_matching`, `assert_no_violation_from_file`
#![allow(dead_code)]
Evidence
PR Compliance ID 1208563 requires modified source files to remain under ~200 lines. The current
test_utils.rs extends well beyond 200 lines (e.g., it includes code at and past line 300).

Rule 1208563: Source files must not exceed ~200 lines
crates/mcb-validate/tests/test_utils.rs[9-20]
crates/mcb-validate/tests/test_utils.rs[214-320]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`crates/mcb-validate/tests/test_utils.rs` is a modified source file that exceeds the ~200 line limit and should be split into smaller files/modules.

## Issue Context
Even though this is test code, it is still a source file and the guideline applies to modified files to prevent large monolithic modules.

## Fix Focus Areas
- crates/mcb-validate/tests/test_utils.rs[9-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 15c4c6b ⚖️ Balanced

Results up to commit 15c4c6b ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (3) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. crud_adapter.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability
Description
The modified file crates/mcb-server/src/admin/crud_adapter.rs is well over the ~200 line limit,
increasing maintenance risk and making future changes harder to review. This violates the guideline
to split large source files into submodules when they grow beyond ~200 lines.
Code

crates/mcb-server/src/admin/crud_adapter.rs[R141-152]

+/// Generates a CRUD adapter struct wrapping a repository trait object.
+macro_rules! impl_crud_adapter {
+    ($name:ident($repo_ty:ty) { $($methods:item)* }) => {
+        struct $name(Arc<$repo_ty>);
+
+        #[async_trait]
+        impl EntityCrudAdapter for $name {
+            $($methods)*
+        }
+    };
+}
+
Evidence
PR Compliance ID 1208563 requires modified source files to stay under ~200 lines. The updated
crud_adapter.rs clearly extends far beyond 200 lines (e.g., it contains code well past line 275).

Rule 1208563: Source files must not exceed ~200 lines
crates/mcb-server/src/admin/crud_adapter.rs[141-152]
crates/mcb-server/src/admin/crud_adapter.rs[273-319]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`crates/mcb-server/src/admin/crud_adapter.rs` is a modified source file that exceeds the ~200 line limit and should be split to improve maintainability.

## Issue Context
The PR adds code to this already-large file, but the repository guideline requires splitting files that exceed ~200 lines.

## Fix Focus Areas
- crates/mcb-server/src/admin/crud_adapter.rs[141-152]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. test_utils.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability
Description
The modified file crates/mcb-validate/tests/test_utils.rs exceeds the ~200 line limit, making it
harder to navigate and maintain as it grows. It should be split into smaller focused modules/files.
Code

crates/mcb-validate/tests/test_utils.rs[R9-12]

+//! - **Assertions**:      `assert_no_violations`,
//!   `assert_has_violation_matching`, `assert_no_violation_from_file`
#![allow(dead_code)]
Evidence
PR Compliance ID 1208563 requires modified source files to remain under ~200 lines. The current
test_utils.rs extends well beyond 200 lines (e.g., it includes code at and past line 300).

Rule 1208563: Source files must not exceed ~200 lines
crates/mcb-validate/tests/test_utils.rs[9-20]
crates/mcb-validate/tests/test_utils.rs[214-320]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`crates/mcb-validate/tests/test_utils.rs` is a modified source file that exceeds the ~200 line limit and should be split into smaller files/modules.

## Issue Context
Even though this is test code, it is still a source file and the guideline applies to modified files to prevent large monolithic modules.

## Fix Focus Areas
- crates/mcb-validate/tests/test_utils.rs[9-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. test_constants.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability
Description
The modified file crates/mcb-validate/tests/test_constants.rs still exceeds the ~200 line limit
after the cleanup, which increases maintenance burden for test infrastructure. It should be split
into smaller modules grouped by purpose (crate names, paths, rule IDs, etc.).
Code

crates/mcb-validate/tests/test_constants.rs[L21-32]

-/// Application layer test crate name.
-pub const APPLICATION_CRATE: &str = "my-application";
-
-/// Infrastructure layer test crate name.
-pub const INFRASTRUCTURE_CRATE: &str = "my-infrastructure";
-
-/// Providers layer test crate name.
-pub const PROVIDERS_CRATE: &str = "my-providers";
-
-/// Validate crate name (self-referential).
-pub const VALIDATE_CRATE: &str = "my-validate";
-
Evidence
PR Compliance ID 1208563 requires that modified source files should not exceed ~200 lines. The
current test_constants.rs reaches at least line 248.

Rule 1208563: Source files must not exceed ~200 lines
crates/mcb-validate/tests/test_constants.rs[240-248]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`crates/mcb-validate/tests/test_constants.rs` is a modified source file that exceeds the ~200 line limit and should be split into smaller modules.

## Issue Context
The PR removes a large block of constants but the file is still >200 lines; splitting will keep future test refactors simpler.

## Fix Focus Areas
- crates/mcb-validate/tests/test_constants.rs[21-32]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

Comment on lines +141 to +152
/// Generates a CRUD adapter struct wrapping a repository trait object.
macro_rules! impl_crud_adapter {
($name:ident($repo_ty:ty) { $($methods:item)* }) => {
struct $name(Arc<$repo_ty>);

#[async_trait]
impl EntityCrudAdapter for $name {
$($methods)*
}
};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remediation recommended

1. crud_adapter.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability

The modified file crates/mcb-server/src/admin/crud_adapter.rs is well over the ~200 line limit,
increasing maintenance risk and making future changes harder to review. This violates the guideline
to split large source files into submodules when they grow beyond ~200 lines.
Agent Prompt
## Issue description
`crates/mcb-server/src/admin/crud_adapter.rs` is a modified source file that exceeds the ~200 line limit and should be split to improve maintainability.

## Issue Context
The PR adds code to this already-large file, but the repository guideline requires splitting files that exceed ~200 lines.

## Fix Focus Areas
- crates/mcb-server/src/admin/crud_adapter.rs[141-152]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +9 to 12
//! - **Assertions**: `assert_no_violations`,
//! `assert_has_violation_matching`, `assert_no_violation_from_file`
#![allow(dead_code)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remediation recommended

2. test_utils.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability

The modified file crates/mcb-validate/tests/test_utils.rs exceeds the ~200 line limit, making it
harder to navigate and maintain as it grows. It should be split into smaller focused modules/files.
Agent Prompt
## Issue description
`crates/mcb-validate/tests/test_utils.rs` is a modified source file that exceeds the ~200 line limit and should be split into smaller files/modules.

## Issue Context
Even though this is test code, it is still a source file and the guideline applies to modified files to prevent large monolithic modules.

## Fix Focus Areas
- crates/mcb-validate/tests/test_utils.rs[9-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines -21 to -32
/// Application layer test crate name.
pub const APPLICATION_CRATE: &str = "my-application";

/// Infrastructure layer test crate name.
pub const INFRASTRUCTURE_CRATE: &str = "my-infrastructure";

/// Providers layer test crate name.
pub const PROVIDERS_CRATE: &str = "my-providers";

/// Validate crate name (self-referential).
pub const VALIDATE_CRATE: &str = "my-validate";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remediation recommended

3. test_constants.rs exceeds 200 lines 📘 Rule violation ⚙ Maintainability

The modified file crates/mcb-validate/tests/test_constants.rs still exceeds the ~200 line limit
after the cleanup, which increases maintenance burden for test infrastructure. It should be split
into smaller modules grouped by purpose (crate names, paths, rule IDs, etc.).
Agent Prompt
## Issue description
`crates/mcb-validate/tests/test_constants.rs` is a modified source file that exceeds the ~200 line limit and should be split into smaller modules.

## Issue Context
The PR removes a large block of constants but the file is still >200 lines; splitting will keep future test refactors simpler.

## Fix Focus Areas
- crates/mcb-validate/tests/test_constants.rs[21-32]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +20 to 22
/// Helper to set env var safely.
#[allow(unsafe_code)]
/// Helper to set env var safely
fn set_env(key: &str, value: &str) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remediation recommended

1. #[allow(unsafe_code)] lacks justification 📘 Rule violation ⚙ Maintainability

#[allow(unsafe_code)] is used without an inline justification comment on the same line or
immediately following line. This violates the requirement to document why a static-analysis
suppression is necessary, making future audits and maintenance harder.
Agent Prompt
## Issue description
`#[allow(unsafe_code)]` is a suppression directive but it has no inline justification comment on the same line or the next line, as required.

## Issue Context
This appears to be needed due to Rust 2024 requiring `unsafe` for `env::set_var`/`env::remove_var` in tests, but that rationale must be recorded inline next to the suppression.

## Fix Focus Areas
- crates/mcb-infrastructure/tests/unit/config_figment_tests.rs[20-22]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 15c4c6b

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 12 files

Confidence score: 4/5

  • In crates/mcb-infrastructure/tests/unit/config_figment_tests.rs, the unsafe environment-variable access is still unsound even with #[serial], so concurrent test execution can trigger undefined behavior or flaky results that hide real regressions — remove the unsafe env mutation pattern or isolate those cases in a single-threaded subprocess-based test path.
  • In crates/mcb-providers/src/database/sqlite/mod.rs, making implementation modules public duplicates already re-exported repository APIs and expands the crate’s semver surface unnecessarily, which can lock in internal layout and complicate future refactors — keep the modules private and expose only the intended re-exports.
  • In crates/mcb-server/src/admin/crud_adapter.rs, the as_ref() plus Some(ref field) combination creates an avoidable &&String, which can obscure intent and rely on coercions that may break with later signature changes — simplify the binding to a single-reference form.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/mcb-infrastructure/tests/unit/config_figment_tests.rs">

<violation number="1" location="crates/mcb-infrastructure/tests/unit/config_figment_tests.rs:23">
P2: These unsafe calls are not made sound merely by serializing the tagged tests: `#[serial]` does not make the shared `unit` test binary single-threaded, and the Rust safety contract also forbids concurrent environment reads outside `std::env`, not only concurrent mutations. Since this binary includes many ordinary and Tokio tests, this new safety rationale does not establish the required invariant on non-Windows targets. Consider running these cases in an actually single-threaded process (and enforcing that in the test command), or isolating environment mutation in subprocesses; the safety comment should state the full invariant that the implementation enforces.</violation>
</file>

<file name="crates/mcb-providers/src/database/sqlite/mod.rs">

<violation number="1" location="crates/mcb-providers/src/database/sqlite/mod.rs:14">
P3: The repository types are already available through the public re-exports, so making these two implementation modules public adds duplicate API paths and unnecessarily makes the module layout part of the crate's compatibility surface. This is also inconsistent with the other SQLite repository modules in this file. Keeping the modules private while retaining the existing `pub use` exports would preserve the intended API.</violation>
</file>

<file name="crates/mcb-server/src/admin/crud_adapter.rs">

<violation number="1" location="crates/mcb-server/src/admin/crud_adapter.rs:229">
P3: The sort-field binding now adds an unnecessary second reference: `as_ref()` already yields `Option<&String>`, while `Some(ref field)` makes `field` an `&&String`. Deref coercions/blanket implementations may hide this in the current calls, but it makes the type and intent harder to follow; matching with `Some(field)` keeps the field as `&String`.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.

Fix all with cubic | Re-trigger cubic

/// Helper to set env var safely
fn set_env(key: &str, value: &str) {
// SAFETY: Tests must run with --test-threads=1
// SAFETY: Tests run serially (#[serial]) — no concurrent env mutation.

@cubic-dev-ai cubic-dev-ai Bot Jul 29, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: These unsafe calls are not made sound merely by serializing the tagged tests: #[serial] does not make the shared unit test binary single-threaded, and the Rust safety contract also forbids concurrent environment reads outside std::env, not only concurrent mutations. Since this binary includes many ordinary and Tokio tests, this new safety rationale does not establish the required invariant on non-Windows targets. Consider running these cases in an actually single-threaded process (and enforcing that in the test command), or isolating environment mutation in subprocesses; the safety comment should state the full invariant that the implementation enforces.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/mcb-infrastructure/tests/unit/config_figment_tests.rs, line 23:

<comment>These unsafe calls are not made sound merely by serializing the tagged tests: `#[serial]` does not make the shared `unit` test binary single-threaded, and the Rust safety contract also forbids concurrent environment reads outside `std::env`, not only concurrent mutations. Since this binary includes many ordinary and Tokio tests, this new safety rationale does not establish the required invariant on non-Windows targets. Consider running these cases in an actually single-threaded process (and enforcing that in the test command), or isolating environment mutation in subprocesses; the safety comment should state the full invariant that the implementation enforces.</comment>

<file context>
@@ -17,19 +17,19 @@ use std::env;
-/// Helper to set env var safely
 fn set_env(key: &str, value: &str) {
-    // SAFETY: Tests must run with --test-threads=1
+    // SAFETY: Tests run serially (#[serial]) — no concurrent env mutation.
     unsafe {
         env::set_var(key, value);
</file context>
Fix with cubic

@@ -10,9 +10,11 @@ mod agent_repository;
mod ddl;

@cubic-dev-ai cubic-dev-ai Bot Jul 29, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The repository types are already available through the public re-exports, so making these two implementation modules public adds duplicate API paths and unnecessarily makes the module layout part of the crate's compatibility surface. This is also inconsistent with the other SQLite repository modules in this file. Keeping the modules private while retaining the existing pub use exports would preserve the intended API.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/mcb-providers/src/database/sqlite/mod.rs, line 14:

<comment>The repository types are already available through the public re-exports, so making these two implementation modules public adds duplicate API paths and unnecessarily makes the module layout part of the crate's compatibility surface. This is also inconsistent with the other SQLite repository modules in this file. Keeping the modules private while retaining the existing `pub use` exports would preserve the intended API.</comment>

<file context>
@@ -10,9 +10,11 @@ mod agent_repository;
 pub mod executor;
-mod issue_entity_repository;
+/// SQLite-backed issue entity repository implementation.
+pub mod issue_entity_repository;
 mod memory_repository;
-mod org_entity_repository;
</file context>
Fix with cubic

// Sort
if let Some(ref field) = params.sort_field
&& valid_sort_fields.contains(field.as_str())
if let Some(ref field) = params

@cubic-dev-ai cubic-dev-ai Bot Jul 29, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The sort-field binding now adds an unnecessary second reference: as_ref() already yields Option<&String>, while Some(ref field) makes field an &&String. Deref coercions/blanket implementations may hide this in the current calls, but it makes the type and intent harder to follow; matching with Some(field) keeps the field as &String.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/mcb-server/src/admin/crud_adapter.rs, line 229:

<comment>The sort-field binding now adds an unnecessary second reference: `as_ref()` already yields `Option<&String>`, while `Some(ref field)` makes `field` an `&&String`. Deref coercions/blanket implementations may hide this in the current calls, but it makes the type and intent harder to follow; matching with `Some(field)` keeps the field as `&String`.</comment>

<file context>
@@ -216,8 +226,10 @@ fn apply_filter_pipeline(
     // Sort
-    if let Some(ref field) = params.sort_field
-        && valid_sort_fields.contains(field.as_str())
+    if let Some(ref field) = params
+        .sort_field
+        .as_ref()
</file context>
Suggested change
if let Some(ref field) = params
if let Some(field) = params
Fix with cubic

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.

2 participants