code wiki / (root) / nx_code_quality.nx

nx_code_quality.nx

buildroot/runtime/nx_code_quality.nx

14479 B389 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic code
docsdependenciesstructsconstsfunctions

about

nx_code_quality.nx -- qualitative + quantitative code refactor verdict. Six measurable axes -> Q10 score per axis + sealed-enum CodeQualityVerdict. Operates on a source-text byte buffer (any language whose lexical substrate uses { } ( ) [ ] for nesting + // for comments -- which covers NishiLang, C, Rust, Go, Java, JavaScript, TypeScript, C++). Refactor triggers (each maps to a Q10 axis): 1. NULL_PTR_HAZARD count of `0 as *` patterns (NULL sentinel) normalized by source length 2. HARDCODING_SCORE count of `* 8`, `* 4` literals not in comments (cardinal-violation signal: should be NX_SIZEOF_NX_INT etc.) 3. NESTING_HAZARD maximum bracket nesting depth (cyclomatic proxy; deep nesting -> refactor) 4. REPETITION_HAZARD line-length-diversity proxy (very uniform line lengths -> repetition; very long single lines -> readability issue) 5. COMMENT_DEFICIT comment density below threshold -> documentation gap 6. TIER_COMPLIANCE bare `i64 ` occurrences (should use nx_int / nx_size / nx_idx aliases) Composite_q10 = inverse-weighted sum across axes (low hazard count + good comment density + nx_tier compliance = high composite). Sealed-enum verdict: NX_CQ_REFACTOR_HOT composite < 300 immediate refactor NX_CQ_REFACTOR_RECOMMENDED 300 <= comp < 600 NX_CQ_ACCEPTABLE 600 <= comp < 800 NX_CQ_EXCELLENT comp >= 800 Cross-language: same primitive over any text-source byte stream (NishiLang .nx, C .c, Rust .rs, prose .txt -- though the cardinal- violation axes 1, 2, 6 are NishiLang-specific; they read as no-op on other languages where those patterns don't appear). "Competitive coding best practices" reading per dual-reading cardinal: the qualitative verdict names WHICH refactor is most

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_tier.nx nx_code_quality.nx nx_code_quality_test.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_code_quality_test.nx

structs

74struct CodeQualityReport

consts

57const NX_CQ_Q: nx_int = 1024
58const NX_CQ_MAX_NESTING_OK: nx_int = 5
60const NX_CQ_REFACTOR_HOT: nx_int = 0
61const NX_CQ_REFACTOR_RECOMMENDED: nx_int = 1
62const NX_CQ_ACCEPTABLE: nx_int = 2
63const NX_CQ_EXCELLENT: nx_int = 3
64const NX_CQ_N_VERDICTS: nx_int = 4
66const NX_CQ_AXIS_NULL_PTR: nx_int = 0
67const NX_CQ_AXIS_HARDCODING: nx_int = 1
68const NX_CQ_AXIS_NESTING: nx_int = 2
69const NX_CQ_AXIS_REPETITION: nx_int = 3
70const NX_CQ_AXIS_COMMENT: nx_int = 4
71const NX_CQ_AXIS_TIER: nx_int = 5
72const NX_CQ_N_AXES: nx_int = 6

functions

95func _cq_match_at(buf: *u8, len: nx_int, pos: nx_int, lit: *u8, n: nx_int) -> nx_int
108func _cq_in_comment(buf: *u8, pos: nx_int) -> nx_int
127func nx_code_quality_scan(buf: *u8, len: nx_int, report: *CodeQualityReport) -> nx_int
286func nx_code_quality_score(report: *CodeQualityReport) -> nx_int
371func nx_code_quality_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
377func nx_code_quality_axis_is_valid(a: nx_int) -> nx_int
called by 1: main
385func nx_code_quality_compute(buf: *u8, len: nx_int, report: *CodeQualityReport) -> nx_int