|
| 1 | +--- |
| 2 | +applyTo: "src/**/*.ps1,tests/**/*.ps1" |
| 3 | +--- |
| 4 | + |
| 5 | +# Agentic code quality matrix |
| 6 | + |
| 7 | +## Purpose |
| 8 | + |
| 9 | +Use this file as the best-effort code quality matrix for generated and reviewed code in this repository. |
| 10 | + |
| 11 | +The matrix translates the repository's preferred `src/**` and `tests/**` maintainability thresholds into agent guidance, so agents can shape code toward the expected quality from the start. This guidance does **not** require a `.codescene/code-health-rules.json` file in generated projects. |
| 12 | + |
| 13 | +## How to use the matrix |
| 14 | + |
| 15 | +- Treat warning thresholds as the default design ceiling for new or heavily changed code. |
| 16 | +- Treat alert thresholds as refactor-now signals for new or heavily changed code. |
| 17 | +- When a threshold has no alert value, stay below the warning threshold by default. |
| 18 | +- When a threshold is marked `not used`, do not optimize around it; focus on the other limits instead. |
| 19 | +- If a change must exceed a threshold, call it out in the handoff and explain the trade-off clearly. |
| 20 | + |
| 21 | +## Source code matrix (`**/src/**`) |
| 22 | + |
| 23 | +| Threshold | Warning | Alert | Best-effort authoring guidance | |
| 24 | +|----------------------------------------------------|------------------|-------|--------------------------------------------------------------------------------------------------------------| |
| 25 | +| `constructor_max_arguments` | `4` | — | Extract parameter objects or workflow-context objects before constructors exceed four inputs. | |
| 26 | +| `file_mean_cyclomatic_complexity_warning` | `26` | — | Split growing files or extract helpers before the file's average complexity drifts past this point. | |
| 27 | +| `function_complex_conditional_branches_warning` | `6` | `11` | Break up long boolean expressions before complex branch conditions become hard to read. | |
| 28 | +| `function_cyclomatic_complexity_warning` | `6` | `11` | Extract helpers and flatten control flow before a function becomes a local hotspot. | |
| 29 | +| `function_duplication_min_lines_of_code_for_check` | `6 lines` | — | Treat six or more repeated lines as an extraction candidate. | |
| 30 | +| `function_duplication_min_similarity_percentage` | `89% similarity` | — | Consolidate near-copy/paste logic even when names or literals differ slightly. | |
| 31 | +| `function_lines_of_code_warning` | `16` | `31` | Keep new or heavily changed functions short; extract helpers before they drift beyond the warning threshold. | |
| 32 | +| `function_max_arguments` | `4` | — | Introduce context objects, parameter objects, or helper abstractions before functions exceed four inputs. | |
| 33 | +| `function_nesting_depth_warning` | `6` | — | Flatten nested control flow early; do not let new logic grow into deep indentation towers. | |
| 34 | + |
| 35 | +## Test code matrix (`**/tests/**`) |
| 36 | + |
| 37 | +| Threshold | Warning | Alert | Best-effort authoring guidance | |
| 38 | +|----------------------------------------------------|------------|------------------------------|--------------------------------------------------------------------------------------------------------------------------| |
| 39 | +| `constructor_max_arguments` | `5` | — | Keep test helper constructors simple; prefer factory helpers or setup objects before they sprawl. | |
| 40 | +| `file_lines_of_code_for_warning` | `1000` | `5000` (`critical`: `10000`) | Split oversized test files by source ownership or behavior before they become hard to review. | |
| 41 | +| `file_mean_cyclomatic_complexity_warning` | `4` | — | Refactor test helpers or `BeforeAll` setup when a file becomes too branch-heavy overall. | |
| 42 | +| `file_primitive_obsession_percentage_for_warning` | `0.3` | — | Extract builders, fixtures, or named data objects when tests lean too heavily on raw strings, ints, and hashtables. | |
| 43 | +| `function_bumpy_road_bumps_for_warning` | `2` | — | Keep each test focused on one logical path; extract setup helpers when the flow breaks into many chunks. | |
| 44 | +| `function_bumpy_road_nesting_level_depth` | `2` | — | Keep test logic shallow and linear; avoid nested setup trees in individual test functions. | |
| 45 | +| `function_complex_conditional_branches_warning` | `2` | `10` | Prefer separate tests or helper functions over highly conditional test logic. | |
| 46 | +| `function_cyclomatic_complexity_warning` | `9` | `100` | Split test helpers or parameterized cases before one test function turns into control-flow-heavy code. | |
| 47 | +| `function_embedded_content_lines_of_code_warning` | `not used` | `not used` | Do not optimize for this metric; focus on the other thresholds instead. | |
| 48 | +| `function_lines_of_code_warning` | `70` | `500` | Keep new or heavily changed test functions compact; extract setup and assertion helpers when they grow too large. | |
| 49 | +| `function_max_arguments` | `4` | — | Keep helper/test function signatures tight; prefer fixtures or context objects over long parameter lists. | |
| 50 | +| `function_nesting_depth_warning` | `4` | — | Flatten nested assertions and setup paths before they become difficult to follow. | |
| 51 | +| `unit_test_consecutive_asserts_for_large_block` | `4` | — | Split assertion helpers or use richer comparison helpers before an assertion block grows past four consecutive asserts. | |
| 52 | +| `unit_test_suite_number_of_large_assertion_blocks` | `4` | — | If a suite accumulates multiple large assertion blocks, extract reusable assertion helpers instead of copy/paste growth. | |
| 53 | + |
| 54 | +## Review expectations |
| 55 | + |
| 56 | +- PowerShell implementation agents should use the source code matrix while shaping `src/**/*.ps1`. |
| 57 | +- Test-focused agents should use the test code matrix while shaping `tests/**/*.ps1`. |
| 58 | +- Review agents should flag new or heavily changed code that ignores the warning thresholds without a clear, justified reason. |
0 commit comments