refactor: migrate shared algorithms to codescan-core#43
Open
DaisukeYoda wants to merge 6 commits intomainfrom
Open
refactor: migrate shared algorithms to codescan-core#43DaisukeYoda wants to merge 6 commits intomainfrom
DaisukeYoda wants to merge 6 commits intomainfrom
Conversation
Replace local implementations of CFG, APTED, MinHash/LSH, clone grouping, and Tarjan SCC with language-agnostic equivalents from codescan-core. Keep only JavaScript/TypeScript-specific logic locally (parser, classifiers, cost models). Fix complexity calculation bug where nested function bodies inflated parent function complexity scores. Deleted files (7): cfg.go, apted.go, apted_tree.go, minhash.go, lsh_index.go, ast_features.go, grouping_strategy algorithms. New files (3): js_classifier.go (StatementClassifier), js_complexity.go (ComplexityContributor), tree_converter.go (AST→APTED TreeNode). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
P1: Add TODO comment to replace directive — cannot remove until codescan-core is published to a Go module proxy. P2: Populate Nodes field in ComplexityResult using cfg.Size() so node counts are no longer reported as 0 in CSV/JSON/text outputs. P3: Fix nil dereference in Clone.ItemKey() — check c == nil before accessing c.ID to prevent panic on nil clone pointers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use the published v0.1.0 module from the Go module proxy instead of a local path replacement. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
corecfg counts EdgeLoop back-edges as decision points, but jscan's CFG already creates EdgeCondTrue/EdgeCondFalse at loop headers. Subtract loop back-edge count to avoid double-counting each loop. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
codescan-core v0.1.1 no longer counts EdgeLoop back-edges as decision points, so the jscan-side subtraction workaround is no longer needed. Co-Authored-By: Claude Opus 4.6 <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
codescan-coreJSStatementClassifier,JSComplexityContributor,TreeConverter,DirectedGraphAdapter,GroupableItemondomain.Clonenode.Walk()traversed into nested function bodies, inflating parent function complexity (e.g. lodashanonymous_9: 1034 → 27)Deleted files (7)
internal/analyzer/cfg.gocodescan-core/cfginternal/analyzer/apted.gocodescan-core/aptedinternal/analyzer/apted_tree.gocodescan-core/aptedinternal/analyzer/minhash.gocodescan-core/lshinternal/analyzer/lsh_index.gocodescan-core/lshinternal/analyzer/ast_features.gocodescan-core/cloneinternal/analyzer/grouping_strategy.go(algorithms)codescan-core/clone(generics)New files (3)
internal/analyzer/js_classifier.gocfg.StatementClassifierfor JS return/break/continue/throwinternal/analyzer/js_complexity.gocfg.ComplexityContributorfor JS logical/ternary operatorsinternal/analyzer/tree_converter.go*parser.Node→*apted.TreeNodeconversionTest plan
go build ./...passesgo test ./...— all tests passgo vet ./...— no issuesjscan analyze,jscan check,jscan depson lodash test repo🤖 Generated with Claude Code