feat: add language-agnostic analysis packages for pyscn parity#1
Open
DaisukeYoda wants to merge 1 commit intomainfrom
Open
feat: add language-agnostic analysis packages for pyscn parity#1DaisukeYoda wants to merge 1 commit intomainfrom
DaisukeYoda wants to merge 1 commit intomainfrom
Conversation
Add 7 new packages and extend clone/ to extract all language-independent logic from pyscn into codescan-core, enabling pyscn to import these directly instead of maintaining its own copies. New packages: - domain/: shared error types, risk levels, clone types, default thresholds - dfa/: data flow analysis with DefUse chains and reaching definitions - semantic/: CFG+DFA semantic similarity comparison - cbo/: Coupling Between Objects metric with risk assessment - lcom/: Lack of Cohesion of Methods (LCOM4) via Union-Find - nesting/: nesting depth analysis via NestingClassifier interface - source/: file collection with glob pattern filtering Extended clone/ with: - fragment.go: CodeFragment implementing GroupableItem - similarity.go: SimilarityAnalyzer interface + APTED-based StructuralAnalyzer - classifier.go: cascade clone classifier (Type-1 → Type-4) 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
domain/,dfa/,semantic/,cbo/,lcom/,nesting/,source/) and extendclone/with 3 new files to extract all language-independent analysis logic from pyscn into codescan-coreanytyped fields) so language-specific logic remains in pyscn/jscanNew packages
domain/DomainError),RiskLevel,CloneType,OutputFormat,SortCriteria, and all default threshold constantsdfa/DefUseKind,VarReference,DefUsePair,DefUseChain,DFAInfo,DFAFeatures, andDFABuilderwithRefExtractorinterface for language adapterssemantic/ExtractCFGFeatures,CompareCFGFeatures,CompareDFAFeatures,ComputeSimilaritywith configurable weightscbo/ComputeCBOwith dependency kind breakdown and risk assessmentlcom/nesting/NestingClassifierinterface for language-agnostic tree traversalsource/Extended
clone/packagefragment.goCodeFragment(implementsGroupableItem),ClonePair,CloneGroup,CloneStatisticssimilarity.goSimilarityAnalyzerinterface +StructuralAnalyzerwrapping APTEDclassifier.goKey design decisions
dfa.RefExtractorandnesting.NestingClassifierare interfaces so language-specific AST logic stays in pyscn/jscansemantic.ComputeSimilarityreturns 0.0 for nil CFGs to prevent false-positive matches on parse failuresdfa.DFABuilder.Buildvalidates the extractor is non-nil before use, returning an error instead of panickingTest plan
go test ./... -count=1— all 13 packages pass (24 new files, 4261 lines added)go vet ./...— cleango build ./...— clean🤖 Generated with Claude Code