feat: initial implementation of codeanalyzer-go#4
Draft
sinha108 wants to merge 6 commits into
Draft
Conversation
Adds the static code analysis engine for Go including syntactic analysis, schema definitions, CLI entrypoint, and test fixtures. Semantic analysis via CodeQL is scaffolded but not yet implemented. Signed-off-by: Saurabh Sinha <sinha108@gmail.com>
Incorporates the GitHub Go template (*.dll, *.so, go.work, .env, etc.) alongside project-specific ignores for built binaries and .claude/. Signed-off-by: Saurabh Sinha <sinha108@gmail.com>
Bug fix: populate InnerCallables by walking ast.FuncLit nodes in buildInnerCallables; add *ast.FuncLit: return false to buildCallSites so closure call sites are not double-counted in the outer function. New test files: - cmd/codeanalyzer/main_test.go: CLI integration tests covering --version, --format validation, --output, --analysis-level, --skip-tests, --target-files - internal/analysis/registry_test.go: orderPasses topo-sort tests and RunPipeline smoke test - internal/semantic_analysis/call_graph_test.go: MergeEdges unit tests - internal/utils/fs_test.go: table-driven tests for IsTestFile, IsVendored, FileHash, EnsureDir, DiscoverGoFiles - internal/core/skip_tests_test.go: SkipTests true/false behaviour - internal/core/incremental_test.go: TargetFiles single/multi package and nil Test additions to existing files: - chi_test.go: InnerCallables populated, IsConstructorCall for methodTyp() type conversion, init() presence and is_exported - multipackage_test.go (renamed from realistic_test.go): LocalVariables present with correct type and scope Testdata restructure: - testdata/fixture/ -> testdata/greeter/ - testdata/realistic/ -> testdata/multipackage/ - testdata/chi/: replace single-file wrapper with chi v5 library source (35 files) - testdata/generics/: add generics fixture (fn + set packages) - testdata/multipackage/server/server_test.go: minimal test file for --skip-tests=false coverage Signed-off-by: Saurabh Sinha <sinha108@gmail.com>
- Add .github/workflows/ci.yml: test (go build + go test) and lint (golangci-lint) jobs triggered on push to main/feat/** and PRs to main - Fix stale testdata path references in README (fixture/→greeter/, realistic/→multipackage/) and update test count (57→105) - Add /output/ to .gitignore to exclude generated analysis artifacts Signed-off-by: Saurabh Sinha <sinha108@gmail.com>
golangci-lint-action@v6 resolved to v1.64.8 (built with Go 1.24) which refuses to analyze go 1.25.0 modules. Installing via go install compiles the tool from source using the project's own toolchain, so the version check always passes. Signed-off-by: Saurabh Sinha <sinha108@gmail.com>
- fs_test.go: use writeFile helper for TestFileHash_DifferentContent and check os.MkdirAll error in TestDiscoverGoFiles_SkipsVendorDir - signature.go: remove unused signatureOfNamed, signatureForCall, normalizeReturnType functions and their unused strings import Signed-off-by: Saurabh Sinha <sinha108@gmail.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
analysis.json(symbol table + call graph) in the CLDK canonical schemaCLDK(language="go").analysis(project_path=...)go/ast+golang.org/x/tools/go/packagesgo/typesWhat's included
cmd/codeanalyzer— Cobra CLI (-i,-o,-a,-t,--skip-tests,--eager,--cache-dir,-v,--version)internal/syntactic_analysis—SymbolTableBuilder: structs, interfaces, methods, generics, closures, call sites, cyclomatic complexity, struct tags, cross-file method reconciliationinternal/semantic_analysis—CallGraphBuilder:go/typesresolver backfillscallee_signatureand emits project-internal call edges; CodeQL backend wired but stubbedinternal/analysis— pluggable pass registry with topological ordering (extension seam for framework passes)internal/frameworks—BaseEntrypointFinderseam for Gin/net-http entrypoint detectioninternal/schema— canonical output types (GoApplication,GoFile,GoType,GoCallable,GoCallsite,GoCallEdge) with spine-compatible JSON keysTest fixtures
testdata/greeter/testdata/multipackage/testdata/generics/Set[T], union-constraint interfaces, multi-type-param functions)testdata/chi/init()105 tests across symbol table correctness, call graph edges, generics, JSON round-trip, caching, incremental analysis, and error paths.
Test plan
go test ./...passes (all 105 tests)go build ./...succeedsgo vet ./...cleananalysis.json