You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/codebase-audit-suite/skills/ln-624-code-maintainability-hotspot-auditor/SKILL.md
+38-15Lines changed: 38 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: ln-624-code-maintainability-hotspot-auditor
3
-
description: "Checks local maintainability hotspots: complexity, long methods, god modules, signatures, algorithms, and constants. Use when auditing code hotspots."
3
+
description: "Checks local maintainability hotspots: complexity, long methods, god modules, signatures, algorithms, and constants. Also flags identifier drift across API/DTO/DB layers. Use when auditing code hotspots."
**Domain-aware:** Supports `domain_mode` + `current_domain` (see `audit_output_schema.md#domain-aware-worker-output`).
32
32
33
-
Use `hex-graph` first when hotspots, architecture coupling, or semantic relationships materially improve the audit. Use `hex-line` first for local code reads when available. If MCP is unavailable, unsupported, or not indexed, continue with built-in `Read/Grep/Glob/Bash` and state the fallback in the report.
34
-
35
33
## Workflow
36
34
37
35
Detection policy: use two-layer detection (candidate scan, then context verification); load `references/two_layer_detection.md` only when the verification method is ambiguous.
@@ -50,6 +48,7 @@ Detection policy: use two-layer detection (candidate scan, then context verifica
50
48
- Cyclomatic complexity: is complexity from switch/case on enum (valid) or deeply nested conditions (bad)? Enum dispatch -> downgrade to LOW or skip
- God class: is it a config/schema/builder class? -> downgrade
51
+
- Identifier drift: is the rename mediated by an explicit serializer alias (`@JsonProperty`, `alias_generator`, `@SerializedName`) or an ORM column mapping (`@Column(name=...)`)? If yes -> downgrade or skip
53
52
4)**Collect findings with severity, location, effort, recommendation**
54
53
- Tag each finding with `domain: domain_name` (if domain-aware)
55
54
5)**Calculate score using penalty algorithm**
@@ -211,6 +210,34 @@ Detection policy: use two-layer detection (candidate scan, then context verifica
211
210
212
211
**Effort:** S-M (refactor signatures + callers)
213
212
213
+
### 9. Identifier Consistency Across Layers
214
+
**What:** Same concept uses different identifiers across API contracts, DTOs, services, repositories, DB columns, or internal modules
215
+
216
+
**Detection:**
217
+
218
+
| Issue | Pattern | Example |
219
+
|-------|---------|---------|
220
+
| External contract drift | API/OpenAPI/external-schema field name differs from DTO/service/repo/DB column |`user_id` in OpenAPI but `uid` in DTO, `userId` in service, `user` column in DB |
221
+
| Synonym drift (internal) | Same entity referenced by competing names across modules |`customer` vs `client` vs `account` vs `user` for one concept |
222
+
| Unmediated casing/translation | snake/camel/kebab swap without an explicit serializer alias |`created_at` API field assigned to `creationTime` with no alias declared |
223
+
| Abbreviation drift | Full and abbreviated forms coexist for one concept |`organization` vs `org` vs `orgId` vs `organizationId`|
224
+
225
+
**Severity:**
226
+
-**HIGH:** External-contract field renamed inside code without an explicit serializer alias -- silent breakage risk when the upstream contract changes
227
+
-**MEDIUM:** Synonym drift for one entity across 3+ modules (`customer` / `client` / `account`)
228
+
-**MEDIUM:** Casing translation without an explicit alias mapping
229
+
-**LOW:** Two-variant drift in one bounded module; abbreviation drift in internal-only code
230
+
-**Downgrade when:** ORM-mediated mapping with explicit column alias, framework-required transforms (e.g. GraphQL camelCase via codegen), generated DTOs from contract, language-keyword collision forcing rename -> downgrade or skip
231
+
232
+
**Layer 2 requirement:** Synonym drift detection relies on a curated project glossary or on reading usage context. Grep alone is insufficient -- always confirm the two identifiers refer to the same concept before reporting.
233
+
234
+
**Recommendation:**
235
+
-**External-contract case:** carry the external API name as-is through DTO / service / repository / DB column. If casing or language conventions conflict, configure a serializer alias once at the boundary (`@JsonProperty`, `alias_generator`, `@SerializedName`) rather than renaming the field inside the code
236
+
-**Internal-only case:** pick the most semantically precise variant, apply find/replace across the modules, record the canonical term in a shared glossary or shared constants/enum module. Add a lint rule or codegen step where possible to prevent reintroduction
237
+
- For verb naming within a single module, see Rule #8 (Method Signature Quality)
238
+
239
+
**Effort:** S-M (rename + serializer config). L when a DB column rename plus migration is required
@@ -221,9 +248,7 @@ Detection policy: use two-layer detection (candidate scan, then context verifica
221
248
222
249
Write JSON summary per `references/audit_summary_contract.md`. In managed mode the caller passes both `runId` and `summaryArtifactPath`; in standalone mode the worker generates its own run-scoped artifact path per shared contract.
223
250
224
-
Write report to `{output_dir}/ln-624--{domain}.md` (or `624-quality.md` in global mode) with `category: "Code Maintainability Hotspots"` and checks: cyclomatic_complexity, deep_nesting, long_methods, god_classes, too_many_params, quadratic_algorithms, magic_numbers, method_signatures.
225
-
226
-
Return summary per `references/audit_summary_contract.md`.
251
+
Write report to `{output_dir}/ln-624--{domain}.md` (or `624-quality.md` in global mode) with `category: "Code Maintainability Hotspots"` and checks: cyclomatic_complexity, deep_nesting, long_methods, god_classes, too_many_params, quadratic_algorithms, magic_numbers, method_signatures, identifier_consistency.
227
252
228
253
When `summaryArtifactPath` is absent, write the standalone runtime summary under `.hex-skills/runtime-artifacts/runs/{run_id}/evaluation-worker/{worker}--{identifier}.json` and optionally echo the same summary in structured output.
229
254
```
@@ -238,20 +263,18 @@ Apply the already-loaded `references/audit_worker_core_contract.md`.
238
263
-**Do not auto-fix:** Report only
239
264
-**Domain-aware scanning:** If `domain_mode="domain-aware"`, scan ONLY `scan_path` (not entire codebase)
240
265
-**Tag findings:** Include `domain` field in each finding when domain-aware
241
-
-**Context-aware:** Small functions (n < 100) with O(n^2) may be acceptable
242
-
-**Constants detection:** Exclude test files, configs, examples
243
266
-**Metrics tools:** Use existing tools when available (ESLint complexity plugin, radon, gocyclo)
244
-
-**Unique angle:** Audit local maintainability hotspots only. Do not audit duplication, package health, architecture boundaries, N+1 persistence behavior, or orchestration ownership.
245
-
-**Action required:** Every finding uses `REFACTOR_HOTSPOT`, `SIMPLIFY_SIGNATURE`, or `EXTRACT_CONSTANT`.
267
+
-**Unique angle:** Audit local maintainability hotspots only. Do not audit duplication, package health, architecture boundaries, N+1 persistence behavior, or orchestration ownership. Identifier-consistency findings cover naming continuity of one concept across layers; this is distinct from ln-623 (code duplication) and ln-643 (DTO presence / layer leakage in signatures).
268
+
-**Action required:** Every finding uses `REFACTOR_HOTSPOT`, `SIMPLIFY_SIGNATURE`, `EXTRACT_CONSTANT`, or `UNIFY_IDENTIFIER`.
246
269
247
270
## Definition of Done
248
271
249
272
Apply the already-loaded `references/audit_worker_core_contract.md`.
0 commit comments