Skip to content

sync: catch up scoring with pyscn (initial catch-up 2/3)#51

Merged
DaisukeYoda merged 1 commit into
mainfrom
sync/catchup-scoring
Jun 11, 2026
Merged

sync: catch up scoring with pyscn (initial catch-up 2/3)#51
DaisukeYoda merged 1 commit into
mainfrom
sync/catchup-scoring

Conversation

@DaisukeYoda

@DaisukeYoda DaisukeYoda commented Jun 11, 2026

Copy link
Copy Markdown
Member

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 for domain/analyze.go / domain/system_analysis.go / domain/complexity.go and ported the missing scoring changes.

Ported changes

pyscn commit Change jscan files changed
0886cfb, 760bc87, 68b6d2b Switch the duplication metric to K-Core clone-group density (groups per 1000 lines × 20, capped at 10%) with a 0–10% penalty scale domain/analyze.go, service/output_formatter.go
333c9ac, 9c84a3d Soften CBO coupling calibration (medium weight 0.5→0.3, saturation at weighted ratio 0.40). Introduce the CouplingMediumWeight / CouplingSaturationRatio constants domain/analyze.go
3c9927c Use compliance directly as the ArchitectureScore (98% compliance = 98 points) domain/analyze.go
e6b9920 Expose WeightedViolations to make ComplianceScore reproducible (ported for type alignment) domain/system_analysis.go
2cc013c Report module-scope code as <module> instead of __main__ (introduce the domain.ModuleFunctionName constant 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.go

Mirroring 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)

  • LCOM cohesion scoring (54698b6, 57fcc66) — depends on the unported LCOM4 feature
  • Cognitive complexity / RawMetrics (8aa6d21, ce469ce) — unported features
  • Mock/synthetic fixture detection (15bd414) — pyscn-specific lint feature
  • Suggestions (1eaf9f6) — depends on the unported domain/suggestion.go
  • Analyze config plumbing (222d190, 779200a, 13644b4, e79a414, d6fd3da, ca75d12) — jscan's config-loader layer is structured differently, out of scope
  • Architecture style presets / warn rules / neutral prefixes / cohesion-responsibility validation (ad79460, 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 in coupling_metrics.go from TS interfaces/abstract classes
  • Django migration exclusion / Python default patterns (a33f1c7) — Python-specific

Also documented jscan's intentional divergences in the SYNC.md file-mapping notes (calculateComplexityPenalty uses the high/medium count ratio; calculateDeadCodePenalty uses a per-file rate) so future syncs don't overwrite them.

Verification

  • make test passes
  • Golden comparison on test-repos/ (latest-version, junk, express):
    • latest-version / junk: the only difference is architecture_score 100→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 output
    • express: code_duplication_percentage 56.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), and architecture_score 100→0 (same as above). The ±a-few jitter in clone_pairs reproduces 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

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>
@DaisukeYoda DaisukeYoda merged commit c372c29 into main Jun 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant