sync: catch up scoring with pyscn (initial catch-up 2/3)#51
Merged
Conversation
Port pyscn scoring changes to jscan per SYNC.md: - Duplication metric switched to K-Core clone-group density (groups per 1000 lines * 20, capped at 10%) with a 0-10% penalty scale (pyscn 0886cfb, 760bc87, 68b6d2b) - CBO coupling calibration softened: medium weight 0.5 -> 0.3, saturation ratio at 0.40 (pyscn 333c9ac, 9c84a3d) - Architecture score now uses compliance directly (pyscn 3c9927c) - Expose WeightedViolations on ArchitectureAnalysisResult to make ComplianceScore reproducible (pyscn e6b9920) - Report module-scope code as "<module>" instead of "__main__" via domain.ModuleFunctionName (pyscn 2cc013c) Skipped (recorded in SYNC.md pending changes): LCOM cohesion scoring, cognitive complexity / raw metrics, mock data detection, suggestions, analyze config plumbing, architecture style presets, AbstractClassCount, Python-specific default patterns. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second phase of the initial catch-up per SYNC.md (Scoring area). Compared the cumulative pyscn
origin/main(8650522) diff against jscan's current state fordomain/analyze.go/domain/system_analysis.go/domain/complexity.goand ported the missing scoring changes.Ported changes
0886cfb,760bc87,68b6d2bdomain/analyze.go,service/output_formatter.go333c9ac,9c84a3dCouplingMediumWeight/CouplingSaturationRatioconstantsdomain/analyze.go3c9927cdomain/analyze.goe6b9920WeightedViolationsto make ComplianceScore reproducible (ported for type alignment)domain/system_analysis.go2cc013c<module>instead of__main__(introduce thedomain.ModuleFunctionNameconstant and route all internal sentinel comparisons through it)domain/complexity.go,internal/analyzer/cfg_builder.go,service/complexity_service.go,service/dead_code_service.go,service/dead_code_aggregate.goMirroring pyscn's test updates (expected-value changes in analyze_test.go), added duplication / CBO / architecture score tests to
domain/analyze_test.go, adapted to jscan's formulas.Skipped changes (recorded in SYNC.md pending changes)
54698b6,57fcc66) — depends on the unported LCOM4 feature8aa6d21,ce469ce) — unported features15bd414) — pyscn-specific lint feature1eaf9f6) — depends on the unporteddomain/suggestion.go222d190,779200a,13644b4,e79a414,d6fd3da,ca75d12) — jscan's config-loader layer is structured differently, out of scopead79460,1c9839d,61f0431,3708845,ddcf1c5) — jscan does not implement architecture validation (types are unused scaffolding)AbstractClassCount(f63540d) — Python ABC detection; jscan computes abstractness its own way incoupling_metrics.gofrom TS interfaces/abstract classesa33f1c7) — Python-specificAlso documented jscan's intentional divergences in the SYNC.md file-mapping notes (
calculateComplexityPenaltyuses the high/medium count ratio;calculateDeadCodePenaltyuses a per-file rate) so future syncs don't overwrite them.Verification
make testpassestest-repos/(latest-version, junk, express):architecture_score100→0, exactly as the ported formula dictates (jscan does not implement architecture validation, so compliance=0; pyscn produces the same value when arch is disabled). This is a JSON-only field, not shown in HTML/CLI outputcode_duplication_percentage56.4→10.0 (the group-density metric's cap; the penalty is the full 20 both before and after, so the health score stays at 74/C), andarchitecture_score100→0 (same as above). The ±a-few jitter inclone_pairsreproduces across re-runs of the same binary — pre-existing nondeterminism, unrelated to this change (clone detection is untouched). Function lists, complexity, and dead-code aggregates match exactly🤖 Generated with Claude Code