desloppify version: 0.9.15
Language: Rust
Bug
desloppify zone (run with no args to list classifications) classifies every src/foo_tests.rs file as production zone. These files contain #[test] functions and are included into their parent module via #[cfg(test)] #[path = "foo_tests.rs"] mod tests; — they ARE test code by construction. They should be in test zone so structural / file-size / code-quality checks apply test-rules to them, not production-rules.
Steps to reproduce
$ desloppify zone
Zone classifications (36 files)
production (36 files)
src/boot.rs
src/boot_tests.rs ← test file, but classified production
src/calibration.rs
src/calibration_tests.rs ← test file, but classified production
src/cli.rs
src/cli_tests.rs ← test file, but classified production
...
All 14 sibling *_tests.rs files are in production. Their content is exclusively #[test] fn ... bodies. Sample:
// src/cli_tests.rs (head)
// Tests for cli module — included via #[path = "cli_tests.rs"] from src/cli.rs.
// This file IS the body of the tests module — no outer `mod tests {}` wrapper.
use super::*;
#[test]
fn test_default_5m() {
let cli = CliArgs::parse_from(args(&[]));
...
}
Expected behavior
The zone classifier should recognize one of:
- Filename pattern
*_tests.rs — uniform Rust convention.
- Files referenced by
#[cfg(test)] #[path = "..."] mod tests; declarations — parse parent file for the path attribute.
- Files where every top-level item is
#[test] or use — content-based heuristic.
Any of these would correctly classify the sibling test files as test zone.
Concrete impact on the score
Because all *_tests.rs files are tagged production, they:
- Count toward
File health (structural detector flags large files including test files)
- Count toward
Code quality (smells / unused / etc detectors run on them as if production)
- Trigger
security::hardcoded_secret_name on test fixtures (Issue 9 — every test fixture with api_key: "K" becomes a "production" hardcoded secret)
- Are scanned for
cargo_error / clippy_warning as production code
This is the root cause of several other issues I filed:
- Issue 9 (security false-positives on test fixtures) would not exist if test fixtures were in
test zone with relaxed security rules
- Issue 7 (test_coverage detector) wouldn't flag inline test files as untested
Suggested fix
In desloppify/engine/policy/zones.py (or the language-specific Rust zone classifier), add:
def classify_rust_zone(path: Path, parent_module_content: str | None = None) -> str:
if path.name.endswith('_tests.rs'):
return 'test'
if path.name.startswith('test_') and path.suffix == '.rs':
return 'test'
if 'tests/' in str(path):
return 'test'
# ... rest of classifier
And, if you want to be thorough, parse the parent foo.rs file for #[cfg(test)] #[path = "foo_tests.rs"] mod tests; and follow the link.
Impact
Misclassifying ~half of all source files as production inflates the work-item count for every detector that runs on production code, drives File health below where it should be, and reproduces every test-fixture false positive at runtime cost. Fixing this single classifier would resolve or significantly reduce previously reported issues.
desloppify version: 0.9.15
Language: Rust
Bug
desloppify zone(run with no args to list classifications) classifies everysrc/foo_tests.rsfile asproductionzone. These files contain#[test]functions and are included into their parent module via#[cfg(test)] #[path = "foo_tests.rs"] mod tests;— they ARE test code by construction. They should be intestzone so structural / file-size / code-quality checks apply test-rules to them, not production-rules.Steps to reproduce
$ desloppify zone Zone classifications (36 files) production (36 files) src/boot.rs src/boot_tests.rs ← test file, but classified production src/calibration.rs src/calibration_tests.rs ← test file, but classified production src/cli.rs src/cli_tests.rs ← test file, but classified production ...All 14 sibling
*_tests.rsfiles are inproduction. Their content is exclusively#[test] fn ...bodies. Sample:Expected behavior
The zone classifier should recognize one of:
*_tests.rs— uniform Rust convention.#[cfg(test)] #[path = "..."] mod tests;declarations — parse parent file for the path attribute.#[test]oruse— content-based heuristic.Any of these would correctly classify the sibling test files as
testzone.Concrete impact on the score
Because all
*_tests.rsfiles are taggedproduction, they:File health(structural detector flags large files including test files)Code quality(smells / unused / etc detectors run on them as if production)security::hardcoded_secret_nameon test fixtures (Issue 9 — every test fixture withapi_key: "K"becomes a "production" hardcoded secret)cargo_error/clippy_warningas production codeThis is the root cause of several other issues I filed:
testzone with relaxed security rulesSuggested fix
In
desloppify/engine/policy/zones.py(or the language-specific Rust zone classifier), add:And, if you want to be thorough, parse the parent
foo.rsfile for#[cfg(test)] #[path = "foo_tests.rs"] mod tests;and follow the link.Impact
Misclassifying ~half of all source files as production inflates the work-item count for every detector that runs on production code, drives File health below where it should be, and reproduces every test-fixture false positive at runtime cost. Fixing this single classifier would resolve or significantly reduce previously reported issues.